CentOS5VPS nginx + php + mysql solution 2

Source: Internet
Author: User
Tags vps
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!

Related Article

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.