Nginx: 0.8.151. Install the pcre Library required by Nginx: Export cdusrlocalsrctarbag#tarzxvfpcre-7.9.tar.gz-C .. software # cd .. softwarepcre-7.9 #. configure # makemakeinstall # cdhttp: restart
Nginx: 0.8.15
1, InstallationNginxRequiredPcreLibrary:
- #Cd/Usr/local/src/tarbag
- # Tar zxvf pcre-7.9.tar.gz-C ../software
- # Cd ../software/pcre-7.9/
- #./Configure
- # Make & make install
- # Cd http://www.linuxIdC.com/tarbag
2, InstallationNginx
- # Tar zxvf nginx-0.8.15.tar.gz-C ../software
- # Cd ../software/nginx-0.8.15/
- #./Configure -- user = nobody -- group = nobody -- prefix =/usr/local/nginx -- with-http_stub _StatUs_moDuLe -- with-http_ssl_module
- # Make & make install
- # Cd http://www.linuxidc.com/tarbag
3, CreateNginxLog directory
- Mkdir-P/opt/www/nginx/logs
- Chmod+ W/www/nginx/logs
- Chown-R nobody: nobody/www/nginx/logs
4, CreateNginxConfiguration File
In/Usr/local/nginx/conf/CreateNginx. confFile:
- Rm-F/usr/local/nginx/conf/nginx. conf
- Vi/usr/local/nginx/conf/nginx. conf
- User nobody;
- Worker_processes 8;
- Error_log/opt/www/nginx/logs/nginx_error.log crit;
- Pid/usr/local/nginx. pid;
- # Specifies the value for maximumFileDescriptors that can be openEdBy this process. worker_rlimit_nofile 65535;
- Events
- {
- Use epoll;
- Worker_connections 65535;
- }
- Http
- {
- INcLude mime. types;
- Default_type appliCatIon/octet-sTrEam;
- # CharSetGb2312;
- 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;
- GZipOn;
- 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;
- Log_format access \ '$ remote_aDdR-$ remote_user [$ time_local] \'
- \ "$ Request \" $ status $ bytes_sent \'
- \ '\ "$ Http_referer \" \ "$ http_user_agent \"\'
- \ "$ Gzip_ratio \"\';
- Log_format wwwlogs \ '$ remote_addr-$ remote_user [$ time_local] \'
- \ '\ "$ Request \" $ status $ bytes_sent \'
- \ '\ "$ Http_referer \" \ "$ http_user_agent \"\'
- \ '\ "$ Http_range \" \ "$ sent_http_content_range \"\';
- Include vhosts. conf
- }
In/Usr/local/nginx/conf/CreateVhosts. confFile:
- Vi/usr/local/nginx/conf/vhosts. conf
- # Limit_zone crawler $ binary_remote_addr 10 m;
- Server
- {
- Listen 80;
- Server_name www.hsf.com;
- Index index.html index.htm index.Php;
- Root/www/blog;
- # Limit_conn crawler 20;
- Access_log/opt/www/nginx/logs/access. log access;
- }
- Server
- {
- Listen 80;
- Server_name www.hsf.com;
- Index index.html index.htm index. php;
- Root/www;
- Access_log/www/nginx/wwwlogs. log wwwlogs;
- }
- Server
- {
- Listen 80;
- Server_name status.www.hsf.com;
- Location/
- {
- Stub_status on;
- Access_log off;
- }
- }
5, StartNginx
- Ulimit-SHn 65535
- /Usr/local/nginx/sbin/nginx
OptimizationLinuxKernel Parameters
- Vi/etc/sysctl. conf
Add the following content at the end:
- # Add
- Net. ipv4.tcp _ max_syn_backlog = 65536
- Net. core. netdev_max_backlog = 32768
- Net. core. somaxconn = 32768
- Net. core. wmem_default = 8388608