使用Nginx设置Wordpress与Magento

7rtdyuoh  于 2022-11-12  发布在  Nginx
关注(0)|答案(2)|浏览(163)

我有一个Magento 2安装在/var/www/html/文件夹中使用mydomain.com,我添加了一个WordPress在/var/www/html/pub/wp/文件夹中使用mydomain.com/wp/当我试图访问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;
  }
}
wooyq4lh

wooyq4lh1#

您已经在pub/wp安装了WordPress,但是您的Nginx配置只引用了/wp/。请修改您的Nginx配置以引用/pub/wp/,或者将WordPress移到根目录(例如/wp/)。
https://fishpig.co.uk/magento/wordpress-integration/nginx/

upstream fastcgi_backend {
  server  127.0.0.1:9000;
}

server {
  listen 80;

  # Magento 2 base URL
  server_name m2.latest.composer.fp.com;

  # Magento 2 root directory
  set $MAGE_ROOT /home/magento2/html;

  set $MAGE_DEBUG_SHOW_ARGS 1;

  include /home/magento2/html/nginx.conf.sample;

  # WordPress is installed in pub/wp
  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;
    }
  }
}
5sxhfpxr

5sxhfpxr2#

我的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表中的站点URL和主页值

相关问题