An AccessDenied error occurs after the LNMP environment is set up.

Source: Internet
Author: User
After the LNMP environment is set up, an AccessDenied error occurs. now, the File permission problem has been ruled out and the 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. However, I opened nginx. conf and found that my log information was not detailed enough. so I hope to configure log_format to Configure Nginx log_format.

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.