linux 下安装nginx
安装:https://blog.csdn.net/u013068377/article/details/82821639
window 下安装nginx
nginx配置:https://blog.csdn.net/kingscoming/article/details/79042874
日志参数设置说明:https://blog.csdn.net/czlun/article/details/73251723
nginx 启动
注意:不要直接双击nginx.exe,这样会导致修改配置后重启、停止nginx无效,需要手动关闭任务管理器内的所有nginx进程
start nginx : 启动nginx服务
nginx -s reload :修改配置后重新加载生效
nginx -s reopen :重新打开日志文件
nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确 path/to/nginx.conf 是配置文件路径
启动成功检查
输入命令 tasklist /fi "imagename eq nginx.exe"
验证配置是否正确: nginx -t
查看Nginx的版本号:nginx -V
启动Nginx:start nginx
快速停止或关闭Nginx:nginx -s stop
正常停止或关闭Nginx:nginx -s quit
配置文件修改重装载命令:nginx -s reload
错误
1、question 1
Nginx错误:nginx: [error] OpenEvent("Global\ngx_reload_6252") failed (2: The system cannot find the file specified)
执行nginx -s reload命令:
nginx: [error] OpenEvent("Global\ngx_reload_6252") failed (2: The system cannot find the file specified)
错误原因:
Nginx 尚未启动导致,执行 start nginx 命令开启Nginx
2、question 2 :记事本编辑nginx.conf 导致的错误
D:\soft\nginx-1.16.1>nginx -t
nginx: [emerg] unknown directive "锘? in D:\soft\nginx-1.16.1/conf/nginx.conf:5
nginx: configuration file D:\soft\nginx-1.16.1/conf/nginx.conf test failed
原因及解决:
conf文件被记事本编辑过,保存成了含BOM头的文件
使用其他编辑器将文件另存为UTF-8不含Bom头的格式
注:记事本编辑UTF-8都会加BOM头
3、question 3: