我已经在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
失败, command not found
错误
我validation了nginx存在于usr / sbin目录中,并且该目录被添加到$ PATHvariables中
看来你的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
欲了解更多信息: http : //nginxlibrary.com/check-nginx-version/
您可以使用-v
参数仅显示Nginx版本,或者使用-V
参数显示版本以及编译器版本和配置参数。
在我的情况下,我尝试添加sudo
sudo nginx -v
我的猜测是这不是你的路径。
在bash中,尝试:
echo $PATH
和
sudo which nginx
看看包含nginx的文件夹是否也在你的$ PATH变量中。
如果没有,请将文件夹添加到路径环境变量中,或者创建别名(并将其放在.bashrc中),或者可以创建一个链接。
或者sudo nginx -v
如果你只是想要…
尝试运行命令' whereis 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
然后我可以通过以下命令在$ PATH中追加路径'/ usr / local / sbin':
~$ echo 'export PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/nginx/sbin"' >> $HOME/.bashrc
请检查您的nginx安装路径可能与我的不同,但添加它们的步骤是相同的。