Problems with nginx + php + mysql

Source: Internet
Author: User
Let's talk about the problems encountered when we first set up nginx + php + mysql:

Nginx + php (5.5.10) + mysql


The source code has been written locally and debugged successfully (the default configuration of XAMPP is used in the local environment). when the code is uploaded to linux, the following problems occur:

[1] When writing logs:

PHP message: PHP Warning: fopen (log/log. log.141019): failed to open stream: Permission denied

This indicates that you have no access permission.

Solution: linux has some restrictions on php access user permissions. by default, it should be nobody access. Therefore, you only need to add permissions to the corresponding directory of nobody,

Operation: chown nobody: nobody log


[2] when accessing mysql:

PHP message: PHP Warning: mysql_connect (): No such file or directory
By default, php accesses mysql. sock at/var/mysql. sock, while my mysql handle is at/var/lib/mysql/mysq. sock,

Therefore, you only need to give a link: ln-s/var/lib/mysql/mysq. sock/var/mysql. sock


In addition, during XAMPP debugging, all the errors are reported on the page, which is very insecure and is thinking about how to handle them. nginx intercepts the error information, written in your own log file, this is good. (Can I configure it? To be studied later)


First, let's take a look at the solution. later, we will have time to get it done. now we are busy launching this service.

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.