#sbin 目录位于nginx 安装的跟目录 启动命令:./sbin/nginx
启动成功后访问:http://192.168.8.222/ java
使用方法实例nginx
nginx -c /path/to/nginx.conf // 以特定目录下的配置文件启动nginx: nginx -t // 测试当前配置文件是否正确 nginx -t -c /path/to/nginx.conf //测试特定的nginx配置文件是否正确
有两种方式:tcp
在启动命令后面加上参数测试
nginx -s reload // 修改配置后从新加载生效 nginx -s reopen // 从新打开日志文件 nginx -s stop // 快速中止nginx nginx -s quit // 完整有序的中止nginx
发送一个信号量给 NGINX 的主进程,NGINX默认会将主进程id写入/usr/local/NGINX/logs/nginx.pid,能够经过查看这个文件,获得主进程PIDui
使用实例及介绍:日志
# 发送这个信号后,不会马上中止老的进程,但程序会从新的加载配置文件,再接收的请求将会以新的配置为准 kill -HUP $( cat /usr/local/nginx/logs/nginx.pid ) # 发送这个信号命令,会优雅的中止全部的进程,即等正在运行的进程执行完成后,中止nginx kill -QUIT $( cat /usr/local/nginx/logs/nginx.pid ) # 发送这个信号后,会强制的中止全部进程,中止nignx 服务 kill -TERM $( cat /usr/local/nginx/logs/nginx.pid ) # 发送这个信号后,会从新打开日志文件,能够用来作日志切割 kill -TERM $( cat /usr/local/nginx/logs/nginx.pid )
[root@localhost nginx]# ./sbin/nginx nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] still could not bind()
解决方法:code
#查看被占用的端口是谁在占用 $ netstat -antp [root@localhost nginx]# netstat -antp Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 17758/nginx: master # 关掉这个进程 实用kill或者 pkill 或者 killall(关闭进程) [root@localhost nginx]# pkill -9 17758
重启一下,就OK了server
官方文档blog