Environment: OS: centos5.532-bit server address: 192.168.1.101 software version: small cdpcre-8.12./c...
Environment: Operating system: centos 5.5 32-bit server address: 192.168.1.101
Software version: pcre-8.12.zip nginx-1.0.5.tar.gz mysql-5.1.55.tar.gz php-5.3.6.tar.gz
1. install pcre
Unzip pcre-8.12.zip
Cd pcre-8.12
./Configure
Make & make install
Cd ..
2. install nginx
Useradd nginx-s/sbin/nologin
Tar-zxvf nginx-1.0.5.tar.gz
Cd nginx-1.0.5
./Configure -- user = nginx -- group = nginx -- prefix =/usr/local/nginx -- with-http_stub_status_module -- with-http_ssl_module
Make & make install
3. install mysql
Refer to the mysql installation document written in my blog
4. php installation preparation
A curl installation
Tar-zxvf curl-7.15.0.tar.gz
Cd curl-7.15.0
./Configure -- prefix =/usr/local/curl
Make & make install
B expat installation
Tar-zxvf expat-2.0.1.tar.gz
Cd expat-2.0.1
./Configure -- prefix =/usr/local/expat
Make & make install
C gzip installation
Tar-zxvf gzip-1.3.5.tar.gz
Cd gzip-1.3.5
./Configure -- prefix =/usr/local/gzip
Make & make install
D. install libxml2
Tar-zxvf libxml2-2.6.19.tar.gz
Cd libxml2-2.6.19
./Configure -- prefix =/usr/local/libxml2
Make & make install
E. zlib installation
Tar-zxvf zlib-1.2.3.tar.gz
Cd zlib-1.2.3
./Configure
Make & make install
F.jpeg 6 installation
Mkdir-p/usr/local/limit 6
Mkdir-p/usr/local/partition 6/bin
Mkdir-p/usr/local/IPv6/lib
Mkdir-p/usr/local/users 6/include
Mkdir-p/usr/local/IPv6/man
Mkdir-p/usr/local/IPv6/man1
Mkdir-p/usr/local/users 6/man/man1
Tar-zvxf restart src.v6b.tar.gz
Cd jpeg-6b
./Configure -- prefix =/usr/local/configure 6/-- enable-shared -- enable-static
Make & make install
G. install libpng
Tar-zxvf libpng-1.2.37.tar.gz
Cd libpng-1.2.37
./Configure // as described in zlib above, do not include parameters so that it is installed in the corresponding directory by default.
Make & make install
H install freetype
Tar-zvxf freetype-2.3.5.tar.gz
Cd freetype-2.3.5
Mkdir-p/usr/local/freetype
./Configure -- prefix =/usr/local/freetype
Make & make install
I install the libmcrypt encryption and decryption package (to avoid logging in to phpmyadmin and reporting an error)
Tar zxvf libmcrypt-2.5.7.tar.gz
Cd libmcrypt-2.5.7
./Configure
Make & make install
J. install fontconfig
Tar zxvf fontconfig-2.4.2.tar.gz
Cd fontconfig-2.4.2
./Configure -- prefix =/usr/local/fontconfig -- with-freetype-config =/usr/local/freetype/bin/freetype-config
Make & make install
K install gettext-devel
Yum-y install gettext-devel
(If not installed, make gd reports the error 'Am _ iconv' not found in library)
L install gd
Tar-zxvf gd-2.0.35.tar.gz
Cd gd-2.0.35
. /Configure -- prefix =/usr/local/gd -- with-jpeg =/usr/local/resize 6/-- with-png -- with-zlib -- with-freetype =/usr/local /freetype/-- with-fontconfig =/usr/local/fontconfig
Make & make install
5. install php
Run the following two commands to prevent php compilation errors.
Cp/usr/local/mysql/bin/mysql_config/usr/bin/mysql_config
Ln-s/usr/local/mysql/include/mysql. h/usr/include/
Tar-zxvf php-5.3.6.tar.gz
Cd php-5.3.6
. /Configure -- prefix =/usr/local/php -- with-config-file-path =/usr/local/php/etc -- with-gd =/usr/local/gd -- with-mysql =/usr/local/mysql/-- with-mysqli =/usr/local/mysql/bin/mysql_config -- with-jpeg-dir =/usr/local/defaults 6/ -- with-zlib-dir -- enable-mbstring = all -- with-pdo-mysql -- with-freetype-dir =/usr/local/freetype -- with-mcrypt -- enable-sockets -- enable-mbstring -- enable-fpm
Make & make install
# Cp php. ini-production/usr/local/php/etc/php. ini
# Vi/usr/local/php/etc/php. ini
Add date. timezone = Asia/Shanghai
Change short_open_tag = Off to short_open_tag = On (enable short format support)
Change expose_php = on to expose_php = off (hide the php version number in curl)
# Cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
# Vi/usr/local/php/etc/php-fpm.conf cancel the following; semicolon comment
1; pid = run/php-fpm.pid
2; pm. start_servers = 20
3; pm. min_spare_servers = 5
4; pm. max_spare_servers = 35
# Cp sapi/fpm/init. d. php-fpm/etc/init. d/php-fpm
# Chmod 755/etc/init. d/php-fpm
# Chkconfig -- add php-fpm
# Chkconfig -- levels 2345 php-fpm on
# Service php-fpm start
6 integrate php and nginx
# Change vi/usr/local/nginx/conf/nginx. conf to the following content:
User nginx;
Worker_processes 8;
Error_log logs/error. log crit;
Pid logs/nginx. pid;
Worker_rlimit_nofile 65535;
Events
{
Use epoll;
Worker_connections 51200;
}
Http
{
Include mime. types;
Default_type application/octet-stream;
# Charset gb2312;
Server_names_hash_bucket_size 128;
Client_header_buffer_size 32 k;
Large_client_header_buffers 4 32 k;
Client_max_body_size 8 m;
Sendfile on;
Tcp_nopush on;
Keepalive_timeout 60;
Tcp_nodelay on;
Server_tokens off;
Fastcgi_connect_timeout 300;
Fastcgi_send_timeout 300;
Fastcgi_read_timeout 300;
Fastcgi_buffer_size 64 k;
Fastcgi_buffers 4 64 k;
Fastcgi_busy_buffers_size 128 k;
Fastcgi_temp_file_write_size 128 k;
Gzip on;
Gzip_min_length 1 k;
Gzip_buffers 4 16 k;
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 192.168.1.101;
Index index.html index.htm index. php;
Root/data/web;
Location ~ . * \. (Php | php5 )? $
{
# Fastcgi_pass unix:/tmp/php-cgi.sock;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fcinclude GI. conf;
}
Location ~ . * \. (Gif | jpg | jpeg | png | bmp | swf) $
{
Expires 30d;
}
Location ~ . * \. (Js | css )? $
{
Expires 1 h;
}
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/usr/local/nginx/logs/webaccess. log access;
Location/nginxstatus {
Stub_status on;
Access_log off;
}
}
}
Create the fcgi. conf file in the/usr/local/webserver/nginx/conf/directory:
Vi/usr/local/webserver/nginx/conf/fcgi. conf
Fastcgi_param GATEWAY_INTERFACE CGI/1.1;
Fastcgi_param SERVER_SOFTWARE nginx;
Fastcgi_param QUERY_STRING $ query_string;
Fastcgi_param REQUEST_METHOD $ request_method;
Fastcgi_param CONTENT_TYPE $ content_type;
Fastcgi_param CONTENT_LENGTH $ content_length;
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
Fastcgi_param SCRIPT_NAME $ fastcgi_script_name;
Fastcgi_param REQUEST_URI $ request_uri;
Fastcgi_param DOCUMENT_URI $ document_uri;
Fastcgi_param DOCUMENT_ROOT $ document_root;
Fastcgi_param SERVER_PROTOCOL $ server_protocol;
Fastcgi_param REMOTE_ADDR $ remote_addr;
Fastcgi_param REMOTE_PORT $ remote_port;
Fastcgi_param SERVER_ADDR $ server_addr;
Fastcgi_param SERVER_PORT $ server_port;
Fastcgi_param SERVER_NAME $ server_name;
# PHP only, required if PHP was built with -- enable-force-cgi-redirect
Fastcgi_param REDIRECT_STATUS 200;
7. test the configuration file
/Usr/local/nginx/sbin/nginx-t
Start nginx and add/etc/rc. d/rc. local to boot automatically
Ulimit-SHn 65535
/Usr/local/nginx/sbin/nginx
8. optimize Linux kernel parameters
Add the following content to the end of vi/etc/sysctl. conf:
# Add
Net. ipv4.tcp _ max_syn_backlog = 65536
Net. core. netdev_max_backlog = 32768
Net. core. somaxconn = 32768
Net. core. wmem_default = 8388608
Net. core. rmem_default = 8388608
Net. core. rmem_max = 16777216
Net. core. wmem_max = 16777216
Net. ipv4.tcp _ timestamps = 0
Net. ipv4.tcp _ synack_retries = 2
Net. ipv4.tcp _ syn_retries = 2
Net. ipv4.tcp _ tw_recycle = 1
# Net. ipv4.tcp _ tw_len = 1
Net. ipv4.tcp _ tw_reuse = 1
Net. ipv4.tcp _ mem = 94500000 915000000 927000000
Net. ipv4.tcp _ max_orphans = 3276800
# Net. ipv4.tcp _ fin_timeout = 30
# Net. ipv4.tcp _ keepalive_time = 120
Net. ipv4.ip _ local_port_range = 1024 65535
Make the configuration take effect immediately:
/Sbin/sysctl-p
9. install eaccelerator to optimize php
Tar-jxvf eaccelerator-0 \ [1 \ ].9.6.1.tar.bz2
Cd eaccelerator-0.9.6.1/
/Usr/local/php/bin/phpize
./Configure -- enable-eaccelerator = shared -- with-php-config =/usr/local/php/bin/php-config
Make
Make install
Vi/usr/local/php/etc/php. ini
Add
Extension = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator. so"
Eaccelerator. shm_size = "16"
Eaccelerator. cache_dir = "/tmp/eaccelerator"
Eaccelerator. enable = "1"
Eaccelerator. optimizer = "1"
Eaccelerator. check_mtime = "1"
Eaccelerator. debug = "0"
Eaccelerator. filter = ""
Eaccelerator. shm_max = "0"
Eaccelerator. shm_ttl = "0"
Eaccelerator. shm_prune_period = "0"
Eaccelerator. shm_only = "0"
Eaccelerator. compress = "1"
Eaccelerator. compress_level = "9"
Create a folder
Mkdir/tmp/eaccelerator
Chmod 0777/tmp/eaccelerator
Restart php
Service php-fpm restart
10 tests
Create the website root directory
Mkdir-p/data/upload index. php (the attachment provides download) to/data/web. enter http: // 192.168.1.101/index. php in the browser to see the effect.
This article is from the "daocaoren0311" blog