我使用的是Drupal 8,具有多站点设置,位于"/var/www/html/drupal“目录下,我使用NGINX作为web服务器。
我有以下域名:
其中"qa.example.com“是提供静态文件的主要域(index.html中包含一些信息)。v1和v2是使用Drupal 8多站点创建的动态站点.
因为qa.example.com只有一个静态文件,所以我将它放在Drupal目录中,并将虚拟主机指向"/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 nginx”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“。
以下是我提到的链接:
发布于 2018-12-16 09:52:50
当您正在进行多站点设置时,我将建议您在站点目录中创建带有域名的目录,并按下面的方式输入sites.php。
$sites[directoy name] = 'domain name';对于每个站点,您需要在sites.php中进行输入。每个域都应该有settings.php。
https://stackoverflow.com/questions/53783109
复制相似问题