Sunday, May 3, 2015

How to restore the nginx.conf to default

Sometimes you mess up the nginx.conf of your server just like me a couple days ago, and want to go back to default. Here is how to do it:

1. Move the current nginx.conf to somewhere else or change its name:

$ sudo mv /etc/nginx/nginx.conf /etc/nginx/nginx.bk

2. Restore the default nginx.conf using the "force-confmiss" option of dpkg:

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