Homebrew does not completely uninstall nginx

5

I installed yesterday nginx on my machine using

brew install nginx

Today I would like to remove the software, therefore I tried

brew uninstall nginx

which has been correctely executed. In fact if I ask again to uninstall nginx I get

Error: No such keg: /usr/local/Cellar/nginx

The problem is that the files under

/usr/local/etc/nginx

has not been removed.

What is the correct way to remove them?
Thank you

mottalrd

Posted 2014-01-26T17:59:09.900

Reputation: 163

Not sure if you found your solution, but I just went through the same issue yesterday. I deleted the directories like @slhck suggested. – pixel 67 – 2014-10-25T12:52:22.183

If nginx is installed with homebrew, than you also have to remove it from
/usr/local/var/run/nginx/ and nothing bad will happen
– pixel 67 – 2015-10-31T02:26:09.370

I'm fairly certain you can just delete the directory /usr/local/etc/nginx and /usr/local/var/www. – slhck – 2014-01-26T18:17:52.863

thanks, my only concern is that /usr/local/etc/nginx seems to be under git version control :/ – mottalrd – 2014-01-27T06:39:29.410

Answers

8

As usual, use

rm -f -R /usr/local/nginx
rm -f /usr/local/sbin/nginx

Sergey Chikirev

Posted 2014-01-26T17:59:09.900

Reputation: 81

5

from terminal,

  1. uninstall nginx using: brew remove nginx

  2. remove nginx config files using: rm -r /usr/local/var/run/nginx

Emmanuel Opio

Posted 2014-01-26T17:59:09.900

Reputation: 51

3

November 2017 – El Capitan

It seems the answers are outdated.  After trying a lot of options, I've finally found the right instructions:

remove from brew:

brew remove nginx

remove config:

The folder was changing; make sure the folder exists.  If it does not exist, it's because brew could change for the future versions (I hope not).  In this case, tell me to update my answer.

rm -f -R /usr/local/etc/nginx  

stackdave

Posted 2014-01-26T17:59:09.900

Reputation: 131

Hi dave, I'm a bit surprised you didn't update or edit the other answer which stated the same solution, save for the location of the config ... – Edward – 2017-11-17T07:57:52.130

you can downvote if you don't like – stackdave – 2017-11-17T19:20:42.933

2

I found an nginx directory in all these places mentioned above. This is a succinct list of all the commands above:

brew remove nginx
rm -f -R /usr/local/nginx
rm -f /usr/local/sbin/nginx
rm -r /usr/local/var/run/nginx
rm -f -R /usr/local/etc/nginx  
rm -r /usr/local/opt/nginx

Dusty H

Posted 2014-01-26T17:59:09.900

Reputation: 21

0

I got the same error but nginx was installed in /usr/local/opt/. To resolve I did:

rm -r /usr/local/opt/nginx

Galuga

Posted 2014-01-26T17:59:09.900

Reputation: 121

1Are you sure it was actually installed in /usr/local/opt/? The reason I ask is that directory is typically just filled with symbolic links to the /usr/local/Cellar/ directory Homebrew dumps stuff into. – JakeGould – 2018-03-25T00:30:23.947