nginx+php-fpm 的配置下,php的错误日志
發(fā)現(xiàn)php 運行錯誤時,瀏覽器的網(wǎng)頁上并沒有輸出php的錯誤日志。那php的錯誤日志在哪里呢? 發(fā)現(xiàn)在 /var/log/nginx/error.log文件中。
?
怎么樣才能在瀏覽器的網(wǎng)頁中輸出php的出錯信息呢?
編輯 /etc/php5/fpm/php.ini文件,將display_errors = On. (如果不改php.ini文件,只是在執(zhí)行文件中 ini_set("display_errors", "on"))發(fā)現(xiàn)沒效果,不知道為什么呢?奇怪!!
這樣改了php.ini文件后,網(wǎng)頁上就可以看到php的出錯信息了,便于調(diào)試。
-------------------------------------------------------------------------------------------------
?
?
| 8down vote | I gathered insights from a bunch of answers here and I present a comprehensive solution: So, if you setup nginx with php5-fpm and log a message using?error_log()?you can see it in?/var/log/nginx/error.log?by default. A problem can arise if you want to log a lot of data (say an array) using?error_log(print_r($myArr, true));. If an array is large enough, it seems that?nginx?will truncate your log entry. To get around this you can configure?fpm?to manage logs. Here are the steps to do so. Open?/etc/php5/fpm/pool.d/www.conf: $ sudo nano /etc/php5/fpm/pool.d/www.conf Uncomment the following two lines by removing?;?at the beginning of the line: ;php_admin_value[error_log] = /var/log/fpm-php.www.log ;php_admin_flag[log_errors] = on Create?/var/log/fpm-php.www.log: $ sudo touch /var/log/fpm-php.www.log; Change ownership of?/var/log/fpm-php.www.log?so that php5-fpm can edit it: $ sudo chown vagrant /var/log/fpm-php.www.log Note:?vagrant?is the user that I need to give ownership to. You can see what user this should be for you by running?$ ps aux | grep php.*www?and looking at first column. Restart php5-fpm: $ sudo service php5-fpm restart Now your logs will be in?/var/log/fpm-php.www.log. |
轉(zhuǎn)載于:https://www.cnblogs.com/oxspirt/p/6219186.html
《新程序員》:云原生和全面數(shù)字化實踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的nginx+php-fpm 的配置下,php的错误日志的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Windows 10 中 Eclipse
- 下一篇: 借点钱闪现贷上征信吗