首页 > 解决方案 > 使用 Nginx 使用 Magento 设置 Wordpress

问题描述

我使用 mydomain.com 在 /var/www/html/ 文件夹中安装了一个 Magento 2,并使用 mydomain.com/wp/ 在 /var/www/html/pub/wp/ 文件夹中添加了一个 Wordpress 当我尝试访问 mydomain .com/wp/readme.html 它工作正常,但所有 php 文件都无法访问,所以我无法连接到管理员 mydomain.com/wp/wp-login.php 并查看我的 Wordpress。

我将此添加到我的 nginx 配置中,但它不起作用:

location /wp/ {
  index index.html index.php;
  try_files $uri $uri/ /wp/index.php?q=$uri&args;

  location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  /wp/index.php;
    include        fastcgi.conf;
  }
}

标签: wordpressmagentofishpig

解决方案


我的 magento 项目安装在 docker 上。我的 WP 站点安装在 pub/wp/ 中。安装时我使用了这个文档https://fishpig.co.uk/magento/wordpress-integration/docs/

我遇到了同样的问题。

我通过将 fastcgi_pass 值更改为我的 docker 容器(fastcgi_backend)中使用的值来解决此问题:

location /wp/ {
index index.html index.php;
try_files $uri $uri/ /wp/index.php$is_args$args;
location ~ \.php$ {
    fastcgi_pass   fastcgi_backend;
    fastcgi_index  /wp/index.php;
    include        fastcgi.conf;
}

之后,您需要更改 wp_options 表中的 siteurl 和 home 值


推荐阅读