linux系统报错日志学习

linux自己会自动记录系统报错日志:/var/log/messagesphp

这个日志记录,我是在何时发现其强大的做用的呢?它有点像咱们使用php脚本开发接口的时候技术员在重要地方打日志的效果,方便技术人员排错,linux自己也有记录启动相关服务的报错日志。html

先贴出我nginx的配置看下linux

复制代码
server {
    listen   80;
    server_name  lisiqiong.ttyun.com;
    root /data/wwwroot/lisiqiong/demo;

    location / {
        index index.php index.html index.htm;
    }
    
    location ~ .php${
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /usr/local/nginx/conf/fastcgi_params;
    }
   
    #access_log /data/wwwlogs/lisiqiong/access.log;
    #error_log  /data/wwwlogs/lisiqiong/error.log;

}
复制代码

 

通常技术员看到这个都会懵掉,由于怎么看都好像没有问题,看官方手册也没有找到问题所在,可是重启nginx服务的时候却报错nginx

[root@Dev_wechat vhost]# service nginx restart
Restarting nginx (via systemctl):  Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
                                                           [FAILED]

若是有心人去百度,google检索这个错误你会发现不少错误可能都会报这个错哟!那怎么弄呢?懵逼了ui

最后我仔细的检索发现了牛逼的/var/log/messages这个日志
下面贴错我经过这个查找问题的所在问题google

复制代码
cat /var/log/messages|grep nginx

Feb 16 14:26:35 Dev_wechat nginx: Starting nginx: nginx: [emerg] directive "location" has no opening "{" in /usr/local/nginx/conf/vhost/lisiqiong.ttyun.com.conf:11
Feb 16 14:26:35 Dev_wechat nginx: [FAILED]
Feb 16 14:26:35 Dev_wechat systemd: nginx.service: control process exited, code=exited status=1
Feb 16 14:26:35 Dev_wechat systemd: Unit nginx.service entered failed state.
Feb 16 14:26:35 Dev_wechat systemd: nginx.service failed.
Feb 16 14:26:35 Dev_wechat root: [euid=root]:root pts/0 2017-02-16 09:28 (172.168.6.252):[/usr/local/nginx/conf/vhost]2017-02-16 14:26:34 root service nginx restart
复制代码

仔细查看日志发现错误报在/usr/local/nginx/conf/vhost/lisiqiong.ttyun.com.conf这个配置文件的11行代码spa

我靠在看前面的nginx配置发现11就是这行代码调试

location ~ .php${

你会发现nginx配置中{前面是须要空格的,我晕,最后重启rest

service nginx restart

一切ok了,就是这么简单,这个日志真的是太有用了,很适合调试服务懵逼时使用日志

相关文章
相关标签/搜索