Last active
August 29, 2015 14:20
-
-
Save yungke/9b7faedb6f2aea0f4a89 to your computer and use it in GitHub Desktop.
Wp-ffpc 在 Nginx 的 conf 檔案
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user www www; | |
worker_processes auto; | |
error_log /home/wwwlogs/error_nginx.log crit; | |
pid /var/run/nginx.pid; | |
worker_rlimit_nofile 51200; | |
events { | |
use epoll; | |
worker_connections 51200; | |
} | |
http { | |
upstream memcached-servers { | |
server 127.0.0.1:11211; | |
} | |
include mime.types; | |
default_type application/octet-stream; | |
server_names_hash_bucket_size 128; | |
client_header_buffer_size 32k; | |
large_client_header_buffers 4 32k; | |
client_max_body_size 50m; | |
sendfile on; | |
tcp_nopush on; | |
keepalive_timeout 120; | |
server_tokens off; | |
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 Compression | |
gzip on; | |
gzip_buffers 16 8k; | |
gzip_comp_level 6; | |
gzip_http_version 1.1; | |
gzip_min_length 256; | |
gzip_proxied any; | |
gzip_vary on; | |
gzip_types | |
text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml | |
text/javascript application/javascript application/x-javascript | |
text/x-json application/json application/x-web-app-manifest+json | |
text/css text/plain text/x-component | |
font/opentype application/x-font-ttf application/vnd.ms-fontobject | |
image/x-icon; | |
gzip_disable "msie6"; | |
#If you have a lot of static files to serve through Nginx then caching of the files' metadata (not the actual files' contents) can save some latency. | |
open_file_cache max=1000 inactive=20s; | |
open_file_cache_valid 30s; | |
open_file_cache_min_uses 2; | |
open_file_cache_errors on; | |
###################pureftpd AND phpmyadmin############################ | |
server { | |
listen 80; | |
server_name _; | |
access_log /home/wwwlogs/access_nginx.log combined; | |
root /home/wwwroot/default; | |
index index.html index.php; | |
if ( $query_string ~* ".*[\;'\<\>].*" ){ | |
return 404; | |
} | |
location ~ .*\.(php|php5)?$ { | |
#fastcgi_pass remote_php_ip:9000; | |
fastcgi_pass unix:/dev/shm/php-cgi.sock; | |
fastcgi_index index.php; | |
include fastcgi.conf; | |
} | |
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ { | |
expires 30d; | |
} | |
location ~ .*\.(js|css)?$ { | |
expires 7d; | |
} | |
} | |
##########################vhost##################################### | |
include vhost/*.conf; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[root@vps ~]# curl -I http://yourDomain.com/ | |
HTTP/1.1 200 OK | |
Server: nginx | |
Date: Mon, 27 Apr 2015 02:51:40 GMT | |
Content-Type: text/html;charset=utf-8 | |
Connection: keep-alive | |
Vary: Accept-Encoding | |
Cache-Control: no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0 | |
Pragma: no-cache | |
Expires: Mon, 27 Apr 2015 02:51:40 GMT | |
X-Cache-Engine: WP-FFPC with memcached via PHP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name yourdomain.com; | |
access_log off; | |
index index.html index.htm index.jsp index.php; | |
include wordpress.conf; | |
root /home/wwwroot/yourdomain.com; | |
#error_page 404 /404.html; | |
if ( $query_string ~* ".*[\;'\<\>].*" ){ | |
return 404; | |
} | |
location @memcached { | |
default_type text/html; | |
set $memcached_key data-$scheme://$host$request_uri; | |
set $memcached_request 1; | |
if ($request_method = POST ) { | |
set $memcached_request 0; | |
} | |
if ( $uri ~ "/wp-" ) { | |
set $memcached_request 0; | |
} | |
if ( $args ) { | |
set $memcached_request 0; | |
} | |
if ($http_cookie ~* "comment_author_|wordpressuser_|wp-postpass_|wordpress_logged_in_" ) { | |
set $memcached_request 0; | |
} | |
if ( $memcached_request = 1) { | |
add_header X-Cache-Engine "WP-FFPC with memcached via nginx"; | |
memcached_pass memcached-servers; | |
error_page 404 = @nocache; | |
} | |
if ( $memcached_request = 0) { | |
rewrite ^ /index.php?q=$request_uri last; | |
} | |
} | |
location @rewrites { | |
add_header X-Cache-Engine ""; | |
rewrite ^ /index.php?q=$request_uri last; | |
} | |
location ~ .*\.(php|php5)?$ { | |
#fastcgi_pass remote_php_ip:9000; | |
#add_header X-Cache-Engine "not cached"; | |
fastcgi_pass unix:/dev/shm/php-cgi.sock; | |
fastcgi_index index.php; | |
include fastcgi.conf; | |
} | |
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ { | |
expires 365d; | |
} | |
location ~ .*\.(js|css)?$ { | |
expires 7d; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment