Import third-party software libraries
Centos 5 32-bit:
- Rpm-uvh http://nginx.org/packages/centos/5/noarch/RPMS/nginx-release-centos-5-0.el5.ngx.noarch.rpm
- Rpm-uvh http://centos.alt.ru/repository/centos/5/i386/centalt-release-5-3.noarch.rpm
Centos 5 64-bit:
- Rpm-uvh http://nginx.org/packages/centos/5/noarch/RPMS/nginx-release-centos-5-0.el5.ngx.noarch.rpm
- Rpm-uvh http://centos.alt.ru/repository/centos/5/x86_64/centalt-release-5-3.noarch.rpm
Install MySQL
1. Uninstall the built-in Apache, and then update the software library.
- Yum remove httpd
- Yum update
Install MySql in yum
- Yum install MySQL mysql-Server
Add the startup Item and start MySQL
- Chkconfig -- levels 235 mysqld on
- /Etc/init. d/mysqld start
Set the MySQL password and related settings
- Mysql_secure_installation
Because this command is started for the first time, press Enter next, enter your MySQL password, and follow the prompts.
Install nginx
1. Install nginx in yum
- Yum install nginx
Add to startup Item and start nginx
- Chkconfig -- levels 235 nginx on
- /Etc/init. d/nginx start
Install PHP
1. install PHP and related modules
- Yum install PHP-fpm php-cli PHP-mysql PHP-Gd PHP-imap PHP-ldap php-odbc php-pear PHP-xml php-xmlrpc php-mbstring PHP-mcrypt PHP- mssql php-snmp php-soap PHP-tidy
2. Edit the php. ini file and add CGI. fix_pathinfo = 1 at the end of the file.
3. Start PHP-FPM
- Service PHP-FPM start
Add PHP-FPM to the startup Item
- Chkconfig -- levels 235 PHP-FPM on
Modify the nginx configuration file and add FastCGI support
1. Modify the nginx. conf file
VI/etc/nginx. conf
Configuration File Code:
- [...]
- Server {
- Listen 80;
- SERVER_NAME _;
- # Charset koi8-r;
- # Access_log logs/host. Access. Log main;
- Location /{
- Root/usr/share/nginx/html;
- Index index. php index.html index.htm;
- }
- Error_page 404/404 .html;
- Location =/404.html {
- Root/usr/share/nginx/html;
- }
- # Redirect server error pages to the static page/50x.html
- #
- Error_page 500 502 503 x.html;
- Location =/50x.html {
- Root/usr/share/nginx/html;
- }
- # Proxy the PHP scripts to Apache listening on 127.0.0.1: 80
- #
- # Location ~ \. Php $ {
- # Proxy_pass http: // 127.0.0.1;
- #}
-
- # Pass the PHP scripts to FastCGI server listening on Fig: 9000
- #
- Location ~ \. Php $ {
- Root/usr/share/nginx/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;
- }
- # Deny access to. htaccess files, if Apache's document root
- # Concurs with nginx's one
- #
- Location ~ /\. Ht {
- Deny all;
- }
- }
- [...]
Modify row 33/usr/share/nginx/html to your website root directory.
2. Restart nginx PHP-FPM
- /Etc/init. d/nginx restart
- /Etc/init. d/PHP-FPM restart
Test...
Source: http://www.centos.bz/2011/03/yum-install-nginx-mysql-php-fastcgi-lnmp/