Skip to content

hongshunyang/learn-nginx

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 

Repository files navigation

learn-nginx

学习安装、配置nginx, 如果你有什么想学习的case或者想完成某些配置, 可在 issues 创建~

在学习之前你可能需要掌握的

  • linux服务器和一些常用的操作命令
  • 域名,当然如果是本地玩玩也可以是Hosts
  • 基本的正则表达式

list

修改配置文件后需要重启、刷新nginx服务, 如: [sudo] nginx -s reload

常见错误和解决方法

nginx: [emerg] getpwnam("nginx") failed

表示该用户nginx不存在, 解决方法:

  1. nginx.conf里添加user nobody;
  2. 创建用户和用户对应的分组

nginx: [emerg] getgrnam("xiaowu") failed

表示用户分组不存在, 解决方法:

  1. nginx.conf里添加user nobody;
  2. 创建用户对应的分组

nginx: [alert] could not open error log file: open() "/logs/error.log" failed (13: Permission denied)

启动nginx的用户权限不够导致无法写入日志文件, 常见于非root用户启动报错

nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)

80端口被占用启动失败, 修改端口或者杀死占用者再启动即可

nginx: [error] open() "nginx.pid" failed (2: No such file or directory)

pid进程id文件不存在, 可能文件被删除或者已经停止, 在停止nginx时会使用该进程id, 如果不存在将失败, 可以手动kill掉

nginx: [emerg] unknown "realpath_roots_xxx" variable

变量$realpath_roots_xxx不存在

nginx: [emerg] "add_header" directive is not allowed here in xx

add_header指令不能直接在if判断内, 可以在httpserverserver.locationserver.location.if

About

学习nginx配置

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published