我有nginx的設置爲提供HTML內容直接從memcached的,但用我們自己的後端(而不是傳統的設立因而故障切換到PHP配置),但是無論何時在PHP中設置頁面以便從memcached中檢索,nginx似乎都可以找到它,但只需下載一個名爲「download」的文件,其內部看起來像是二進制數據。nginx的memcached的和,返回「下載」作爲附件,而不是HTML內容
這是nginx.conf文件,並將其從源使用增強的memcached模塊建造。
worker_processes 1;
events {
worker_connections 1024;
}
http {
include /usr/local/nginx/conf/mime.types;
default_type application/octet-stream;
server {
listen 80;
server_name localhost;
location/{
root /var/www;
index index.html;
}
location ~* \.php$ {
root /var/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 80;
server_name mydomain.com;
access_log /path/to/access/log/access_log;
error_log /path/to/error/log/error_log;
root /u1/live/sites/public_html;
location ~* \.(jpg|png|gif|css|js|swf|flv|ico|html|woff|ttf|svg|htm)$ {
try_files $uri $uri/ $uri.html @notcached;
}
location ~* \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 240;
include fastcgi_params;
}
location/{
set $enhanced_memcached_key "$server_name$request_uri";
enhanced_memcached_hash_keys_with_md5 on;
enhanced_memcached_pass memcache.local:11211;
error_page 404 = @notcached;
}
location @memcache {
set $enhanced_memcached_key "$server_name$request_uri";
enhanced_memcached_hash_keys_with_md5 on;
enhanced_memcached_pass memcache.local:11211;
error_page 404 = @notcached;
}
location @notcached {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /path/to/main/php/file/index.html;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_read_timeout 240;
include fastcgi_params;
}
}
}
這個問題可能是[ServerFault(http://serverfault.com)更好。投票遷移。 – 2013-02-17 21:16:34