我最近升级到php 5.3的使用php-fpm的目的。 我所有的网站正在工作,除了默认的一个showimg空白页面。 在nginx.conf中定义如下。 什么是这个configuration的问题。 错误日志似乎没有任何报告。
user nginx; worker_processes 1; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; events { worker_connections 2048; } http { include /etc/nginx/mime.types; default_type application/octet-stream; index index.html index.htm index.php; log_format main '$remote_addr - $remote_user [$time_local] $request ' '"$status" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; keepalive_timeout 65; client_max_body_size 4M; server { listen 80; server_name mysite.net.au 111.118.171.66; root /usr/share/nginx/html; location ~* ^.+\.(xml|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf)$ { rewrite ^/files(/.*)$ /wp-content/blogs.php?file=$1 last; access_log off; expires max; break; } location / { if (!-e $request_filename) { rewrite ^.+/?(/wp-.*) $1 last; rewrite ^.+/?(/.*\.php)$ $1 last; rewrite ^(.+)$ /index.php?q=$1 last; } } error_page 404 /404.html; location = /404.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } location ~ \.php$ { #rewrite ^/.*(/wp-.*/.*.php)$ $1; fastcgi_pass php; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; } } server { server_name www.mysite.net.au; rewrite ^/(.*) http://mysite.net.au/$1 permanent; } include /etc/nginx/conf.d/*.conf; }
将位置/块中的重写规则更改为:
location / { try_files $uri $uri/ /index.php?$args; }
为了解决安全漏洞,请将其添加到〜.php块的第一行
try_files $uri =404;