找到nginx版本?

use*_*mda 60 version nginx command-line-interface

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

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install nginx
sudo service nginx start
Run Code Online (Sandbox Code Playgroud)

我已经确认通过从浏览器访问hostip来启动nginx.我如何找到nginx的版本?

nginx -vcommand not found错误而失败

我验证了nginx存在于usr/sbin目录中,并且该目录被添加到$ PATH变量中

has*_*abi 63

您的nginx似乎未正确安装.注意安装命令的输出:

sudo apt-get install nginx
Run Code Online (Sandbox Code Playgroud)

要检查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
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请访问:http: //nginxlibrary.com/check-nginx-version/

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


Fra*_*yen 24

就我而言,我尝试添加sudo

sudo nginx -v
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

  • 如果您想让图像保持可读性,则没有必要涂黑图像。 (2认同)

小智 14

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

ps -ef | grep nginx
Run Code Online (Sandbox Code Playgroud)

然后你会看到这样的事情:

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
Run Code Online (Sandbox Code Playgroud)

所以现在你已经知道nginx在哪里了.您可以使用-v或-V.就像是:

/opt/nginx/sbin/nginx -v
Run Code Online (Sandbox Code Playgroud)


小智 5

我的猜测是它不在你的路径中。
在 bash 中,尝试:
echo $PATH

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


bho*_*pur 5

确保您有权运行以下命令。

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

man nginx

你可以找到这个:

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

-v             Print the nginx version.
Run Code Online (Sandbox Code Playgroud)

然后在终端输入

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
Run Code Online (Sandbox Code Playgroud)

如果你的系统man nginx命令中没有安装 nginx 找不到手册页,那么请确保你已经安装了 nginx。

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

使用其中一个命令查找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
Run Code Online (Sandbox Code Playgroud)

然后从终端运行:

/usr/sbin/nginx -v

nginx version: nginx/1.14.0
Run Code Online (Sandbox Code Playgroud)