Homebrew does not completely uninstall nginx

46,582

Solution 1

As usual, use

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

Solution 2

from terminal,

  1. uninstall nginx using: brew remove nginx

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

Solution 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  

Solution 4

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
Share:
46,582

Related videos on Youtube

mottalrd
Author by

mottalrd

Updated on September 18, 2022

Comments

  • mottalrd
    mottalrd over 1 year

    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

    • slhck
      slhck over 10 years
      I'm fairly certain you can just delete the directory /usr/local/etc/nginx and /usr/local/var/www.
    • mottalrd
      mottalrd over 10 years
      thanks, my only concern is that /usr/local/etc/nginx seems to be under git version control :/
    • pixel 67
      pixel 67 over 9 years
      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
      pixel 67 over 8 years
      If nginx is installed with homebrew, than you also have to remove it from /usr/local/var/run/nginx/ and nothing bad will happen
  • Edward
    Edward over 6 years
    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 ...
  • stackdave
    stackdave over 6 years
    you can downvote if you don't like
  • Giacomo1968
    Giacomo1968 about 6 years
    Are 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.