1. Install the pcre Library required by Nginx:
Tar zxvf pcre-8.10.tar.gz
Cd pcre-8.10/
./Configure
Make & make install
Cd ../
2. Install Nginxtar zxvf nginx-0.8.46.tar.gz
Cd nginx-0.8.46/
./Configure -- user = www -- group = www -- prefix =/usr/local/webserver/nginx -- with-http_stub_status_module -- with-http_ssl_module
Make & make install
Cd ../
3. Create the Nginx log directory mkdir-p/data1/logs
Chmod + w/data1/logs
Chown-R www: www/data1/logs
4. Create an Nginx configuration file
① Create the nginx. conf file in the/usr/local/webserver/nginx/conf/directory: rm-f/usr/local/webserver/nginx/conf/nginx. conf
Vi/usr/local/webserver/nginx/conf/nginx. conf
Enter the following content: Reference user www;
Worker_processes 8;
Error_log/data1/logs/nginx_error.log crit;
Pid/usr/local/webserver/nginx. pid;
# Specifies the value for maximum file descriptors that can be opened by this process.
Worker_rlimit_nofile 65535;
Events
{
Use epoll;
Worker_connections 65535;
}
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;
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;
# Limit_zone crawler $ binary_remote_addr 10 m;
Server
{
Listen 80;
Server_name blog.s135.com;
Index index.html index.htm index. php;
Root/data0/htdocs/blog;
# Limit_conn crawler 20;
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/data1/logs/access. log access;
}
Server
{
Listen 80;
Server_name www.s135.com;
Index index.html index.htm index. php;
Root/data0/htdocs/www;
Location ~ . * \. (Php | php5 )? $
{
# Fastcgi_pass unix:/tmp/php-cgi.sock;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fcinclude gi. conf;
}
Log_format wwwlogs '$ remote_addr-$ remote_user [$ time_local] "$ request "'
'$ Status $ body_bytes_sent "$ http_referer "'
'"$ Http_user_agent" $ http_x_forwarded_for ';
Access_log/data1/logs/wwwlogs. log wwwlogs;
}
Server
{
Listen 80;
Server_name status.blog.s135.com;
Location /{
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
Enter the following content: Reference 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;
5. Start Nginxulimit-SHn 65535
/Usr/local/webserver/nginx/sbin/nginx
This article is from the "FlyHome" blog, please be sure to keep this source http://superfly81.blog.51cto.com/6302302/1294667