Centos6.3 yum install nginx + mysql + php-fpm

Source: Internet
Author: User

The following describes how to install and configure nginx + MySQL + PHP-FPM:

1. Change source, update:

# rpm -Uvh http://centos.alt.ru/repository/centos/6/i386/centalt-release-6-1.noarch.rpm# yum update

2. Install nginx + MySQL + PHP-FPM:

# yum install nginx-stable php-fpm mysql-server php-mysql mysql-server php-mbstring php-gd php-pear php-mcrypt  php-mhash php-eaccelerator -y

3. Set the MySQL password and start MySQL, nginx, and PHP-FPM at startup:

# Service mysqld start # mysqladmin-u Root Password 'Password' # chkconfig nginx on # chkconfig mysqld on # chkconfig PHP-FPM on

Note: The following error occurs when PHP-FPM is started by default:

Starting PHP-FPM: [28-nov-2011 08:11:01] error: [pool WWW] cannot get uid for user 'apache'

Solution:

# vi /etc/php-fpm.d/www.conf

Find the following two rows:

user = apachegroup = apache

Change Apache to nginx.

4. enable port 80 (disabled by default ):

# /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT# /etc/rc.d/init.d/iptables save# /etc/init.d/iptables restart

5. Modify the nginx configuration file and start nginx and PHP-FPM:

# vi /etc/nginx/nginx.conf

Change the root directory of the website and add the default PHP file:

location / {root   /usr/share/nginx/html;index  index.php index.html index.htm;}

Modify the code to add PHP support:

# location ~ \.php$ {#    root           html;#    fastcgi_pass   127.0.0.1:9000;#    fastcgi_index  index.php;#    fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name;#    include        fastcgi_params;#}

Delete all the above # And one line (in blue), and modify the website directory to be consistent with the previous one. Start nginx and PHP-FPM:

# service nginx start# service php-fpm start

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.