研究了2天的nginx缓存 出现各种报错
我把配置文件修改过后还是报错
location ~ /purge(/.*)
{
allow 127.0.0.1;
allow 192.168.0.0/24;
deny all;
proxy_cache_purge cache_one $host$1$is_args$args;
}
nginx: [emerg] unknown directive "proxy_cache_purge" in /home/data/websrv/nginx/conf/nginx.conf:75
nginx: [emerg] unknown directive "proxy_cache_purge
报错提示
发现模块没有安装,有的重新安装模块
安装 ngx_cache_purge-1.3.tar
wget http://labs.frickle.com/files/ngx_cache_purge-2.0.tar.gz
tar -zxvf ngx_cache_purge-2.0.tar.gz
cd /home/data/install/lnmp/nginx-1.0.15/
查看版本
nginx -V
[root@ceshi nginx-1.0.15]# /home/data/websrv/nginx/sbin/nginx -V
nginx version: nginx/1.0.15
configure arguments: --prefix=/home/data/websrv/nginx --with-http_stub_status_module
啥配置都没 所以只能重新编译
./configure --user=nginx --group=nginx --add-module=/home/data/install/ngx_cache_purge-2.0 \
--prefix=/home/data/websrv/nginx --with-http_stub_status_module --with-http_ssl_module
加模块
onfiguration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library
nginx path prefix: "/home/data/websrv/nginx"
nginx binary file: "/home/data/websrv/nginx/sbin/nginx"
nginx configuration prefix: "/home/data/websrv/nginx/conf"
nginx configuration file: "/home/data/websrv/nginx/conf/nginx.conf"
nginx pid file: "/home/data/websrv/nginx/logs/nginx.pid"
nginx error log file: "/home/data/websrv/nginx/logs/error.log"
nginx http access log file: "/home/data/websrv/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
注意这里只要make 而不要make install
make,不要make install会覆盖
-o objs/src/http/ngx_http_postpone_filter_module.o \
src/http/ngx_http_postpone_filter_module.c
gcc -c -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
-o objs/src/http/modules/ngx_http_ssi_filter_module.o \
src/http/modules/ngx_http_ssi_filter_module.c
gcc -c -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
-o objs/src/http/modules/ngx_http_charset_filter_module.o \
src/http/modules/ngx_http_charset_filter_module.c
gcc -c -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
-o objs/src/http/modules/ngx_http_userid_filter_module.o \
src/http/modules/ngx_http_userid_filter_module.c
gcc -c -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
-o objs/src/http/modules/ngx_http_autoindex_module.o \
src/http/modules/ngx_http_autoindex_module.c
gcc -c -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules \
-o objs/src/http/modules/ngx_http_auth_basic_module.o \
src/http/modules/ngx_http_auth_basic_module.c
make[1]: Leaving directory `/home/data/install/lnmp/nginx-1.0.15'
make -f objs/Makefile manpage
make[1]: Entering directory `/home/data/install/lnmp/nginx-1.0.15'
sed -e "s|%%PREFIX%%|/home/data/websrv/nginx|" \
-e "s|%%PID_PATH%%|/home/data/websrv/nginx/logs/nginx.pid|" \
-e "s|%%CONF_PATH%%|/home/data/websrv/nginx/conf/nginx.conf|" \
-e "s|%%ERROR_LOG_PATH%%|/home/data/websrv/nginx/logs/error.log|" \
< man/nginx.8 > objs/nginx.8
make[1]: Leaving directory `/home/data/install/lnmp/nginx-1.0.15'
替换nginx二进制文件
[root@ceshi nginx-1.0.15]# killall nginx
[root@ceshi nginx-1.0.15]# cp ./objs/nginx /home/data/websrv/nginx/sbin/
cp:是否覆盖"/home/data/websrv/nginx/sbin/nginx"? y
service nginx start
这次就没报错了
location ~ /purge(/.*)
{
allow 127.0.0.1;
allow 192.168.0.0/24;
deny all;
proxy_cache_purge cache_one $host$1$is_args$args;
}
access_log off;
}
Starting nginx daemon: nginx
started.
正常启动nginx了
当是发现 nginx 页面是500
500 Internal Server Error
[root@ceshi nginx-1.0.15]# ulimit -n
655360
[root@ceshi nginx-1.0.15]# ulimit -n 65535
[root@ceshi nginx-1.0.15]# cat /proc/sys/fs/file-max
65535
解决,也可以直接改配置文件
vi /etc/security/limits.conf
在文件末加上:
* soft nofile 65535
* hard nofile 65535
127.0.0.1 - - [06/Nov/2013:01:52:05 +0800] "GET /static_gmd/images/shadow_bg.jpg HTTP/1.0" 500 0 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36"
服务器端会判断上次的 config 时间是否比 If-Modified-Since 晚。如果自上次 request 之后又更新了 config,那么服务器就会返回完整的内容;如果期间没有更新 config,那么服务器就没必要返回完整的内容,只需要向客户端发送一个 304 Not Modified 状态码就可以了。
(责任编辑:IT) |