This article introduces solution 2 of nginx + php + mysql under CentOS5VPS. this solution uses php-fpm as fast
This article introduces solution 2 of nginx + php + mysql under CentOS 5 VPS. this solution uses php-fpm as the fastcgi Process Manager.
When using php-fpm, php must be re-compiled, and the built-in php cannot be used. Our point is to try to use the built-in system unless the function is not satisfied. In this solution, MySQL comes with CentOS 5 and Nginx is compiled by ourselves.
Install Nginx
Centos system without nginx, we use Nginx is self-compiled, Nginx version is the latest stable version 0.7.61, to the http://rashost.com/download to download nginx, and then start to install:
Rpm-ivh nginx-0.7 *. rpm
Chkconfig -- list nginx
Chkconfig nginx on
/Etc/init. d/nginx start
Rpm-ql nginx
The above rpm-ql nginx command is to check which directories the nginx files are installed under. you can see that the default nginx webpage directory should be/usr/share/nginx/html/
When you access nginx through a browser, you can see the default web page of nginx, which means nginx is working properly!
Install MySQL
Run the following command to install MySQL that comes with CentOS:
Yum install-y mysql-server
Chkconfig -- list mysqld
Chkconfig mysqld on
/Etc/init. d/mysqld start
Run the mysql-uroot command to connect to MySQL normally.
Install php & php-fpm
First install some library files on which php & php-fpm depends:
Yum install libmhash libmcrypt libtool-ltdl libpng libjpeg curl
Then go to the http://rashost.com/download to download our own compiled php-fpm and install:
Cd/opt
Tar zxf php-fpm-5.2.10 * .tar.gz
/Opt/php/sbin/php-fpm start
Edit/etc/rc. local and add/opt/sbin/php-fpm start
Integration
First, create the file test. php in the/usr/share/nginx/html Directory. the content is very simple, as long as the following line:
Assume that the VPS address is centos5.rashost.com. then, access http://centos5.rashost.com/test.php through a browser.
Modify the nginx configuration file/etc/nginx. conf, search for fastcgi_pass in the file, and modify this part:
Location ~ \. Php $ {
Root html;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME $ document_root/$ fastcgi_script_name;
Include fastcgi_params;
}
Restart nginx:
/Etc/init. d/nginx/restart
Then access the test. php page in the browser and the page will be correctly displayed. reboot VPS test, each module should be able to be started by itself. Success!