我们有2个项目。 https://host/ -第一(在Node.js上), https://host/modules/ -第二(在WP上)。在此之前,nginx一直是反向代理。当我进入“模块”页面时,一切都很好,但是当我进入 https://host/modules/wp-admin/ 时,URL变为 https://host/wp-admin ,并在其中链接菜单也失去前缀/ modules /。正确的链接在某个地方。那里发生了什么事,我应该何时挖掘?
我也尝试了.htaccess设置:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /modules/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /modules/index.php [L]
</IfModule>
但是没有结果。设置 siteurl 和 home 是 https://host/modules/ 。拜托,我祈祷能得到一些建议。
答案 0 :(得分:0)
我通过Docker,nginx和wordpress:*-php * -fpm容器(wp也需要mysql)解决了这个问题。
文件夹结构:
nginx_data
- wordpress.conf
wp
- modules
有我的docker-compose.yml:
version: '3'
services:
nginx:
image: nginx
restart: always
ports:
- 80:80
volumes:
- ./nginx_data:/etc/nginx/conf.d
- ./wp:/var/www/html
modules:
image: wordpress:4.9-php7.1-fpm-alpine
volumes:
- ./wp/modules:/var/www/html/modules
environment:
WORDPRESS_DB_HOST: mysql
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: root
restart: always
depends_on:
- mysql
mysql:
image: mysql
restart: always
ports:
- 3306:3306
volumes:
- ./mysql_data:/var/lib/mysql
environment:
MYSQL_DATABASE: wordpress
MYSQL_ROOT_PASSWORD: root
nginx.conf:
server {
listen 80;
root /var/www/html;
index index.php;
location / {
proxy_pass https://some_host;
}
location /modules {
try_files $uri $uri/ /modules/index.php?q=$uri&$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass modules:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
还有一个重要时刻::您必须将wp容器中的文件从/var/www/html
移到/var/www/html/modules
!!