I accidentally deleted /etc/nginx, reinstalling nginx won't recover it

Solution 1:

Force the reinstall of the default config files with the --force-confmiss option of dpkg.

Looks like the packaging layout for nginx changed in 11.04. If you're on 10.10 or older:

sudo dpkg --force-confmiss -i /var/cache/apt/archives/nginx_*.deb

Or 11.04 and newer:

sudo dpkg --force-confmiss -i /var/cache/apt/archives/nginx-common_*.deb

Solution 2:

check for the deb package in your ubuntu system [your version of deb file may be different]

/var/cache/apt/archives/nginx-common_0.8.54-4_all.deb

open it using archive manager. Inside the archive check for folder /etc/nginx

This is the default nginx installation cfg folder. You can copy from here to /etc .


Solution 3:

Don't just apt-get remove it, this will leave configurations behind. apt-get purge it, and any unused dependency. You can check inatallation status by grepping dpkg -l output

Tags:

Nginx

Ubuntu

Apt