Nginx常用命令之启动与重启


1、测试新的Nginx程序是否正确

[test@P-SH-Nginx-01 nginx]$ ./sbin/nginx -t

nginx: the configuration file /usr/local/openresty/nginx/conf/nginx.conf syntax is ok

nginx: [emerg] open() "/usr/local/openresty/nginx/logs/access.log" failed (13: Permission denied)

nginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test failed

2、启动Nginx

test@P-SH-Nginx-01 openresty]$ sudo ./nginx/sbin/nginx -c conf/nginx.conf

/usr/local/nginx/sbin/nginx -t

nginx: theconfiguration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx:configuration file /usr/local/nginx/conf/nginx.conf test issuccessful

3、查看Nginx是否已经启动起来

[test@P-SH-Nginx-01 openresty]$ ps -ef |grep nginx

root      46505      1  0 01:41 ?        00:00:00 nginx: master process ./nginx/sbin/nginx -c conf/nginx.conf

nobody    46506  46505  0 01:41 ?        00:00:00 nginx: worker process

test      46528  28392  0 01:42 pts/0    00:00:00 grep --color=auto nginx

4、查看Ngixn版本及其编译参数,注意参数是大写字母V

[test@P-SH-Nginx-01 openresty]$  ./nginx/sbin/nginx -V

nginx version: openresty/1.11.2.5

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/local/openresty/nginx --with-cc-opt=-O2 --add-module=../ngx_devel_kit-0.3.0 --add-module=../echo-nginx-module-0.61 --add-module=../xss-nginx-module-0.05 --add-module=../ngx_coolkit-0.2rc3 --add-module=../set-misc-nginx-module-0.31 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.06 --add-module=../srcache-nginx-module-0.31 --add-module=../ngx_lua-0.10.10 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.32 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.18 --add-module=../redis2-nginx-module-0.14 --add-module=../redis-nginx-module-0.3.7 --add-module=../rds-json-nginx-module-0.14 --add-module=../rds-csv-nginx-module-0.07 --with-ld-opt=-Wl,-rpath,/usr/local/openresty/luajit/lib --with-http_stub_status_module --with-http_ssl_module

5、验证Nginx是否正常运行

[test@P-SH-Nginx-01 openresty]$ curl -I http://127.0.0.1

HTTP/1.1 200 OK

Server: openresty/1.11.2.5

Date: Fri, 15 Dec 2017 01:58:18 GMT

Content-Type: text/html

Content-Length: 562

Last-Modified: Thu, 26 Oct 2017 04:12:11 GMT

Connection: keep-alive

ETag: "59f1609b-232"

Accept-Ranges: bytes

6、重启Nginx

[test@P-SH-Nginx-01 openresty]$ sudo ./nginx/sbin/nginx -s reload


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM