Nginx cache configuration and troubleshooting

Source: Internet
Author: User
Tags openssl library nginx load balancing

I studied the error messages in the nginx cache for two days.
After I modified the configuration file, I still reported an error.
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

Error Message
The module is not installed, and some reinstall the module.
Install 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
D/home/data/install/lnmp/nginx-1.0.15/
View version
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

No configuration, so you can only recompile it.
./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
Add 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"

Note that you only need make instead of make install.
Make, do not make install will overwrite

-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/modules-I src/OS/unix-I objs-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/modules-I src/OS/unix-I objs-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/modules-I src/OS/unix-I objs-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/modules-I src/OS/unix-I objs-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/modules-I src/OS/unix-I objs-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'

Replace nginx binary files
[Root @ ceshi nginx-1.0.15] # killall nginx
[Root @ ceshi nginx-1.0.15] # cp./objs/nginx/home/data/websrv/nginx/sbin/
Cp: Do you want to overwrite "/home/data/websrv/nginx/sbin/nginx "? Y
Service nginx start
No error is reported this time.
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 is started normally.
When it is found that the nginx page is 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

You can also directly change the configuration file.
Vi/etc/security/limits. conf
Add the following at the end of the file:
* 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"

The server checks whether the last config time is later than If-Modified-Since. If config is updated after the last request, the server returns the complete content. If config is not updated during the request, the server does not need to return the complete content, you only need to send a 304 Not Modified status code to the client.

For more details, please continue to read the highlights on the next page:

Recommended reading:

Configure and optimize reverse proxy and load balancing in Nginx

Nginx load balancing: nginx: [emerg] cocould not build the types_hash

Nginx Load Balancing module ngx_http_upstream_module details

Nginx + Firebug allows the browser to tell you which Server Load balancer distributes requests

Ubuntu install Nginx php5-fpm MySQL (LNMP environment setup)

Nginx details: click here
Nginx: click here

  • 1
  • 2
  • Next Page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.