问题解决了
我想安装 wordpress osx。
这些是我所做的。
$ brew install nginx
$ brew install --without-apache --with-fpm --with-mysql php55
- 下载最新的 wordpress.zip 并解压到 /var/www/wordpress_test
- 通过运行 php-fpm
php-fpm -g /usr/local/var/run/php-fpm.pid
- 像这样编写 nginx 配置文件。
/usr/local/etc/nginx/nginx.conf
worker_processes 1;
error_log /usr/local/log/nginx/error.log;
pid /usr/local/var/run/nginx.pid;
events {
worker_connections 256;
}
http {
include /usr/local/etc/nginx/mime.types;
default_type application/octet-stream;
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 /usr/local/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
#gzip on;
include /usr/local/etc/nginx/site-enabled/*;
}
/usr/local/etc/nginx/site-avaiable/wordpress_test
server {
listen 8080;
server_name localhost;
access_log /usr/local/log/nginx/wordpress_test.access.log;
error_log /usr/local/log/nginx/wordpress_test.error.log;
root /var/www/wordpress_test;
index index.html index.htm index.php;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass 127.0.0.1:9000;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
location ~ /\.ht {
deny all;
}
}
- 创建
/usr/local/nginx/site-available/wordpress_test
到 `usr/local/nginx/site-enabled/wordpress_test 的符号链接 /var/www/wordpress_test/info.php
在里面创建和写<?php phpinfo(); ?>
。
我可以通过访问来查看 php 信息http://localhost:8080/info.php
。但是当我访问时收到错误消息http://localhost:8080/index.php
。
/usr/local/log/nginx/wordpress_test.error.log
不放任何消息。并/usr/local/log/nginx/wordpress_test.access.log
显示此消息。
127.0.0.1 - - [23/Sep/2013:17:21:55 +0900] "GET /index.php HTTP/1.1" 500 537 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36"
我怎么解决这个问题?接下来我应该检查什么?
- 我从http://codex.wordpress.org/Nginx添加这样的设置,然后它就可以工作了。
# WordPress single blog rules.
# Designed to be included in any server {} block.
# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule
location / {
try_files $uri $uri/ /index.php?$args;
}
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
# Directives to send expires headers and turn off 404 error logging.
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off; log_not_found off; expires max;
}
# Uncomment one of the lines below for the appropriate caching plugin (if used).
#include global/wordpress-wp-super-cache.conf;
#include global/wordpress-w3-total-cache.conf;
# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ \.php$ {
# Zero-day exploit defense.
# http://forum.nginx.org/read.php?2,88845,page=3
# Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
# Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine. And then cross your fingers that you won't get hacked.
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_intercept_errors on;
fastcgi_pass php;
}