1. Configure the third-party yum source for CentOS because the original Yum is unable to install Nginx
wget http://www.atomicorp.com/installers/atomic Download Atomic yum source
Sh./atomic performing the installation
Yum Check-update
2. Installing Nginx
Yum Install Nginx
Service Nginx Start
Chkconfig Nginx on
3. Install MySQL
Yum install MySQL Mysql-server
Service mysqld Start
Chkconfig mysqld on
4. Installing PHP and its related components
Yum install php-mysql Php-redis php-devel php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbst Ring Php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-fpm php
Service PHP-FPM Start
Chkconfig PHP-FPM on
5. Modify the relevant configuration to enable Nginx support PHP
Vi/etc/nginx/conf.d/default.conf
Remove the previous comment
Location ~ \.php$ {
root HTML;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi _script_name; #注意这里需要修改为$document _root
Include Fastcgi_params;
}
Then restart Nginx,service nginx restart
Now it's ready to support PHP.
6. Whether the test environment is built successfully
Create a new index.php file under/usr/share/nginx/html path
<?php
Phpinfo ();
?>
Access Address # # # (IP address or bound domain name)/index.php
If this is displayed, it proves that it has been configured successfully.
Construction of LNMP Environment under CentOS