Home  >  Article  >  Backend Development  >  Nginx common commands

Nginx common commands

WBOY
WBOYOriginal
2016-08-08 09:23:55858browse
1. Start Nginx /usr/local/nginx/sbin/nginx
poechant@ubuntu:sudo ./sbin/nginx
2. Stop Nginx
poechant@ubuntu:sudo ./sbin/nginx -s stop
poechant@ubuntu: sudo ./sbin/nginx -s quit
-s all use the method of sending signals to Nginx.
3. Nginx reload configuration
poechant@ubuntu:sudo ./sbin/nginx -s reload
The above is the method of sending a signal to Nginx, or use:
poechant@ubuntu:service nginx reload
4. Specify the configuration file
poechant@ubuntu:sudo ./sbin/nginx -c /usr/local/nginx/conf/nginx.conf
-c means configuration, specify the configuration file.
5. View Nginx version
There are two parameters to view Nginx version information. The first one is as follows:
poechant@ubuntu:/usr/local/nginx$ ./sbin/nginx -v
nginx: nginx version: nginx/1.0.0
The other one displays detailed version information:
poechant@ ubuntu:/usr/local/nginx$ ./sbin/nginx -V
nginx: nginx version: nginx/1.0.0
nginx: built by gcc 4.3.3 (Ubuntu 4.3.3-5ubuntu4)
nginx: TLS SNI support enabled
nginx: configure arguments: --with-http_ssl_module --with-openssl=/home/luming/openssl-1.0.0d/
6. Check whether the configuration file is correct
poechant@ubuntu:/usr/local/nginx$. /sbin/nginx -t
nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (13: Permission denied)
nginx: the configuration file / usr/local/nginx/conf/nginx.conf syntax is ok
2012/01/09 16:45:09 [emerg] 23898#0: open() "/usr/local/nginx/logs/nginx.pid" failed (13: Permission denied)
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
If the above prompt message appears, it means there is no access errorlogfiles and processes, you can sudo (super user do):
poerchant@ubuntu:/usr/local/nginx$ sudo ./sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: the configuration file /usr/local/nginx/conf/nginx.conf test is successful
If it is displayed as above, it means The configuration file is correct. Otherwise, there will be relevant prompts.
7. Display help information
poechant@ubuntu:/user/local/nginx$ ./sbin/nginx -h
or:
poechant@ubuntu:/user/local/nginx$ ./sbin/nginx -?


[root@centos-1-22 sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf /nginx.conf test is successful
[root@centos-1-22 sbin]# ./nginx -h
nginx version: nginx/1.0.15
Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]
Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit -t : test configuration and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /usr/local/nginx/ )
-c filename : set configuration file (default: conf/nginx.conf)
-g directives : set global directives out of configuration file

The above covers all basic operations of Nginx daily maintenance, in addition to the master process We will see the related commands for sending signals later.
The above introduces the common commands of Nginx, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn