nginx:
修改: src/core/nginx.h
#define nginx_version 8054
#define NGINX_VERSION "0.8.54"
#define NGINX_VER "nginx/" NGINX_VERSION
#define NGINX_VAR "NGINX"
为想要显示的信息
cache_purge :
./configure --prefix=/data/soft/nginx/ \
--user=nobody \
--group=nobody \
--with-http_flv_module \
--with-http_sub_module \
--with-http_stub_status_module \
--with-http_gzip_static_module\
--without-http_auth_basic_module \
--without-http_scgi_module \
--without-http_uwsgi_module \
--add-module=../ngx_cache_purge-1.2/
将以上的configure保存以备以后升级时使用.
nginx.conf:
user nobody nobody;
worker_processes 4;
worker_rlimit_nofile 30000;
log_not_found off;
#our own experience worker_processes value is recommended to
#be set to the number of cores your server has
worker_processes 4;
#worker_cpu_affinity 0001 0010 0100 1000;
#Bind the first worker to CPU0 , second to CPU1 ,thired to CPU2,forth to CPU3
#error_log file [ debug | info | notice | warn | error | crit ]
# 1. in the main section - error
# 2. in the HTTP section - crit
# 3. in the server section - crit
#pid logs/nginx.pid;
events {
#The worker_connections and worker_proceses from the main section
#allows you to calculate maxclients value:
#max_clients = worker_processes * worker_connections
#In a reverse proxy situation, max_clients becomes
#max_clients = worker_processes * worker_connections/4
#Since a browser opens 2 connections by default to a server and
#nginx uses the fds (file descriptors)
#from the same pool to connect to the upstream backend
worker_connections 4096;
#use [ kqueue | rtsig | epoll | /dev/poll | select | poll ] ;
#used [epoll] on Linux 2.6+
use epoll;
}
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;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
#keepalive_timeout 0;
keepalive_timeout 20;
keepalive_requests 1000;
server_tokens off;
#gzip on;
include vhosts/*.conf;
}
vhosts/
server {
listen 80;
#use "default" parameter to directive this is default when using
#name based virtual hosts.
# listen 88 default;
server_name x.x.com;
charset utf-8;
gzip on;
gzip_types text/html text/css;
gzip_comp_level 3;
gzip_min_length 10000;
# gzip_disable "MSIE [1-6]\.";
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
access_log off;
expires 30d;
}
root /xxx/xx/;
access_log off;
log_not_found off;
location / {
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
include access.conf;
location ~ \.php$ {
#add to fastcgi_params,below the "fastcgi_param SCRIPT_NAME" line.
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_pass unix:/tmp/php5-fpm.sock;
}
location /nginx_status {
stub_status on;
access_log off;
allow x.x.x.x;
deny all;
}
}
access.conf:
location /xxxx/ {
allow x.x.x.x;
allow x.x.x.x;
allow x.x.x.x;
deny all;
}
关于cache:
http {
proxy_cache_path /tmp/cache levels=1:1:1 keys_zone=tmpcache:10m inactive=10m max_size=1G;
upstream backend_group {
server backend1.example.com weight=5;
server backend2.example.com:8080;
server unix:/tmp/backend3;
}
server {
location / {
proxy_pass
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504
proxy_cache tmpcache;
proxy_cache_valid 200 204 304 12h;
proxy_cache_valid 301 302 10m;
proxy_cache_valid any 1m;
proxy_cache_key $uri$is_args$args;
# proxy_cache_key $host$uri$is_args$args;
# proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Accept-Encoding "";
expires 12h;
}
location ~ .*\.(php|jsp|cgi)?$ {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass
}
location ~ /purge(/.*) {
allow 127.0.0.1;
deny all;
proxy_cache_purge tmpcache $1$is_args$args;
}
}
}
假设一个URL为,通过访问
注意配置段中的区域包含关系.
proxy_cache_patch 要在proxy_cache前已经定义.
>>>> what seems to be the problem?
>>>>
>>>> [emerg]: the size 52428800 of shared memory zone "media" conflicts with
>>>> already declared size 0 in /etc/nginx/conf.d/cache.conf:5
>>>> configuration file /etc/nginx/nginx.conf test failed
>>>>
>>>>
>>> This may be caused if "proxy_cache media" is included before proxy_cache_path.
>>>
>>>
nginx升级:
./configure xxxxxxxxx
make
生成objs/nginx可执行文件
NEW_NGINX=`pwd` ; cd /data/soft/nginx/sbin/; mv nginx nginx.old ;
cp ${NEW_NGINX}/objs/nginx /data/soft/nginx/sbin/
/data/soft/nginx//sbin/nginx -t
kill -USR2 `cat /data/soft/nginx//logs/nginx.pid`
sleep 1
test -f /data/soft/nginx//logs/nginx.pid.oldbin
kill -QUIT `cat /data/soft/nginx//logs/nginx.pid.oldbin`
版本回退:
mv nginx nginx.new ; mv nginx.old nginx
/data/soft/nginx//sbin/nginx -t
kill -HUP `cat /usr/local/nginx/nginx.pid`
阅读(2479) | 评论(0) | 转发(0) |