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了,就是這麼簡單,這個日誌真的是太有用了,很適合調試服務懵逼時使用日誌