wordpress - 使用 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;
}
}
解决方案
我的 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 值
推荐阅读
- sql-server - 如何按升序将 NULL 放在最后
- linux - docker build 无法连接到 http 服务器,即使它可以在命令行上访问
- spring-mvc - 使用 LDAP 和组成员身份的 Spring 安全性
- android - 使用 Firebase 的推荐系统
- reactjs - 您如何称呼酶中的外部功能?
- java - 如何在Java中制作json对象
- java - 基于Java中的给定模式对字符串数组进行排序
- python-3.x - 单击使用烧瓶提交后,如何将文件保存在不同的目录中?
- ios - 在 Swift 4 中使用动画在 UITableView 中添加一行
- php - 从 SQL 转换 time() 以获取每月销售 PHP