After a period of use, found nginx in the concurrency and load capacity is indeed superior to Apache, now the majority of sites from Apache to Nginx. The following are some simple installation configurations for Nginx.
Environment
Operating systems: CentOS, RedHat
IP Address: 192.168.1.202
Download Package
# Mkdir/usr/local/src/tarbag
# Mkdir/usr/local/src/software
# cd/usr/local/src/tarbag/
Nginx
# wget http://www.nginx.org/download/nginx-1.0.6.tar.gz
Nginx Cache purge Module (optional)
# wget http://labs.frickle.com/files/ngx_cache_purge-1.3.tar.gz
Compiling the installation
# cd/usr/local/src/tarbag/
# TAR-XZVF Nginx-1.0.6.tar.gz-c/usr/local/src/software
# TAR-XZVF Ngx_cache_purge-1.3.tar.gz-c/usr/local/src/software
# cd/usr/local/src/software/
#./configure \
--prefix=/usr/local/nginx-1.0.6 \ # Installation path
--with-http_stub_status_module \ # Enable Nginx State module
--with-http_ssl_module \ # Enable SSL module
--with-http_realip_module \ # Enable the Realip module (forwards the user IP to the back-end server)
--add-module=. /ngx_cache_purge-1.3 # Add cache cleanup Extension Module
# make
# make Install
Kernel parameter Optimization
# VI sysctl.conf Add the following configuration
net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 1800
Net.ipv4.ip_conntrack_max = 16777216 # If default parameters are used, network drops are prone to occur
Net.ipv4.netfilter.ip_conntrack_max = 16777216# Prone to network drops if default parameters are used
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 =
Net.ipv4.tcp_tw_recycle = 1
Net.ipv4.tcp_tw_reuse = 1
Net.ipv4.tcp_mem = 94500000 915000000 927000000
Net.ipv4.tcp_max_orphans = 3276800
Net.ipv4.ip_local_port_range = 1024 65535
Configuration takes effect
# sysctl–p
Modify the Iptables startup script to add the Star () function
# Vi/etc/init.d/iptables
/sbin/sysctl-p
Configure the sample site site
Serial number
Domain name
Directory
1
Www.heytool.com
/www/html/www.heytool.com
2
Bbs.heytool.com
/www/html/bbs.heytool.com
To modify the Nginx configuration file:
# VI Nginx.conf
User nobody nobody; # run Nginx's owning group and owner
Worker_processes 2; # Open two nginx work process, generally several CPU core write a few
Error_log Logs/error.log Notice; # error log path
PID Logs/nginx.pid; # PID Path
Events {
Worker_connections 1024; # One process can handle 1024 requests at a time
}
HTTP {
Include Mime.types;
Default_type Application/octet-stream;
Log_format Main ' $remote _addr-$remote _user [$time _local] "$request" '
' $status $body _bytes_sent ' $http _referer '
' "$http _user_agent" "$http _x_forwarded_for";
Access_log Logs/access.log Main; # Default Access log path
Sendfile on;
Keepalive_timeout 65; # KeepAlive Supermarket time
# Start configuring a domain name, a server configuration segment typically corresponds to a domain name
server {
Listen 80; #
# Listen on all IP on this machine 80, can also write as 192.168.1.202:80, so that, only listen to 192.168.1.202 on the 80 port
server_name www.heytool.com; # Domain Name
root/www/html/www.heytool.com; # Site root directory (program directory)
Index index.html index.htm; # index File
Location/{# can have multiple location
root/www/html/www.heytool.com; # Site root directory (program directory)
}
Error_page 502 503 504/50x.html;
# define the error page, if it is a 500 error, then return the site root directory 50x.html to the user
Location =/50x.html {
root/www/html/www.heytool.com;
}
}
# Start Configuring Site bbs.heytool.com
server {
Listen 80;
server_name bbs.heytool.com;
root/www/html/bbs.heytool.com;
Index index.html index.htm; # index File
Location/{
root/www/html/bbs.heytool.com;
}
Error_page 502 503 504/50x.html;
Location =/50x.html {
root/www/html/bbs.heytool.com;
}
}
}
Nginx Startup off
#/usr/local/nginx-1.0.6/sbin/nginx//Start Nginx
#/usr/local/nginx-1.0.6/sbin/nginx–t//test nginx configuration file Accuracy
#/usr/local/nginx-1.0.6/sbin/nginx–s Reload//heavy-duty Nginx
#/usr/local/nginx-1.0.6/sbin/nginx–s Stop//off Nginx
Test
To create a test site
# mkdir–p/www/html/www.heytool.com
# mkdir–p/www/html/bbs.heytool.com
# echo "www.heytool.com" >/www/html/www.heytool.com/index.html
# echo "bbs.heytool.com" >/www/html/bbs.heytool.com/index.html
start Nginx
#/usr/local/nginx-1.0.6/sbin/nginx–t//See OK and successful, explain the configuration file no problem
Nginx:the configuration file/usr/local/nginx-1.0.6/conf/nginx.conf syntax is OK
Nginx:configuration file/usr/local/nginx-1.0.6/conf/nginx.conf Test is successful
#/usr/local/nginx-1.0.6/sbin/nginx
Bind hosts, test
Point two domains to 192.168.1.202
192.168.1.202 www.heytool.com
192.168.1.202 bbs.heytool.com
Open www.heytool.com, such as:
Nginx
Open bbs.heytool.com, such as:
Nginx
Complete!!!!
More Configuration reference: http://www.docin.com/p-222277825.html
Transferred from: http://blog.sina.com.cn/s/blog_68c25adf01014037.html
Nginx installation configuration + Clear Cache module installation