啟動
啟動代碼格式:nginx安裝目錄地址 -c nginx配置文件地址
例如:
[root@LinuxServer sbin]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
停止
nginx的停止有三種方式:
從容停止
1、查看進程號
[root@LinuxServer ~]# ps -ef|grep nginx
2、殺死進程
[root@LinuxServer ~]# kill -QUIT 2072
快速停止
1、查看進程號
[root@LinuxServer ~]# ps -ef|grep nginx
2、殺死進程
[root@LinuxServer ~]# kill -TERM 2132
或 [root@LinuxServer ~]# kill -INT 2132
強制停止
[root@LinuxServer ~]# pkill -9 nginx
重啟
1、驗證nginx配置文件是否正確
方法一:進入nginx安裝目錄sbin下,輸入命令./nginx -t
看到如下顯示nginx.conf syntax is ok
nginx.conf test is successful
說明配置文件正確!
方法二:在啟動命令-c前加-t
2、重啟Nginx服務
方法一:進入nginx可執行目錄sbin下,輸入命令./nginx -s reload 即可
方法二:查找當前nginx進程號,然后輸入命令:kill -HUP 進程號 實現重啟nginx服務
————————————————
pgrep /pkill
EXAMPLES
Example 1: Find the process ID of the named daemon:
$ pgrep -u root named
Example 2: Make syslog reread its configuration file:
$ pkill -HUP syslogd
Example 3: Give detailed information on all xterm processes:
$ ps -fp $(pgrep -d, -x xterm)
Example 4: Make all netscape processes run nicer:
$ renice +4 $(pgrep netscape)
驗證配置是否正確: nginx -t
查看Nginx的版本號:nginx -V
啟動Nginx:start nginx
快速停止或關閉Nginx:nginx -s stop
正常停止或關閉Nginx:nginx -s quit
配置文件修改重裝載命令:nginx -s reload
1、錯誤情況:
nginx: [error] CreateFile() "E:\nginx\nginx-1.9.3/logs/nginx.pid" failed
nginx: [error] Open() "E:\nginx\nginx-1.9.3/logs/nginx.pid" failed
使用命令創建/logs/nginx.pid文件: nginx -c conf/nginx.conf
相關文檔說明:
http://www.cnblogs.com/wangkongming/p/4004416.html
http://www.cnblogs.com/xiaogangqq123/archive/2011/03/02/1969006.html
2、配置多個80端口 server:
相關文檔說明:
http://os.51cto.com/art/201404/437182.htm
3、不同端口為本地nginx服務器配置多個站點:
相關文檔說明:
http://blog.csdn.net/yongzhang52545/article/details/51282914
http://www.2cto.com/os/201411/355976.html