Objective:
Because the server Apache cannot withstand the current concurrency. Plus the front-end squid configuration, The problem still cannot be solved. And the page program is mostly dynamic. You cannot use fastcgi to handle it. So you want to use the Nginx as the reverse proxy Apache. The entire configuration installation process is simple. When considering high concurrency, Some optimizations were made before installation. The current configuration can withstand more than 3000 concurrent. It's not that big, huh? But it's just a few 499 questions.
Part 1th: Installation
1 Set up users and groups
/usr/sbin/groupadd www
/usr/sbin/useradd -g www www
2 installation pcre let Nginx support rewrite convenient after the need
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.8.tar.gz
tar zxvf pcre-7.8.tar.gz
cd pcre-7.8/
./configure
make && make install
3 Installation Nginx
wget http://sysoev.ru/nginx/nginx-0.7.58.tar.gz
tar zxvf nginx-0.7.58.tar.gz
cd nginx-0.7.58/
./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-cc-opt='-O2' --with-cpu-opt=opteron
make && make install
#注意上文中的--with-cc-opt= '-o2 '--with-cpu-opt=opteron This is compiler optimization, the most commonly used now is-02 instead of 3. The model of the corresponding CPU, can refer to: http://wiki.gentoo.tw/ Index.php/howto_cflag
Part 2nd: Configuring and Optimizing Configuration Files
1 nginx.conf configuration file:
User www www.
Worker_processes 4;
# [Debug | info | notice | warn | error | crit]
Error_log/usr/local/webserver/nginx/logs/nginx_error.log Crit;
Pid/usr/local/webserver/nginx/nginx.pid;
#Specifies the value for maximum file descriptors the can is opened by this process.
Worker_rlimit_nofile 51200;
Events
{
Use Epoll;
Worker_connections 51200;
}
http
{
Include Mime.types;
Default_type Application/octet-stream;
Source_charset GB2312;
Server_names_hash_bucket_size 256;
Client_header_buffer_size 256k;
Large_client_header_buffers 4 256k;
#size limits
Client_max_body_size 50m;
Client_body_buffer_size 256k;
Client_header_timeout 3m;
Client_body_timeout 3m;
Send_timeout 3m;
#参数都有所调整. The purpose is to resolve some 502 499 errors that occur during the agent process
Sendfile on;
Tcp_nopush on;
Keepalive_timeout 120; #参数加大 to resolve 502 errors when doing agent
Tcp_nodelay on;
Include vhosts/upstream.conf;
Include vhosts/bbs.linuxtone.conf;
}