Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've just completely uninstalled nginx 1.0.6 from my server (Ubuntu 11.04) using

apt-get remove nginx 
rm -rf /etc/nginx/
rm -rf /usr/sbin/nginx
rm /usr/share/man/man1/nginx.1.gz
apt-get remove nginx*

Now I want to install it again, however when starting nginx, I get errors such as:

Restarting nginx: nginx: [emerg] open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)

Then I placed my own conf file, then I get a new error:

Restarting nginx: nginx: [emerg] open() "/etc/nginx/mime.types" failed (2: No such file or directory) in /etc/nginx/nginx.conf:12

Now it seems that apt-get install nginx doesn't install it completely, I cleared the apt-get cache, doesn't seem to help. How can I get a full installation of nginx using apt-get?

share|improve this question
up vote 7 down vote accepted

Run apt-get remove --purge nginx nginx-full nginx-common first, and then apt-get install nginx and see if it works.

share|improve this answer
I get this: Starting nginx: nginx: [emerg] open() "/etc/nginx/mime.types" failed (2: No such file or directory) in /etc/nginx/nginx.conf:12 nginx: configuration file /etc/nginx/nginx.conf test failed – MacMac Sep 30 '11 at 10:59
Try apt-get install nginx-extras and restart nginx. – George Tasioulis Sep 30 '11 at 11:07
Hmmm, I still get the same error above. – MacMac Sep 30 '11 at 11:08
What is the output of locate mime.types? (run sudo updatedb first). Did the apt-get install nginx-extras do anything? Maybe you should try the commands on my initial answer, for the nginx-extras package too. – George Tasioulis Sep 30 '11 at 11:11
I get this: /etc/mime.types /usr/share/doc/apache2.2-common/examples/apache2/mime.types.gz /usr/share/usermin/mime.types /usr/share/webmin/mime.types – MacMac Sep 30 '11 at 11:19


sudo apt-get -o DPkg::options::=--force-confmiss --reinstall install nginx-common

then test

sudo nginx -t
share|improve this answer
thanks! now work – Orion Mar 24 at 0:03
sudo apt-get --purge autoremove nginx

If you are not prompted to prove successful uninstall

 which nginx
share|improve this answer

I had the same problem, and solved it by copying the configuration files from /opt/ into /etc/:

cp /opt/nginx/conf/nginx.conf /etc/nginx/
cp /opt/nginx/conf/mime.types /etc/nginx/
share|improve this answer

You first of all want to make sure that the older nginx is uninstalled completely together with its conf files.

 sudo service nginx stop
 sudo apt-get --purge autoremove nginx     
 sudo rm -rf /etc/nginx
 sudo rm /usr/sbin/nginx

Then install nginx. The nginx-extras comes in handy when you want to check your conf files for errors

 sudo apt-get install nginx nginx-extras

Then check whether your conf files are okay with the command;

 sudo nginx -t
share|improve this answer
This doesn't answer the question. – Sven Nov 20 '14 at 15:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.