我的主页面显示在wordpress上但是当我转到其他页面,例如mainpage.com/contact-us,其中有一个php代码,给我一个502坏网关。我已经在php5-fpm和nginx上完成了一些配置,但它似乎根本没有工作。非常感谢任何帮助。
NGINX.conf
nginx.conf
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 8192;
multi_accept on;
use epoll;
}
http {
##
# Reverse
##
set_real_ip_from 0.0.0.0/0;
real_ip_header X-Forwarded-For;
add_header X-UA-Compatible "IE=Edge,chrome=1";
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
##
# Rockin Defaults
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 5;
types_hash_max_size 2048;
server_names_hash_bucket_size 64;
server_name_in_redirect off;
client_max_body_size 512k;
include /etc/nginx/mime.types;
default_type application/octet-stream;
index index.php index.html
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_static on;
gzip_proxied any;
gzip_comp_level 4;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
upstream php {
server unix:/var/run/php5-fpm.sock;
}
}
的nginx / / WordPress的启用位点-
fastcgi_cache_path /mnt/ramdisk/phpfpm-cache levels=1:2 keys_zone=microcache:5M max_size=1G inactive=2h;
server {
listen 8080 default;
server_name localhost;
access_log /mnt/access.log;
error_log /mnt/error.log;
root /var/www/;
index index.php index.html;
client_max_body_size 10m;
client_body_buffer_size 128k;
client_header_buffer_size 64k;
location = /favicon.ico {
allow all;
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|zip|gz|tar)$ {
log_not_found off;
access_log off;
expires max;
}
location / {
try_files $uri $uri/ @memcache;
}
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
location ~* /(fpm.www.status|fpm.www.ping)$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param QUERY_STRING $args;
}
location ~ \.php$ {
try_files $uri @memcache;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param QUERY_STRING $args;
}
# Keeping this in by default. It will _always_ fail for 127.0.0.1 since
# there is no local memcache server. This might change for the default
# setup in the future, but for now it's essentially a redirect to @rewrite
location @memcache {
default_type text/html;
set $memcached_key data-$scheme://$host$request_uri;
memcached_pass 127.0.0.1:11211;
error_page 404 = @rewrite;
}
location @rewrite {
index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
fastcgi_intercept_errors on;
fastcgi_hide_header 'X-Generator';
fastcgi_read_timeout 14400;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_param SCRIPT_NAME /index.php;
fastcgi_param QUERY_STRING $args;
}
}
WWW.CONF for PHP5-fpm
; -------------------------------------------------------------------- ;
; first pool
; -------------------------------------------------------------------- ;
[www]
user = www-data
group = www-data
listen = /var/run/php5-fpm.sock
#listen.allowed_clients = /var/run/php5-fpm.sock
request_slowlog_timeout = 10s
slowlog = /mnt/logs/php-fpm/$pool.slowlog.log
pm = dynamic
pm.max_children = 100
pm.start_servers = 4
pm.min_spare_servers = 4
pm.max_spare_servers = 15
pm.max_requests = 5000
listen.backlog = -1
listen.mode = 0666
; http://url/status
; http://url/status?json
; http://url/status?html
pm.status_path = /fpm.$pool.status
ping.path = /fpm.$pool.ping
ping.response = "pong. $pool OK"
request_terminate_timeout = 120s
rlimit_files = 131072
rlimit_core = unlimited
catch_workers_output = no
php_admin_value[error_log] = /mnt/php5/php-error.log
; this is untested will do this on a later update
env[HOSTNAME] = $HOSTNAME
env[PATH] = $PATH
env[TMP] = /mnt/tmp
env[TMPDIR] = /mnt/tmp
env[TEMP] = /mnt/tmp
最后我收到的错误日志:
2014/08/05 18:23:44 [error] 25991#0: *9 connect() failed (111: Connection refused) while connecting to upstream, client: 99.243.124.199, server: localhost, request: "GET /contact-us/ HTTP/1.0", upstream: "memcached://127.0.0.1:11211", host: "107.150.29.134", referrer: "http://107.150.29.134/
“