centos7 - nginx配置access_log問題
問題描述
我想給nginx開啟訪問日志。百度了一下,主要是在nginx.conf中配置
這一段
# log_format main ’$remote_addr - $remote_user [$time_local] '$request' ’# ’$status $body_bytes_sent '$http_referer' ’# ’'$http_user_agent' '$http_x_forwarded_for'’;## access_log logs/access.log main;
默認都是加#注釋掉的,我想開啟,也就是這段都取消#注釋了。然后重啟nginx卻重啟不了,提示Job for nginx.service failed because the control process exited with error code. See 'systemctl status nginx.service' and 'journalctl -xe' for details.
把#加回去又沒事了,什么原因啊,包括開頭的錯誤日志
#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;
也是把#去掉想生效,結果nginx就啟動不了。`
問題解答
回答1:1.請使用 nginx -t 檢查配置文件獲取 查看具體得錯誤信息
日志這樣處理
log_format main ’$remote_addr - $remote_user [$time_local] '$request' ’ ’$status $body_bytes_sent '$http_referer' ’ ’'$http_user_agent' '$http_x_forwarded_for'’; access_log logs/access.log main;
相關文章:
1. 如何解決docker宿主機無法訪問容器中的服務?2. 前端 - CSS3 box-shadow如何設置,或者用什么方法可以產生圖中這樣陰影的效果。3. node.js - vue-cll+sass 樣式不出來 已經npm install sass、 sass-loader了4. html - css 如何讓文字標題顯示在邊框上?5. docker 下面創建的IMAGE 他們的 ID 一樣?這個是怎么回事????6. 在應用配置文件 app.php 中找不到’route_check_cache’配置項7. html按鍵開關如何提交我想需要的值到數據庫8. html - 微信端video標簽播放mp4視頻,安卓端提示視頻解析錯誤9. HTML5中怎么判斷用戶是否正在瀏覽頁面?10. html5 - 微信開發的時候老是報這樣的錯誤errmsg config invalid signature
