Посмотреть версию nginx linux

Find nginx version?

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

I just tried what you described above (as a regular system user and as root) on one of my systems: I got: nginx -v => nginx version: nginx/1.8.0 — I guess, something with your PATH variable could be wrong aka misconfigured?

7 Answers 7

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 

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.

Источник

Как узнать версию nginx ?

Пример консольного вывода обоих команд чтобы узнать версию nginx:

$ nginx -v nginx version: nginx/1.6.1 $ nginx -V nginx version: nginx/1.6.1 built by gcc 4.7.2 (Debian 4.7.2-5) TLS SNI support enabled configure arguments: --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt=-Wl,-z,relro --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-file-aio --with-http_spdy_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_secure_link_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module --add-module=/usr/src/nginx/source/nginx-1.6.1/debian/modules/nginx-auth-pam --add-module=/usr/src/nginx/source/nginx-1.6.1/debian/modules/nginx-dav-ext-module --add-module=/usr/src/nginx/source/nginx-1.6.1/debian/modules/nginx-echo --add-module=/usr/src/nginx/source/nginx-1.6.1/debian/modules/nginx-upstream-fair --add-module=/usr/src/nginx/source/nginx-1.6.1/debian/modules/nginx-syslog --add-module=/usr/src/nginx/source/nginx-1.6.1/debian/modules/nginx-cache-purge --add-module=/usr/src/nginx/source/nginx-1.6.1/debian/modules/ngx_http_pinba_module --add-module=/usr/src/nginx/source/nginx-1.6.1/debian/modules/ngx_http_substitutions_filter_module --add-module=/usr/src/nginx/source/nginx-1.6.1/debian/modules/nginx-x-rid-header --with-ld-opt=-lossp-uuid

один из докладов разработчика nginx Игоря Сысоева на конференции DevPoint.ru в ноябре 2010.

Источник

10 наиболее часто используемых команд Nginx, которые должен знать каждый пользователь Linux

Nginx (произносится как Engine x) — это бесплатный высокопроизводительный, масштабируемый, надежный, полнофункциональный и популярный HTTP- и обратный прокси-сервер с открытым исходным кодом, почтовый прокси-сервер и универсальный TCP/ UDP-прокси-сервер.

Читайте также:  Nfs port no in linux

Nginx хорошо известен своей простой конфигурацией и низким потреблением ресурсов из-за высокой производительности. Он используется для поддержки нескольких сайтов с высокой посещаемостью в Интернете, таких как GitHub . , SoundCloud, Dropbox, Netflix, WordPress и многие другие.

В этом руководстве мы объясним некоторые из наиболее часто используемых команд управления службами Nginx, которые вы, как разработчик или системный администратор, должны держать под рукой. Мы покажем команды как для Systemd, так и для SysVinit.

Все перечисленные ниже популярные команды Nginx должны выполняться от имени пользователя root или sudo и должны работать в любом современном дистрибутиве Linux, таком как CentOS. , RHEL, Debian, Ubuntu и Fedora.

Установить сервер Nginx

Чтобы установить веб-сервер Nginx, используйте менеджер пакетов дистрибутива по умолчанию, как показано ниже.

$ sudo yum install epel-release && yum install nginx [On CentOS/RHEL] $ sudo dnf install nginx [On Fedora] $ sudo apt install nginx [On Debian/Ubuntu]

Проверить версию Nginx

Чтобы проверить версию веб-сервера Nginx, установленного в вашей системе Linux, выполните следующую команду.

$ nginx -v nginx version: nginx/1.12.2 

Приведенная выше команда просто отображает номер версии. Если вы хотите просмотреть версию и настроить параметры, используйте флаг -V , как показано ниже.

nginx version: nginx/1.12.2 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_auth_request_module --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'

Проверьте синтаксис конфигурации Nginx

Прежде чем запустить службу Nginx, вы можете проверить правильность синтаксиса ее конфигурации. Это особенно полезно, если вы внесли изменения или добавили новую конфигурацию в существующую структуру конфигурации.

Чтобы проверить конфигурацию Nginx, выполните следующую команду.

$ sudo nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful 

