2016-05-09 66 views
1

嗨我有一个运行wp的Nginx服务器没有问题。我只是在空白html5中创建了一个站点,并添加了一些使用php的功能。然后我的客户也决定写一个博客。所以我将Wordpress安装到了一个子目录中。我唯一的问题是我不能弄明白的Nginx配置。我在example.com/上有该网站,wp位于example.com/wp/site/上,但即使我已正确配置所有内容,但我的管理面板仍无法使用。所以我分享我的代码,我非常感谢一些帮助。我在网上发现了类似的文章,但他们根本没有帮助。所以请看看我的Nginx cfg为这个网站,并告诉我什么是错的。谢谢!WordPress的子目录nginx

server { 
    server_name domain.com; 
    listen 80; 
    root /var/www/domain; 
    include wordpress.conf; 

location/{ 
index index.php index.html index.htm; 
} 

    # Block PHP files in uploads directory. 
    location ~* /wp/acc/wp-content/uploads/.*\.php$ { 
    deny all; 
    } 
    location ~ ^/\.user\.ini { 
    deny all; 
    } 
    location /wp/acc { 
    limit_except GET POST OPTIONS HEAD { deny all; } 
    try_files $uri $uri/ /wp/acc/index.php?$args; 
    } 
location ~ \.php$ { 
fastcgi_split_path_info ^(.+\.php)(/.+)$; 
fastcgi_pass unix:/var/run/php5-fpm.sock; 
fastcgi_index index.php; 
include fastcgi_params; 
} 
} 
server { 
    server_name domain.com; 
    listen 81; 
    root /var/www/domain; 
index index.php index.html index.htm; 
    include wordpress7080.conf; 

location/{ 
index index.php index.html index.htm; 
} 

    # Block PHP files in uploads directory. 
    location ~* /wp/acc/wp-content/uploads/.*\.php$ { 
    deny all; 
    } 
    location ~ ^/\.user\.ini { 
    deny all; 
    } 
    location/{ 
    limit_except GET POST OPTIONS HEAD { deny all; } 
    try_files $uri $uri/ /wp/acc/index.php?$args; 
    } 
location ~ \.php$ { 
fastcgi_split_path_info ^(.+\.php)(/.+)$; 
fastcgi_pass unix:/var/run/php5-fpm.sock; 
fastcgi_index index.php; 
include fastcgi_params; 
} 
} 

附加信息:

WP-config.php文件没有被修改。 网址在数据库中是正确的。 wordpress.conf只包含nginx的基本wordpress设置。

+0

我不是一个wordpress开发者,但我想你说的是第二个虚拟主机在端口81上侦听,你有没有在防火墙中启用它?如果您的server_name在这两个站点之间有所不同,那么您可以让他们两个都在端口80上侦听。 – MMT

回答

0

你必须改变根语句每个的WordPress目录中的服务器{}代码块

root /var/www/wp1; 
root /var/www/wp2; 

此外,您还可以在

/var/log/nginx/error* 
/var/log/nginx/access* 

联系,以获得更多的信息事情如何运作。

+0

这是否适合您? – CareFree

+0

我使用了不同的解决方案,但这也会对我有所帮助。谢谢! – e102Rp