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.