找到nginx版本吗?

找到nginx版本吗?,nginx,version,command-line-interface,Nginx,Version,Command Line Interface,我已经通过以下步骤在Debian 7上安装了nginx sudo apt-get update sudo apt-get upgrade sudo apt-get install nginx sudo service nginx start 我已经确认,这将通过从浏览器访问hostip来启动nginx。如何找到nginx的版本 nginx-v失败,出现“命令未找到”错误 我验证了nginx存在于usr/sbin目录中,并且该目录被添加到$PATH变量中。似乎您的nginx没有正确安装。注意安装

我已经通过以下步骤在Debian 7上安装了nginx

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install nginx
sudo service nginx start
我已经确认,这将通过从浏览器访问hostip来启动nginx。如何找到nginx的版本

nginx-v
失败,出现“
命令未找到”
错误


我验证了nginx存在于usr/sbin目录中,并且该目录被添加到$PATH变量中。似乎您的nginx没有正确安装。注意安装命令的输出:

sudo apt-get install nginx
要检查nginx版本,可以使用以下命令:

$ 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
有关更多信息:


您可以使用
-v
参数仅显示Nginx版本,或者使用
-v
参数显示版本以及编译器版本和配置参数。

在我的例子中,我尝试添加sudo

sudo nginx -v

我猜这不在你的道路上。
在bash中,尝试:
echo$PATH


sudo哪个nginx

并查看包含nginx的文件夹是否也在$PATH变量中。
如果没有,请将文件夹添加到path环境变量中,或者创建别名(并将其放在.bashrc中),或者我想您可以创建一个链接。

或者
sudonginx-v
如果你只是想

尝试运行命令“nginx在哪里””。它将为您提供nginx安装的正确路径,在我的例子中,nginx安装在“/usr/local/sbin”中,因此我需要检查命令“echo$path”的输出中是否存在此路径。如果在该命令的输出中找不到路径,则可以添加该路径

假设我的“echo$PATH”命令的输出如下:

  ~$ echo $PATH
/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/nginx/sbin
然后,我可以通过以下命令将路径“/usr/local/sbin”附加到$path中:

~$ echo 'export PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/nginx/sbin"' >> $HOME/.bashrc

请检查您的nginx安装路径可能与我的不同,但添加它们的步骤相同。

如果您不知道它在哪里,请先找到nginx

ps -ef | grep nginx
然后你会看到这样的东西:

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
现在你已经知道nginx在哪里了。您可以使用-v或-v。类似于:

/opt/nginx/sbin/nginx -v

确保您有权运行以下命令

如果您从终端查看nginx的手册页

mannginx

您可以找到:

-V             Print the nginx version, compiler version, and configure script parameters.

-v             Print the nginx version.
然后输入终端

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
如果您的系统中未安装nginx,请确保已安装nginx

您还可以使用以下命令查找版本:

$ 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
使用以下命令之一查找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
然后从终端运行:

/usr/sbin/nginx -v

nginx version: nginx/1.14.0

我只是在我的一个系统上尝试了你上面描述的(作为一个普通的系统用户和root用户):我得到:
nginx-v
=>
nginx版本:nginx/1.8.0
-我想,你的路径变量可能配置错误?所以
/usr/sbin/nginx-v
也不起作用了吗?试过了/usr/sbin/nginx-v,相同的响应执行nginx的位置查找nginx的位置,然后使用路径“sudo apt get install nginx”安装nginx。“sudo service nginx start”需要什么?如果要让图像保持可读性,那么将图像中的文本涂黑是没有意义的。