php - Drupal 多站点设置与 NIGNX 中的子目录
问题描述
我正在使用带有多站点设置的 Drupal 8,位于“/var/www/html/drupal”目录中,并且我使用 NGINX 作为 Web 服务器。
我有以下域名:
- qa.example.com
- qa.example.com/v1
- qa.example.com/v2
其中“qa.example.com”是提供静态文件的主要域(index.html 中包含一些信息)。v1 和 v2 是使用 Drupal 8 Multi-site 创建的动态站点。
由于 qa.example.com 只有 1 个静态文件,我将它放在 Drupal Core 目录中,并将虚拟主机指向“/var/www/html/drupal”目录。根据examples.sites.php中提供的文档,我在sites.php中添加了站点条目,如下所示:
<?php
$sites['qa.example.com.v1'] = 'v1.example.com';
$sites['qa.example.com.v2'] = 'v2.example.com';
访问“qa.example.com”时它工作正常,因为它只有一个 index.html 文件,但访问“qa.example.com/v1”时,我被重定向到“qa.example.com/core/ install.php”或收到“404 Not Found”nginx 页面。我不明白我错过了什么。
以下是我正在使用的 NGINX 配置:
server {
server_name qa.example.com;
listen 80;
listen [::]:80;
index index.php index.html;
location / {
root /var/www/html/drupal;
try_files $uri /index.php?$query_string;
}
location /v1 {
root /var/www/html/drupal;
# try_files $uri $uri/ /var/www/html/drupal/index.php?$query_string;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ \..*/.*\.php$ {
return 403;
}
location ~ ^/sites/.*/private/ {
return 403;
}
location ~ (^|/)\. {
return 403;
}
location @rewrite {
rewrite ^/(.*)$ /index.php?q=$1;
}
location ~ '\.php$|^/update.php' {
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
include fastcgi_params;
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_intercept_errors on;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ ^/sites/.*/files/styles/ {
try_files $uri @rewrite;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
以下是我的目录结构:
// main directory
/var/www/html/drupal
// my static file for landing domain name
/var/www/html/drupal/index.html
// drupal core files
/var/www/html/drupal/core
// drupal's index.php file
/var/www/html/drupal/index.php
// contrib and custom modules
/var/www/html/drupal/modules
// Site v1 directory as per Drupal's multi-site directory structure.
/var/www/html/drupal/sites/v1
// Site v2 directory as per Drupal's multi-site directory structure.
/var/www/html/drupal/sites/v2
我在网上查看了许多参考资料,但没有任何效果。
注意:v1和v2不是实际目录“/var/www/html/drupal”。
以下是我提到的链接:
解决方案
由于您正在处理多站点设置,所以我建议您在站点目录中创建带有域名的目录,然后像下面那样进入 sites.php。
$sites[directoy name] = 'domain name';
对于每个站点,您需要在sites.php 中进行条目。每个域都应该有 settings.php。
推荐阅读
- javascript - Videojs requestPictureInPicture() 在滚动到顶部和底部时仅工作一次
- swift - 与 swift webview 应用程序目标 _blank 的链接不起作用
- mongodb - MongoDB Charts – 使用多个组属性绘制累积增长图表?
- assembly - 从反编译的 ASM 中获取信息
- javascript - 当我调整一张床单的窗口大小时,我的汉堡包按钮不起作用。但它确实适用于我的第一张纸(或首页)
- python - 在Python中按排序顺序打印嵌套字典的键
- python - 如何让 PyTorch Conv1d 在矢量上工作?
- git - 将过去的提交移动到另一个分支
- angular - Angular 8 - 如何模拟从服务返回的主题
- android - Room:无法访问主线程上的数据库 *但是*