PHP error log configuration problem under Mac

coldplay.xixi
Release: 2023-03-03 06:24:01
Original
2554 people have browsed it

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].

PHP error log configuration problem under Mac

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

PHP error log configuration problem under Mac

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
Copy after login

Note: error_reporting error level

PHP error log configuration problem under Mac

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";
?>
Copy after login

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
Copy after login

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

PHP error log configuration problem under Mac

②Command line.

sudo -i → chmod -R 777 /Users/yun/phpLog
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template