nginx -v command not found

I successfully installed nginx ~ but when I use nginx -v command, it show : nginx: command not found

what the problem?

3

2 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.

1

First, find out where nginx is installed by showing all running processes for nginx:

pgrep nginx | xargs ps -f -p

Look 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 $PATH

If 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 ~/.profile

Add 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/:$PATH

This 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:

. ~/.profile

Now try nginx -v

Here's a good resource about editing your path. I got a lot of my answer from here.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like