首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NIGNX中带有子目录的Drupal多站点设置

NIGNX中带有子目录的Drupal多站点设置
EN

Stack Overflow用户
提问于 2018-12-14 16:00:47
回答 1查看 1.1K关注 0票数 1

我使用的是Drupal 8,具有多站点设置,位于"/var/www/html/drupal“目录下,我使用NGINX作为web服务器。

我有以下域名:

  1. qa.example.com
  2. qa.example.com/v1
  3. qa.example.com/v2

其中"qa.example.com“是提供静态文件的主要域(index.html中包含一些信息)。v1和v2是使用Drupal 8多站点创建的动态站点.

因为qa.example.com只有一个静态文件,所以我将它放在Drupal目录中,并将虚拟主机指向"/var/www/html/drupal“目录。根据examples.sites.php提供的文档,我在sites.php中添加了站点条目,如下所示:

代码语言:javascript
复制
<?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配置:

代码语言:javascript
复制
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;
  }
}

下面是我的目录结构:

代码语言:javascript
复制
// 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

我在网上查过很多参考资料,但都没有用。

注意:v1v2不是实际目录"/var/www/html/drupal“。

以下是我提到的链接:

  1. 子文件夹中的nginx项目
  2. Nginx位置配置(子文件夹)
  3. 多站点与两个站点共享相同的域?
  4. Nginx子目录中的PHP应用程序
EN

回答 1

Stack Overflow用户

发布于 2018-12-16 09:52:50

当您正在进行多站点设置时,我将建议您在站点目录中创建带有域名的目录,并按下面的方式输入sites.php。

代码语言:javascript
复制
$sites[directoy name] = 'domain name';

对于每个站点,您需要在sites.php中进行输入。每个域都应该有settings.php。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53783109

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档