tar zxvf nginx-0.8.35.tar.gz
cd nginx-0.8.35/
./configure –user=zhangy –group=users –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module –with-pcre=/usr/local/pcre
make && make install
1,配置nginx.conf
nano /usr/local/nginx/conf/nginx.conf
user zhangy users;
worker_processes 10;
error_log /var/vlogs/nginx_error.log crit;
pid /var/vlogs/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 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
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 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
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 10m;
upstream 127.0.0.1:1081 { server 127.0.0.1:1081; }
upstream localhost:1080 { server 127.0.0.1:1080; }
server
{
listen 10000;
server_name :10000;
index index.html index.htm index.php;
root /home/zhangy/www/metbee/trunk/src/web;
#limit_conn crawler 20;
location ~ .*\.(php|php5)?$
{
proxy_pass :1081;
break;
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
# location /main {
# proxy_pass ;
# break;
# }
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
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 /var/log/metbee.log access;
}
server
{
listen 80;
server_name :80;
index index.html index.htm blog/index.php;
root /home/zhangy/www;
location /test {
proxy_pass :1080;
break;
}
# location ~ .*\.(php|php5|html)?$
# location ~ .*
# {
if (!-e $request_filename){
rewrite ^/tag/(.*) /blog/index.php?tag=$1 last;
rewrite ^/page/(\d+)$ /blog/index.php?paged=$1 last;
rewrite ^/(.*)/(\d+)\.html /blog/index.php?p=$2 last;
rewrite ^/category/(.*) /blog/index.php?category_name=$1 last;
# rewrite ^/date/([0-9]{4,4})/([0-9]{1,2})?$ /blog/index.php?year=$1&monthnum=$2&page=$3 last;
# rewrite ^/date/([0-9]{4,4})/([0-9]{1,2})?$ /blog/index.php?m=$1$2 last;
rewrite ^/newpage(\d+)$ /blog/index.php?page_id=$1 last;
rewrite ^/feed$ /blog/index.php?feed=rss2 last;
rewrite ^/comment/feed$ /blog/index.php?feed=comment-rss2 last;
rewrite $ redirect;
}
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.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 /var/log/wwwlogs.log wwwlogs;
}
server
{
listen 10001;
server_name :10001;
index index.html index.htm index.php;
root /mnt/song/fastfds2/data;
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
log_format imagelogs '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
access_log /var/log/imagelogs.log imagelogs;
}
server
{
listen 11211;
server_name :11211;
location / {
stub_status on;
access_log off;
}
}
}