Find nginx version?

前端 未结 6 1280
生来不讨喜
生来不讨喜 2021-02-01 11:50

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
<         


        
相关标签:
6条回答
  • 2021-02-01 12:21

    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
    
    0 讨论(0)
  • 2021-02-01 12:23

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

    0 讨论(0)
  • 2021-02-01 12:27

    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: http://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.

    0 讨论(0)
  • 2021-02-01 12:32

    In my case, I try to add sudo

    sudo nginx -v
    

    0 讨论(0)
  • 2021-02-01 12:40

    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.

    0 讨论(0)
  • 2021-02-01 12:43

    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
    
    0 讨论(0)
提交回复
热议问题