一、/etc/nginx/nginx.conf文件注解
如何修改conf文件产生一个8888端口的server。
//如何修改conf文件产生一个/chendan/index.html的location
可以在输入命令:gedit。然后在gedit上找到conf的配置文件(etc/nginx/nginx.conf)打开文件后,找到server模块 把其中的 listen数值改为8888。
后再找到 location模块,如下1,仿照1在模块下方添加2.则文件修改成功。可以测试一下,首先在gedit保存该修改文件,再重启nginx(命令:service nginx restart)使配置文件生效,最后在浏览器中输入:127.0.0.1:8888/chendan/index.html
1. location / {
root html;
index index.html index.htm; }
2. location /chendan {
root html;
index index.html index.htm;
}
二、探寻access.log和error.log
通过在浏览器输入一个不存在的网页查看这两个log中的新增行的信息并注解
access.log在/var/log/nginx/access.log
error.log /var/log/nginx/error.log
当我们上面修改配置文件成功后,可以在gedit里再打开access.log和error.log。然后在浏览器上输入127.0.0.1:8888/chendan这一错误网页,再查看access.log和error.log,
会发现access.log里增加了:127.0.0.1 - - [10/Jul/2014:08:06:59 -0400] "GET /chendan HTTP/1.1" 404 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:10.0.5) Gecko/20120606 Firefox/10.0.5"这一行。
GET /chendan:从服务器上获取chendan这个数据
error.log增加了:2014/07/10 08:06:59 [error] 3861#0: *5 open() "/usr/html/chendan" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET /chendan HTTP/1.1", host: "127.0.0.1:8888"。
open() "/usr/html/chendan" failed(2: No such file or directory):在usr目录下的html目录里没有找到“chendan”这个文件