【发布时间】:2017-04-18 17:15:08
【问题描述】:
我正在尝试使用 Nginx 在三个不同的目录中托管三个单独的 WordPress 站点。经过数小时的研究,我完全找不到允许我访问/wp-admin 和网站上各个页面的配置。
这是我目前拥有的:
server {
listen 80;
listen [::]:80 ipv6only=on;
root /var/www;
server_name my.ip.add.ress;
location /wp1 {
root /var/www/wp1;
index index.php index.html index.htm;
try_files $uri $uri/ /wp1/index.php?q=$args;
}
location /wp2 {
root /var/www/wp2;
index index.php index.html index.htm;
try_files $uri $uri/ /wp2/index.php?q=$args;
}
location /wp3 {
root /var/www/wp3;
index index.php index.html index.htm;
try_files $uri $uri/ /wp3/index.php?q=$args;
}
if (!-e $request_filename) {
rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
rewrite ^/[_0-9a-zA-Z-]+.*(/wp-admin/.*\.php)$ $1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_cache moodle;
fastcgi_cache_valid 200 60m;
fastcgi_read_timeout 3600;
}
# Cache static content
location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}
}
当我尝试访问 /wp-admin 时,我的浏览器卡在了重定向循环中。使用 rewrite_log 不会产生任何输出。
【问题讨论】: