[英]Drupal Multi-Site setup with sub-directory in NIGNX
I'm using Drupal 8, with multi-site setup, located at "/var/www/html/drupal" directory and I'm using NGINX as web-server. 我正在使用位于“ / var / www / html / drupal”目录中的具有多站点设置的Drupal 8,并且正在将NGINX用作Web服务器。
I've following domain names : 我正在关注域名:
Where "qa.example.com" is main domain serving static file (index.html with some info in it). 其中“ qa.example.com”是服务静态文件(其中包含一些信息的index.html)的主域。 And v1 and v2 are dynamic sites created using Drupal 8 Multi-site.
v1和v2是使用Drupal 8 Multi-site创建的动态站点。
Since qa.example.com has only 1 static file, I've placed it in Drupal Core directory and pointed virtual host to "/var/www/html/drupal" directory. 由于qa.example.com只有1个静态文件,因此我将其放置在Drupal Core目录中,并将虚拟主机指向“ / var / www / html / drupal”目录。 As per documentation available in examples.sites.php, I've added sites entry in sites.php as below:
根据examples.sites.php中可用的文档,我在sites.php中添加了site条目,如下所示:
<?php
$sites['qa.example.com.v1'] = 'v1.example.com';
$sites['qa.example.com.v2'] = 'v2.example.com';
When accessing "qa.example.com" it works fine as it has only single index.html file, but when accessing "qa.example.com/v1", I'm being redirected to "qa.example.com/core/install.php" or receiving "404 Not Found" nginx page. 访问“ qa.example.com”时,它只有一个index.html文件,因此可以正常工作,但是访问“ qa.example.com/v1”时,我被重定向到“ qa.example.com/core/ install.php”或收到“ 404未找到” nginx页面。 I'm not understanding what I'm missing.
我不明白我所缺少的。
Following is NGINX config I'm using : 以下是我正在使用的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;
}
}
Following is the directory structure I've: 以下是我拥有的目录结构:
// 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
I've looked into many references online, but nothing is working. 我在网上查阅了许多参考资料,但没有任何效果。
NOTE : v1 and v2 are not actual directory "/var/www/html/drupal". 注意: v1和v2不是实际目录“ / var / www / html / drupal”。
Following are links which I've referred : 以下是我已提及的链接:
As you are working on multisite setup so i will suggest you, create directory with domain name in sites directory and make entry to sites.php like below. 当您在进行多站点设置时,我将建议您在站点目录中创建具有域名的目录,并像以下所示进入sites.php。
$sites[directoy name] = 'domain name';
For each site you need to make entry in sites.php. 对于每个站点,您都需要在sites.php中进行输入。 Each domain should have settings.php.
每个域都应具有settings.php。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.