Вы можете протестировать конфигурацию Nginx, сделать дамп и выйти, используя флаг -T , как показано ниже.

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful # configuration file /etc/nginx/nginx.conf: # For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events < worker_connections 1024; >http < log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; server < listen 80 default_server; listen [::]:80 default_server; server_name _; root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / < >error_page 404 /404.html; location = /40x.html < >error_page 500 502 503 504 /50x.html; location = /50x.html < >> .

Запустить службу Nginx

Чтобы запустить службу Nginx, выполните следующую команду. Обратите внимание, что этот процесс может завершиться ошибкой, если синтаксис конфигурации не соответствует OK.

$ sudo systemctl start nginx #systemd OR $ sudo service nginx start #sysvinit

Включить службу Nginx

Предыдущая команда запускает службу только на время, чтобы включить ее автоматический запуск во время загрузки, выполните следующую команду.

$ sudo systemctl enable nginx #systemd OR $ sudo service nginx enable #sysv init

Перезапустите службу Nginx

Чтобы перезапустить службу Nginx, действие, которое остановит, а затем запустит службу.

$ sudo systemctl restart nginx #systemd OR $ sudo service nginx restart #sysv init

Просмотр статуса службы Nginx

Вы можете проверить статус службы Nginx следующим образом. Эта команда показывает информацию о состоянии службы во время выполнения.

$ sudo systemctl status nginx #systemd OR $ sudo service nginx status #sysvinit
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service. [ ~]# systemctl status nginx ● nginx.service - The nginx HTTP and reverse proxy server Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2019-03-05 05:27:15 EST; 2min 59s ago Main PID: 31515 (nginx) CGroup: /system.slice/nginx.service ├─31515 nginx: master process /usr/sbin/nginx └─31516 nginx: worker process Mar 05 05:27:15 linux-console.net systemd[1]: Starting The nginx HTTP and reverse proxy server. Mar 05 05:27:15 linux-console.net nginx[31509]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok Mar 05 05:27:15 linux-console.net nginx[31509]: nginx: configuration file /etc/nginx/nginx.conf test is successful Mar 05 05:27:15 linux-console.net systemd[1]: Failed to read PID from file /run/nginx.pid: Invalid argument Mar 05 05:27:15 linux-console.net systemd[1]: Started The nginx HTTP and reverse proxy server.

Перезагрузить службу Nginx

Чтобы указать Nginx перезагрузить конфигурацию, используйте следующую команду.

$ sudo systemctl reload nginx #systemd OR $ sudo service nginx reload #sysvinit

Остановить службу Nginx

Если вы хотите остановить службу Nginx по той или иной причине, используйте следующую команду.

$ sudo systemctl stop nginx #systemd OR $ sudo service nginx stop #sysvinit

Показать справку по командам Nginx

Чтобы получить простое справочное руководство по всем командам и параметрам Nginx, используйте следующую команду.

systemctl [OPTIONS. ] . Query or send control commands to the systemd manager. -h --help Show this help --version Show package version --system Connect to system manager -H --host=[]HOST Operate on remote host -M --machine=CONTAINER Operate on local container -t --type=TYPE List units of a particular type --state=STATE List units with particular LOAD or SUB or ACTIVE state -p --property=NAME Show only properties by this name -a --all Show all loaded units/properties, including dead/empty ones. To list all units installed on the system, use the 'list-unit-files' command instead. -l --full Don't ellipsize unit names on output -r --recursive Show unit list of host and local containers --reverse Show reverse dependencies with 'list-dependencies' --job-mode=MODE Specify how to deal with already queued jobs, when queueing a new job --show-types When showing sockets, explicitly show their type -i --ignore-inhibitors .

Вы также можете прочитать следующие статьи, связанные с Nginx.

  1. Полное руководство по обеспечению безопасности, укреплению и повышению производительности веб-сервера Nginx
  2. Amplify — простой мониторинг NGINX
  3. ngxtop — мониторинг файлов журналов Nginx в режиме реального времени в Linux
  4. Как установить Nginx с виртуальными хостами и сертификатом SSL
  5. Как скрыть версию сервера Nginx в Linux
Читайте также:  Linux and pdf files

Это пока все! В этом руководстве мы объяснили некоторые из наиболее часто используемых команд управления службами Nginx, которые вам следует знать, включая запуск, включение, перезапуск и остановку Nginx. Если у вас есть дополнения или вопросы, которые вы хотели бы задать, воспользуйтесь формой обратной связи ниже.

Источник

Оцените статью
Adblock
detector