Talking about problems encountered when nginx + php + mysql was built for the first time, nginxmysql

Source: Internet
Author: User
Tags php mysql

Talking about problems encountered when nginx + php + mysql was built for the first time, nginxmysql

First, describe the linux environment:

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.



I used nginx | + php to build a web server and a mysql server to teach how to point to the database during php compilation.

This place does not need to be specific to the database

Nginx php mysql connection, start, in the environment is win7 need to change the file

If it is not configured, download the one-click installation package.
 

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.