An Access Denied error occurs after the LNMP environment is set up.
After the LNMP environment is set up, an Access Denied error occurs. Now, the File Permission problem has been ruled out and Nginx problem has been ruled out, but PHP cannot be resolved.
I found that many of the online bulls used Nginx logs to troubleshoot errors, but I opened nginx. conf and found that my log information was not detailed enough. So I hope to configure log_format.
Configure Nginx log_format
① Open nginx. conf
② Delete the line of the original log_format and replace it with the following
Log_format main '$ remote_addr-$ remote_user [$ time_local]'
'Fwf [$ http_x_forwarded_for] tip [$ http_true_client_ip]'
'$ Upstream_addr $ upstream_response_time $ request_time'
'$ Geoip_country_code'
'$ Http_host $ request'
'"$ Status" $ body_bytes_sent "$ http_referer "'
'"$ Http_accept_language" "$ http_user_agent "'
③ Save and exit
Restart nginx
Open the nginx log file, find error. log, tail-f error. log, and find the following error:
From the first line, we can find that PHP reports an error and searches for a problem. It is found that php only supports running directories and can only run under the/tmp/folder, therefore, the nginx www-root folder does not run, so access is denied.
Solution:
① Open the php. ini file
② Locate open_basedir.
③ Comment out this line, which means php can run in any folder. If you want to run it in a specified folder, set open_basedir to the corresponding directory.
④ Save and exit
Restart the PHP-FPM service php-fpm restart
Then visit the webpage and find that the problem has been solved.