Nginx is a high-performance web server and reverse proxy server. It is well known for its stability and underlying system resource consumption.
However, although nginx is highly efficient, the bottleneck still cannot be avoided in the face of huge traffic volumes. Today, web servers all run dynamic and static pages. Solr also has a dedicated Dynamic and Static Index Division. When the traffic volume is large, there is a feasible application: Install nginx on one server, and install php + mysql on another server. This reduces the server load.
Environment Description:
Nginx is installed on the 192.168.253.129 server.
The 192.168.253.131 server is installed with php + mysql
1. Install nginx on 129
1. Install pcre because nginx needs to query php requests based on regular expressions.
# Rpm-qa | grep pcre // whether the PCRE is installed in the query system. Generally, the installed system is installed by default, so we need to delete the built-in
# Cp/lib64/libpcre. so.0 // before deleting the built-in PCRE, back up libpcre first. so.0 file, because the RPM package is too correlated, no libpcre after deletion. we cannot install PCRE in so.0.
Rpm-e -- nodeps pcre-6.6-2.el5_1.7 // Delete the built-in PCRE
Tar-zxf pcre-7.8.tar.gz
Cd pcre-7.8
Cp/libpcre. so.0/lib64 // copy the libpcre. so.0 backed up before we delete the built-in PCRE to the/lib directory.
. /Configure // configure PCRE. Because PCRE is a library rather than a program such as pache, php, and postfix, you can select the default path during installation, this will avoid unnecessary troubles when installing other things later. After executing this section, it will be displayed, which shows our PCRE configuration.
Make & make install
2. Install nginx
Tar-zxf nginx-0.7.30.tar.gz
Cd nginx-0.7.30
./Configure -- prefix =/usr/local/nginx // you only need to specify a path in this step.
Make & make install
2. install php + mysql on 31
1. Install mysql
Useradd mysql
Tar zxvf mysql-5.0.40.tar.gz
Cd mysql-5.0.40
./Configure -- prefix =/usr/local/mysql
Make & make install
/Usr/local/mysql/bin/mysql_install_db -- user = mysql // initialize the MySQL database
Chown-R mysql/usr/local/mysql/var
/Usr/local/mysql/bin/mysqld_safe & // start MySQL
/Usr/local/mysql/bin/mysqladmin-u root password 123456 // set the MySQL password
Cp support-files/my-medium.cnf/etc/my. cnf
Echo "/usr/local/mysql/bin/mysqld_safe &">/etc/rc. local
Install php
Downloaded to the same directory
Tar xvf php-5.3.0.tar.bz2
Gzip-cd php-5.3.0-fpm-0.5.12.diff.gz | patch-d php-5.3.0-p1 // Add php-5.3.0-fpm-0.5.12.diff.gz to the php-5.3.0 in patch form
Cd php-5.3.0
./Configure -- prefix =/usr/local/php -- enable-fastcgi -- enable-fpm -- with-mysql =/usr/local/mysql
Make & make install
Cp php. ini-dist/usr/local/php/etc/php. ini
3. Configure on 131
Modify the php-fpm configuration file
1. Change 127.0.0.1 to the local ip address <value name = "listen_address"> 192.168.253.131: 9000 </value>
2. Remove comments and run php as a nobody user.
Unix user of processes
<Value name = "user"> nobody </value>
Unix group of processes
<Value name = "group"> nobody </value>
3. Change the Client ip address to 192.168.253.129 and only accept nginx requests.
<Value name = "allowed_clients"> 192.168.253.129 </value>
Create a php test page
Mkdir-p/www/html
Vim/www/html/index. php
<? Php
Phpinfo ();
?>
4. Configure nginx at 192.168.253.129
Vim/usr/local/nginx/conf
Open the CGI comments, change the ip address to 192.168.253.131, and change the PHP file path to/www/html.
Location ~ \. Php $ {
Root html;
Fastcgi_pass 192.168.253.131: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME/www/html $ fastcgi_script_name;
Include fastcgi_params;
}
Test:
Http: // 192.168.253.129/index. php
Index. php
This article is from the "Exile" blog