The experimental environment of this paper is: Centos4.5,nginx version: nginx-0.7.26
pcre-7.8.tar.gz Regular expression: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
nginx-0.7.26.tar:http://www.nginx.net/
php-5.2.6.tar.bz2:http://www.php.net/releases/
Php-5.2.6-fpm-0.5.9.diff.gz
PHP-FPM is a fastcgi management patch for PHP that can smoothly change the php.ini configuration without restarting php-cgi:http://php-fpm.anight.org/
Note: The PHP version is consistent with the FPM version mysql-5.0.67.tar.gz
Discuz!_6.0.0_sc_utf8.zip
1, installation Pcre
Copy CodeThe code is as follows:
# TAR-ZXVF Pcre-7.8.tar.gz
# CD pcre-7.8
#./configure
# Make && make install
2. Installing Nginx
Copy CodeThe code is as follows:
# TAR-ZXVF Nginx-0.7.26.tar.gz
# CD nginx-0.7.26
#./configure--prefix=/usr/local/nginx
# Make && make install
Start nginx#/usr/local/nginx/sbin/nginx
Stop nginx# kill-quit ' cat/usr/local/nginx/logs/nginx.pid '
Restart Nginxkill-hup ' Cat/usr/local/nginx/logs/nginx.pid '
Add to self-launch # echo "/usr/local/nginx/sbin/nginx" >>/etc/rc.local
3. Install MySQL
Copy CodeThe code is as follows:
# TAR-ZXVF Mysql-5.0.67.tar.gz
# CD mysql-5.0.67
# Groupadd MySQL
# useradd-g mysql-s/sbin/nologin-m MySQL
#./configure--prefix=/usr/local/mysql--WITH-CHARSET=GBK--with-extra-charset=all--enable-hread-safe-client
--enable-local-infile--with-low-memory
# Make && make install
# CP SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF
# Chown-r mysql.mysql/usr/local/mysql/
#/usr/local/mysql/bin/mysql_install_db--user=mysql
# Chown-r root.root/usr/local/mysql/
# Chown-r mysql.mysql/usr/local/mysql/var/
Start the database service and add it to the self-boot:
#/usr/local/mysql/bin/mysqld_safe--user=mysql &
#cp Support-files/mysql.server/etc/rc.d/init.d/mysqld
#chmod 755/etc/rc.d/init.d/mysqld
To join the auto-start service queue:
#chkconfig--add mysqld
#chkconfig--level 345 mysqld on add root password
#/usr/local/mysql/bin/mysqladmin-u root password "123456"
Test: #/usr/local/mysql/bin/mysql-u Root-p Enter the password: 123456, see if you can enter the database
To configure the library file search path:
# echo "/usr/local/mysql/lib/mysql" >>/etc/ld.so.conf
# Ldconfig
# ldconfig-v
Add/usr/local/mysql/bin to environment variable in path
#echo "Export path= $PATH:/usr/local/mysql/bin" >>/etc/profile
#source/etc/profile
4. Install PHP
Here is the executable file, unlike Apache, and Apache when combined with the creation of a dynamic library
Copy CodeThe code is as follows:
# TAR-JXVF PHP-5.2.6.TAR.BZ2
# GZIP-CD php-5.2.6-fpm-0.5.9.diff.gz |patch-d PHP-5.2.6-P1
# CD php-5.2.6
#./configure--prefix=/usr/local/php--with-mysql=/usr/local/mysql--enable-fastcgi--enable-fpm
--with-config-file-path=/usr/local/php/etc--enable-force-cgi-redirect
# Make && make install
# CP Php.ini-recommended/usr/local/php/etc/php.ini
# vi/usr/local/php/php-fpm.conf
(1) <value name= "listen_address" >127.0.0.1:9000</value> modified to <value name= "Listen_address" >ip:9000 </value>
This machine is using the default 127.0.0.1
(2) The following two lines remove comments and modify
<value name= "Sendmail_path" >/usr/sbin/sendmail-t-i</value>
<value name= "Display_errors" >1</value>
(3) <value name= "user" >nobody</value>//Comment
(4) <value name= "group" >nobody</value>//Go to comment
(5) <value name= "allowed_clients" >127.0.0.1</value>//Allow connected PC, this machine is used 127.0.0.1
Start php-fpm#/usr/local/php/sbin/php-fpm start add to self-launch # echo "/usr/local/php/sbin/php-fpm start" >>/etc/rc.local
5, modify the Linux nginx configuration file, support PHP
Copy CodeThe code is as follows:
# vi/usr/local/nginx/conf/nginx.conf
User nobody;
Worker_processes 8;
Pid/usr/local/nginx/logs/nginx.pid;
Worker_rlimit_nofile 1024;
Events
{Use Epoll;
Worker_connections 1024;}
http{
Include Mime.types;
Default_type Application/octet-stream;
Server_names_hash_bucket_size 128;
Client_header_buffer_size 32k;
Large_client_header_buffers 4 32k;
Client_max_body_size 8m;
Sendfile on;
Tcp_nopush on;
Keepalive_timeout 60;
Tcp_nodelay on;
Fastcgi_connect_timeout 300;
Fastcgi_send_timeout 300;
Fastcgi_read_timeout 300;
Fastcgi_buffer_size 64k;
Fastcgi_buffers 4 64k;
Fastcgi_busy_buffers_size 128k;
Fastcgi_temp_file_write_size 128k;
gzip on;
Gzip_min_length 1k;
Gzip_buffers 4 16k;
Gzip_http_version 1.0;
Gzip_comp_level 2;
Gzip_types text/plain application/x-javascript text/css application/xml;
Gzip_vary on;
server {
Listen 80;
server_name www.abcdefg.com;
Root/var/www/blog;
Index index.html index.htm index.php;
Location ~. *\. (PHP|PHP5)? $ {
root HTML;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param Script_filename/var/www/blog$fastcgi_script_name;
Includefastcgi_params;}
Location ~. *\. (gif|jpg|jpeg|png|bmp|swf) $
{Expires 30d;}
Location ~. *\. (JS|CSS)? $
{Expires 1h;}
Log_format access ' $remote _addr-$remote _user [$time _local] "$request"
' $status $body _bytes_sent ' $http _referer '
' "$http _user_agent" $http _x_forwarded_for ';
Access_log/var/logs/access.log Access;}}
Note: The server section for PHP virtual host 127.0.0.1:9000 for fastcgi pc, I use the native/var/www/blog$fastcgi_script_name; To test the configuration file for a directory saved by a PHP Web page:
#/usr/local/nginx/sbin/nginx-t
6. Optimizing Linux Kernel Parameters
# vi/etc/sysctl.conf
Add the following at the end:
Copy CodeThe code is as follows:
Net.ipv4.tcp_fin_timeout = 30
Net.ipv4.tcp_keepalive_time = 300
Net.ipv4.tcp_syncookies = 1
Net.ipv4.tcp_tw_reuse = 1
Net.ipv4.tcp_tw_recycle = 1
Net.ipv4.ip_local_port_range = 500065000
Make the configuration effective immediately: #/sbin/sysctl-p.
Nginx Installation and configuration support PHP tutorial (full)