How to uninstall nginx with apt

28 March 2008   11 comments   Linux

Mind That Age!

This blog post is 9 years old! Most likely, it's content is outdated. Especially if it's technical.

Powered by Fusion×

My colleague Jan showed me how to do this so I'm going to blog about it to not forget and perhaps by being here other people might be able to search and find the solution too. I installed nginx because I wanted to play with it as an alternative to apache on my laptop. Now I've played enough and I'm going to want to remove it. My first attempt didn't work:

peterbe@trillian:~ $ sudo apt-get --purge remove nginx
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
0 upgraded, 0 newly installed, 1 to remove and 116 not upgraded.
1 not fully installed or removed.
Need to get 0B of archives.
After unpacking 528kB disk space will be freed.
Do you want to continue [Y/n]?
(Reading database ... 242827 files and directories currently installed.)
Removing nginx ...
Stopping nginx: invoke-rc.d: initscript nginx, action "stop" failed.
dpkg: error processing nginx (--purge):
 subprocess pre-removal script returned error exit status 1
Starting nginx: invoke-rc.d: initscript nginx, action "start" failed.
dpkg: error while cleaning up:
 subprocess post-installation script returned error exit status 1
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

I tried this both before and after having stopped and started nginx. Nothing worked. The trick is to fiddle with the init script /etc/init.d/nginx and insert a exit 0 at the top so that it now starts like this:

exit 0

Once saved and you try apt-get --purge remove nginx it will work. It might warn you that /var/log/nginx aren't removed because they're not empty but you can safely remove them manually unless you want to keep them.


What was your general impression of nginx and what made you decide to remove it? I've been meaning to give it a try as well, would be interested in hearing your experiences.
Peter Bengtsson
I didn't give it a fair test. I just wanted to see if I could get Zope to run behind it. With the kind of work I do, the bottleneck won't be in the fronting server so I wouldn't be able to say if nginx is better than apache.
Peter Bengtsson
Watch this video:
fast forward to about 8 minutes in when he talks about the difference between Apache and Nginx. You'll be impressed by the difference. (hint: Nginx rocks!)
Yes, indeed it rocks
Excellent, vraiment
I have removed Apache
Bar Chiu
Thanks for the tip!
can any 1 tell me how i can remove nginx from my laptop
I seemed to have uninstalled NGINX but since i installed it i have no internet connection. I think that's because i only have one nic and the webserver was monopolizing port 80. however, not it's uninstalled and i still have no internet.
Thankyou, I was having problems getting the configuration files (/etc/nginx/) back after accidentily deleting them.
I used
apt-get --purge remove ^nginx
apt-get install nginx
and reinstalled and they returned.
how to I get this off my computer - it pops up on my search screen
For us lay peeps, can you please give me the step by step instructions. I just use the computer, I don't know the hardware and software programmings. Thank you!
Ismail Rachdaoui
Hi, there is an other tricks to remove nginx, nginx is a metapackage, so to remove it you should first remove all of its dependencies, to proceed just run "sudo apt-cache show nginx" this will display all nginx's related packages, in my case it was nginx-full nginx-ligh, then run apt-get remove to remove theme ''sudo apt-get remove nginx-full nginx-ligh' ...
Thank you for posting a comment

Your email will never ever be published

Related posts

Tip: Printer friendly pages with Page Templates in Zope 24 March 2008
One thing I hate about Linux: cron 31 March 2008
How to deploy a create-react-app 04 November 2016
How I stopped worrying about IO blocking Tornado 18 September 2012
Is Nginx obsolete now that we have Amazon CloudFront? 28 July 2012
How much faster is Nginx+gunicorn than Apache+mod_wsgi? 22 March 2012
How I profile my Nginx + proxy pass server 16 February 2011
DoneCal homepage now able to do 10,000 requests/second 13 February 2011
ssl_session_cache in Nginx and the ab benchmark 31 December 2010
DoneCal gets a grade A (92) 27 November 2010
Local Django development with Nginx 11 October 2010
Upgrading to Ubuntu Lucid Lynx and downgrading to Python2.4 and Python2.5 11 May 2010