Solution to php error log configuration under Mac: 1. Select the phpLog folder, right-click to display the introduction, and modify the permissions of staff and everyone; 2. Use the command line, the code is [sudo -i → chmod - R 777 /Users/yun/phpLog].
Solution to php error log configuration under Mac:
1. Browser display error
Method 1: Configure in php. Modify php.ini, sudo vim /etc/php.ini
. Find display_errors = Off
, change Off to On
Restart the apache server sudo apachectl restart
Note: php.ini Default error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
, you can customize the error level
Method 2: Configure in Apache. Modify httpd.conf, sudo vim /etc/apache2/httpd.conf
. Add
//This corresponds to php.ini at the end of the file
php_flag display_errors on php_value error_reporting 30719
Note: error_reporting error level
2, Error log generation
Code:
<?php function myError($errno,$errmsg){ $msg = "错误号:".$errno."错误信息:".$errmsg; echo $msg; error_log($msg."\r",3,"/Users/yun/phpLog/xx.txt"); } set_error_handler("myError"); // 无xiao.txt,为了演示错误日志生成 $handle = fopen("xiao.txt", "r"); echo "ok"; ?>
Result:
错误号:2错误信息:fopen(xiao.txt): failed to open stream: No such file or directory Warning: error_log(/Users/yun/phpLog/xx.txt): failed to open stream: Permission denied in /Users/yun/Sites/error.php on line 11 ok
warning Description The folder has permission settings.
Solution:
①Select the phpLog folder, right-click to display the introduction, and modify the permissions of staff and everyone
②Command line.
sudo -i → chmod -R 777 /Users/yun/phpLog
Related learning recommendations: PHP programming from entry to proficiency
The above is the detailed content of PHP error log configuration problem under Mac. For more information, please follow other related articles on the PHP Chinese website!