mac自带的php-fpm页面空白以及错误日至输出
配置好nginx、php-fpm之后,访问html页面正常,访问php后台显示空白页面。
起初怀疑php-fpm问题,关闭php-fpm后在访问报gateway错误,说明php-fpm是正常的。
重新检查nginx的配置,发现少了一句。fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
server { listen 8081; server_name localhost; root /Users/chenhe/Project/cx/; error_log logs/error.log; index index.php index.html; location ~ \.php$ { include fastcgi.conf; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } error_page 404 /404.html; } |
添加后重启nginx恢复正常。
运行之后发现php-fpm不输出php错误日志。
1. 修改 php-fpm.conf 文件,添加(或修改)如下配置:
catch_workers_output = yes
2. 修改 php.ini 文件,添加(或修改)如下配置:
1 2 3 |
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