我正在尝试配置wordpress,当我想使用示例或我自己的页面时,我来到了这一步。不幸的是,似乎我没有正确配置nginx但我似乎无法找到如何。要么是旧的,要么与我的nginx版本无关(1.2.1-2.2 + wheezy2)或者只是不完整。有人可以提供一个示例nginx wordpress配置或只是告诉我以下哪个是最正确的让它工作?
location /wordpress {
try_files $uri $uri/ /etc/wordpress/index.php?$args;
}
或
location /wp/wp-content/ {
alias /usr/share/wordpress/wp-content/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}
或其他什么?
答案 0 :(得分:0)
这是我在本地mac上用于本地开发的nginx conf文件,以防它有用:
user matt staff;
worker_processes 4;
events {
worker_connections 768;
}
http {
client_max_body_size 100M;
include mime.types;
types_hash_max_size 2048;
default_type text/plain;
server_tokens off;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
index index.html index.php;
log_format main '[$time_local]: $domain - "$request" '
'status:$status bytes:$body_bytes_sent "$http_referer" ';
access_log /Users/matt/Library/Logs/nginx/access.log main;
error_log /Users/matt/Library/Logs/nginx/error.log;
upstream www-upstream-pool {
server unix:/var/run/php5-fpm.sock;
}
server {
listen 80;
server_name ~^(?:(?<subdomain>\w*)\.)?(?<domain>\w+)\.wp$;
set $basepath "/Users/matt/pls-sites";
set $rootpath "${domain}";
if ($domain ~ 'wordpress'){
set $rootpath "wordpress/httpdocs/web";
}
root $basepath/$rootpath;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$args; # /index.html;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location ~ .php$ {
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass www-upstream-pool;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_read_timeout 300;
}
}
}