I have installed nginx on Debian 7 with the following steps
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install nginx
sudo service nginx start
I have confirmed that this starts nginx by accessing the hostip from the browser. How do I find out the version of nginx?
nginx -v
fails with the 'command not found
error
I verified that nginx exists in the usr/sbin directory and that directory is added to the $PATH variable
asked Dec 9, 2015 at 19:17
user_mdauser_mda
16.8k23 gold badges75 silver badges132 bronze badges
5
It seems that your nginx hasn't been installed correctly. Pay attention to the output of the installation commands:
sudo apt-get install nginx
To check the nginx version, you can use this command:
$ nginx -v
nginx version: nginx/0.8.54
$ nginx -V
nginx version: nginx/0.8.54
TLS SNI support enabled
configure arguments: --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=/build/buildd/nginx-0.8.54/debian/modules/nginx-upstream-fair
For more information: //nginxlibrary.com/check-nginx-version/
You can use -v
parameter to display the Nginx version only, or use the -V
parameter to display the version, along with the compiler version and configuration parameters.
answered Jun 12, 2016 at 11:21
hassan ketabihassan ketabi
2,6112 gold badges20 silver badges30 bronze badges
In my case, I try to add sudo
sudo nginx -v
answered Jul 16, 2017 at 17:12
Frank NguyenFrank Nguyen
6,3833 gold badges37 silver badges37 bronze badges
1
If you don't know where it is, locate nginx first.
ps -ef | grep nginx
Then you will see something like this:
root 4801 1 0 May23 ? 00:00:00 nginx: master process /opt/nginx/sbin/nginx -c /opt/nginx/conf/nginx.conf
root 12427 11747 0 03:53 pts/1 00:00:00 grep --color=auto nginx
nginx 24012 4801 0 02:30 ? 00:00:00 nginx: worker process
nginx 24013 4801 0 02:30 ? 00:00:00 nginx: worker process
So now you already know where nginx is. You can use the -v or -V. Something like:
/opt/nginx/sbin/nginx -v
answered May 24, 2018 at 4:01
My guess is it's not in your path.
in bash, try:
echo $PATH
and
sudo which nginx
And see if the folder containing nginx is also in your $PATH variable.
If not, either add the folder to your path environment variable, or create an alias [and put it in your .bashrc] ooor your could create a link i guess.
or sudo nginx -v
if you just want that...
answered Aug 14, 2017 at 22:51
xorxor
712 silver badges4 bronze badges
Make sure that you have permissions to run the following commands.
If you check the man page of nginx from a terminal
man nginx
you can find this:
-V Print the nginx version, compiler version, and configure script parameters.
-v Print the nginx version.
Then type in terminal
nginx -v
nginx version: nginx/1.14.0
nginx -V
nginx version: nginx/1.14.0
built with OpenSSL 1.1.0g 2 Nov 2017
TLS SNI support enabled
If nginx is not installed in your system man nginx
command can not find man page, so make sure you have installed nginx.
You can also find the version using this command:
Use one of the command to find the path of nginx
ps aux | grep nginx
ps -ef | grep nginx
root 883 0.0 0.3 44524 3388 ? Ss Dec07 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on
Then run from terminal:
/usr/sbin/nginx -v
nginx version: nginx/1.14.0
answered Dec 8, 2018 at 0:35
bhordupurbhordupur
75210 silver badges13 bronze badges
Try running command whereis nginx
. It will give you the correct path of the nginx installation, in my case nginx is installed in /usr/local/sbin
, so I need to check if this path exists in output of command echo $PATH
.
If you don't find the path in the output of this command, then you can add this.
Suppose the output of my echo $PATH
command is this:
~$ echo $PATH
/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/nginx/sbin
Then I can append the path /usr/local/sbin
in $PATH by following command:
~$ echo 'export PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/nginx/sbin"' >> $HOME/.bashrc
Please check your nginx installation path may differ from mine, but the steps for adding them are same.
Zap
3251 gold badge6 silver badges21 bronze badges
answered Oct 26, 2017 at 5:16
search if iginx is installed or any package in your system
which nginx
OR
sudo which nginx
if previously nginx installed result will be like this /sbin/nginx /bin/nginx
if you use rhel, it will show you all installed modules
yum search nginx
OR check nginx version in rhel
rpm -q nginx
Result look like this
nginx-1.14.1-9.module+el8.0.0+4108+af250afe.x86_64
OR
sudo nginx -v
Result look like
nginx version: nginx/1.14.1
don't use "nginx --version" it will show unexpected errors. I'm a RHEL user.
1