Install nginx + mysql + php on the Interface Server 1. install nginx (refer to resource server configuration) 2. install mysql (refer to mysql installation in game server configuration) 3. installing php is the most important place, because Nginx and PHP do not feel any difference by default...
Nginx + mysql + php must be installed on the Interface Server
1. install nginx (refer to resource server configuration)
II. install mysql (refer to mysql installation in game server configuration)
3. install php
This is the most important place, because Nginx and PHP do not feel any difference by default. Many friends have built Apache + PHP. after compiling Apache + PHP, the module file is generated, while Nginx + PHP requires PHP to generate executable files, therefore, fastcgi technology should be used to achieve Nginx and PHP integration, as long as FastCGI is enabled for installation. This time we install PHP not only use FastCGI, but also use the PHP-FPM such a stuff, PHP-FPM said White is a management FastCGI a manager, it exists as a PHP plug-in, install PHP in the form of a patch to install the PHP-FPM to PHP to use the PHP-FPM, and PHP to be consistent with the PHP-FPM version, this is necessary, remember!
Yum install libxml2 libxml2-devel
Yum install libpng *
Yum install gd
Tar zxvf php-5.2.13.tar.gz
Gzip-cd php-5.2.13-fpm-0.5.13.diff.gz | patch-d php-5.2.13-p1 // add php-5.3.0-fpm-0.5.12.diff.gz to the php-5.3.0 in patch form
Cd php-5.2.13
./Configure -- prefix =/usr/local/php -- with-mysql =/usr/local/mysql -- enable-fastcgi -- enable-fpm
Make
Make install
Cp php. ini-dist/usr/local/php/etc/php. ini
Note: for Nginx + PHP integration, you must enable -- enable-fastcgi and -- enable-fpm during installation.
/Usr/local/php/sbin/php-fpm start
The above error is reported when starting the PHP-FPM because the PHP-FPM itself does not know to run PHP with that user and group, so we need to modify a file, remove the comments from the file (open the file and delete the red part), and then the PHP-FPM will run PHP with nobody users and groups.
6/usr/local/php/etc/php-fpm.conf
/Usr/local/php/sbin/php-fpm start
Ps-aux | grep php
Echo "/usr/local/php/sbin/php-fpm start">/etc/rc. local
Nginx does not process dynamic web page requests by itself, and Nginx transfers the dynamic requests to PHP. let's open the Nginx configuration file and take a look.
Vi/usr/local/nginx/conf/nginx. conf
Note: The above/var/www/html is the path of our PHP website.
As shown in, we have seen before that Nginx forwards PHP requests to PHP through Port 9000 of the local machine, and we can see that PHP listens on data from Port 9000 of the local machine, nginx and PHP complete data requests through the local port 9000.
IV. test
Vi/var/www/html/test. php
Phpinfo ();
?>
Kill the process and start it.
Pkill php
Pkill nginx
/Usr/local/php/sbin/php-fpm start
/Etc/rc. d/init. d/nginx start
After restarting PHP and nginx (the process can be closed by killing and then starting), we enter http: // local IP address/test. php in the browser.
For more information about interface testing, see interface documentation.
Authorize the API server:
Grant all on shuihu. account to "test" @ "192.168.1.22" identified by "123456 ";
Hide version number
Edit nginx. conf
Vi/usr/local/nginx/conf/nginx. conf
Add server_tokens off under keepalive_timeout 65;
Modify fastcgi. conf
Vi/usr/local/nginx/conf/fastcgi. conf
Fastcgi_param SERVER_SOFTWARE nginx/$ nginx_version;
Change to fastcgi_param SERVER_SOFTWARE nginx
[Root @ ~] # Curl -- head 127.0.0.1
HTTP/1.1 403 Forbidden
Server: nginx
Date: Thu, 04 Aug 2011 07:41:54 GMT
Content-Type: text/html
Content-Length: 162
Connection: keep-alive
Restart nginx
Service nginx restart
Or restart nginx smoothly.
Check the configuration file again:
/Usr/local/nginx/sbin/nginx-t
If the following two lines of information are displayed, the configuration file is correct:
The configuration file/usr/local/webserver/nginx/conf/nginx. conf syntax is OK
The configuration file/usr/local/webserver/nginx/conf/nginx. conf was tested successfully
Smooth restart:
For Nginx 0.8.x, it is very easy to smoothly restart Nginx. run the following command:
/Usr/local/nginx/sbin/nginx-s reload