【问题标题】:Wordpress in subdirectory nginx子目录 nginx 中的 Wordpress
【发布时间】:2016-05-10 22:56:51
【问题描述】:

您好,我有一个运行 wp 的 Nginx 服务器,没有问题。我刚刚在空白 html5 中创建了一个站点,并使用 php 添加了一些功能。然后我的客户决定也有一个博客。所以我将 Wordpress 安装到一个子目录中。我唯一的问题是我无法弄清楚的 Nginx 配置。我在 example.com/ 上有网站,wp 在 example.com/wp/site/ 但即使我已正确配置所有内容,我的管理面板也无法正常工作。所以我分享我的代码,我非常感谢一些帮助。我在网上找到了类似的文章,但它们根本没有帮助。所以请看一下我的 Nginx cfg 这个网站,告诉我哪里出了问题。谢谢!

    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 未被修改。 数据库中的 URL 是正确的。 Wordpress.conf 仅包含 nginx 的基本 wordpress 设置。

【问题讨论】:

  • 我不是 wordpress 开发人员,但我猜你说的是第二个监听端口 81 的虚拟主机,你在防火墙中启用了吗?如果这两个站点之间的 server_name 不同,那么您可以让它们都监听端口 80。

标签: php wordpress nginx server


【解决方案1】:

你必须将根语句更改为服务器{}代码块中每个wordpress的目录

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

另外,您可以检查您的

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

以获取有关事情如何运作的更多信息。

【讨论】:

  • 我使用了不同的解决方案,但这对我也有帮助。谢谢!
猜你喜欢
  • 1970-01-01
  • 2016-03-24
  • 1970-01-01
  • 2016-11-03
  • 2015-12-15
  • 2023-04-06
  • 2014-12-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多