I successfully installed nginx ~ but when I use nginx -v command, it show : nginx: command not found
what the problem?
32 Answers
run echo $PATH Does it contain /usr/local/sbin?
If not try PATH=/usr/sbin/:$PATH
Also, check that nginx is installed in /usr/local/sbin, by going into this directory.
1First, find out where nginx is installed by showing all running processes for nginx:
pgrep nginx | xargs ps -f -pLook for the nginx master process in the list, it should show the location where the nginx process is e.g /usr/sbin/nginx
(for more info about what the
pgrep ...is doing, see )
Now, check if the containing folder (for example /usr/sbin/) is in your path:
echo $PATHIf it's not there, you need to add it. To add it to the path and persist the change between your linux terminal sessions, edit the profile for the user that you want to be able to persistently access the nginx command. First, ensure you're logged in as the user, then edit the .profile file that's in the user's home directory. If you have nano, then you can do this with:
sudo nano ~/.profileAdd the following at the end of the .profile file (use the correct folder - I'm using `/usr/sbin/ as an example):
export PATH=/usr/sbin/:$PATHThis prepends /usr/sbin/ to the user's path whilst retaining the existing path ($PATH is a variable that points to everything else that's already in the path)
Now you need to source (effectively 'refresh') your profile file so that the change takes effect:
. ~/.profileNow try nginx -v
Here's a good resource about editing your path. I got a lot of my answer from here.