A CENTOS6+NGINX+MYSQL+PHP-FPM environment was installed in the virtual machine yesterday, recording the installation process. CENTOS6 recommends installing in a netinstall manner, installing a minimized server, and configuring the site environment, the size of the virtual machine is around 700M. The following is the installation configuration NGINX+MYSQL+PHP-FPM process:
1, add source, update:
The code is as follows |
Copy Code |
# RPM-UVH http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm # Yum Update |
2, installation NGINX+MYSQL+PHP-FPM:
The code is as follows |
Copy Code |
# yum Install nginx php-fpm mysql-server php-mysql php-mbstring php-gd php-pear-y |
3, set the MySQL password and MySQL, nginx, php-fpm boot:
The code is as follows |
Copy Code |
# service Mysqld Start # mysqladmin-u root password ' password ' # chkconfig Nginx on # Chkconfig Mysqld on # Chkconfig PHP-FPM on |
Note: When the default installation starts PHP-FPM, the following error occurs:
Starting php-fpm:[28-nov-2011 08:11:01] ERROR: [Pool www] cannot get uid for user ' Apache '
Solution:
The code is as follows |
Copy Code |
# vi/etc/php-fpm.d/www.conf Find the following two lines: user = Apache Group = Apache |
Change the Apache to Nginx.
4, open 80 ports (the default is off):
The code is as follows |
Copy Code |
# iptables-i input-p TCP--dport 80-j ACCEPT # Service Iptables Save # Service Iptables Restart |
5, modify Nginx configuration file, start Nginx and PHP-FPM:
The code is as follows |
Copy Code |
# vi/etc/nginx/conf.d/default.conf
|
To add a php default file:
The code is as follows |
Copy Code |
Location/{ root/usr/share/nginx/html; Index index.php index.html index.htm; } |
Modify to the next code, add PHP support:
The code is as follows |
Copy Code |
# 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; #} |
Remove all the # and blue font portions above. Start Nginx and PHP-FPM:
The code is as follows |
Copy Code |
# service Nginx Start # service PHP-FPM Start
|
6, with FileZilla upload site to/usr/share/nginx/html.