mac自帶的php-fpm頁面空白以及錯誤日至輸出
配置好nginx、php-fpm之後,訪問html頁面正常,訪問php後臺顯示空白頁面。
起初懷疑php-fpm問題,關閉php-fpm後在訪問報gateway錯誤,說明php-fpm是正常的。
重新檢查nginx的配置,發現少了一句。fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
server { listen 8081; server_name localhost; root /Users/chenhe/Project/cx/; error_loglogs/error.log; index index.php index.html; location ~ \.php$ { includefastcgi.conf; fastcgi_pass127.0.0.1:9000; fastcgi_indexindex.php; fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name; includefastcgi_params; } error_page 404 /404.html; }
新增後重啟nginx恢復正常。
執行之後發現php-fpm不輸出php錯誤日誌。
1. 修改 php-fpm.conf 檔案,新增(或修改)如下配置:
catch_workers_output = yes
2. 修改 php.ini 檔案,新增(或修改)如下配置:
log_errors = On error_log = /usr/local/etc/php/5.4/php_errors.log error_reporting=E_ALL&~E_NOTICE
3. 重啟 php-fpm
還是不輸出日誌,期間嘗試很多辦法,最後發現可能是許可權問題。把啟動php-fpm的方式修改為普通使用者許可權就解決問題了。
sudo php-fpm -D 改為 php-fpm -D
預設時區提示
PHP Warning: Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in Unknown on line 0
在php.ini 中修改
data.timezone = "Asia/Shanghai";