2 Star 4 Fork 3

zhangquan / learn-nginx

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

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

The MIT License (MIT) Copyright (c) 2016 前端小武 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

学习nginx配置 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/zhangquan/learn-nginx.git
git@gitee.com:zhangquan/learn-nginx.git
zhangquan
learn-nginx
learn-nginx
master

搜索帮助