快轉到主要內容

Install Drupal 9 Multi-site in subdirectories

·361 字·2 分鐘
Y Cheung
作者
Y Cheung
Blogger, Programer & Traveler.
目錄

Instantiate master site
#

1.1: Create a database for the multisite root site, ex: drupal-dev.

1.2: Create Drupal 9 project via Composer.

1cd /var/www
2composer create-project drupal/recommended-project drupal_root_dir

1.3: Add Drush in your Drupal 9 project.

1cd /var/www/drupal_root_dir
2composer require drush/drush

1.4: Install Drupal 9 master site using the Drush command line

1cd /var/www/drupal_root_dir/web
2drush site:install

or

1cd /var/www/drupal_root_dir/web
2drush si

1.5: Create a virtual host definition for the master site.

 1# File: /etc/apache2/sites-available/drupal_multisite.conf
 2
 3<VirtualHost *:80>
 4
 5  # virtual host configuration for Drupal 8 multisite
 6
 7  ServerAdmin [email protected]
 8  DocumentRoot /var/www/drupal_root_dir/web
 9  ServerName example.com
10  ServerAlias www.example.com
11    
12  <Directory /var/www/drupal_root_dir/web>
13    Options Indexes FollowSymLinks MultiViews
14    AllowOverride All
15    Order allow,deny
16    Allow from all
17  </Directory>
18
19  ErrorLog ${APACHE_LOG_DIR}/drupal_error.log
20  LogLevel warn
21  CustomLog ${APACHE_LOG_DIR}/drupal_access.log combined
22
23</VirtualHost>

1.6: Browse the website to make sure all settings are correct.

Configure the first multisite site
#

2.1: Create a database for the multisite site 1, ex: drupal-dev-site-1.

2.2: Install Drupal 9 multisite 1 via Drush command line

1cd /var/www/drupal_root_dir/web
2drush si --sites-subdir=site1

2.3: Create symlink to multisite 1

1cd /var/www/drupal_root_dir/web
2ln -s . default
3ln -s . site1

2.4: Make a copy of /var/www/drupal_root_dir/web/sites/example.sites.php called /var/www/drupal_root_dir/web/sites/sites.php.

2.5: Edit sites.php, so the end of the file looks like this:

1$sites = [
2  'localhost' => 'default',
3  'localhost.site1' => 'site1',
4];

2.6: Create drush site alias via /var/www/drupal_root_dir/drush/sites/self.site.yml , so that you can use drush per site like drush @alias [command]

1# File: self.site.yml
2default:
3  root: /var/www/drupal_root_dir/web
4  uri: http://localhost
5site1:
6  root: /var/www/drupal_root_dir/web
7  uri: http://localhost/site1

2.7: Run drush sa command to make sure site alias.

2.8: To avoid symlink infinite, add the following to the /var/www/drupal-root-dir/web/.htaccesss file.

1# ref. https://www.drupal.org/docs/7/multisite-drupal/multi-site-in-subdirectories#s-avoid-infinite-symlink-recursion
2  RedirectMatch 301 /(default|site1)/(default|site1)/(.*) /$1/$3

Step 3: Import default configs (optional)

1cd /var/www/drupal_root_dir/web
2drush @self.site1 config-set "system.site" uuid 64cf0233-39b3-4bf2-bdae-f6e9eaf8a5e5 -y
3drush @self.site1 entity:delete shortcut_set -y
4drush @self.site1 cim --source=../web/sites/default/config -y

References
#

Not so useful, but … just note.

相關文章

drupal8 dursh config-import使用簡介

·285 字·1 分鐘
GIT CLONE 代碼 正常流程 stander 安裝drupal8 修改/sites/default/settings.php 指定 config 文件夾位置 1$config_directories['sync'] = 'sites/config/sync'; 執行drush命令導入config 1drush config-import 提示報錯:

在DRUPAL 7自定義多行表格表單中設置添加行按鈕與刪除行按鈕

·1506 字·4 分鐘
標題有點拗口,YCHEUNG也想不出來更好的中文表達,沒懂的朋友直接看內文吧(或者看url的英文標題)。 這種功能的表格表單YCHEUNG已經嘗試了五六種方式來寫,但都不滿意。不然就是功能上多少有缺陷,比如無法使用drupal 7 form API的日期type,不然就是很繁瑣的一堆代碼和判斷,看着都頭暈……等,今天終於試出了一個令YCHEUNG較滿意的寫法!分享給大家,也是一種記錄,YCHEUNG有預感,之後還會寫很多個這樣的表單QAQ

drupal 7中操作遠程oracle數據庫

·584 字·2 分鐘
系統環境需求 # PHP環境最好是 PHP 7,系統最好是紅帽系。 操作步驟 # 安裝Oracle Instant Client # 在Oracle官網頁面中找到系統對應的客戶端下載安裝,比如Y CHEUNG選擇的就是 Instant Client Downloads for Linux x86-64 ,Fedora可以下載RPM包直接安裝,非RedHat系統的可能需要先編譯,用make install的方式安裝。

Drupal7中自定义表格输入

·1240 字·3 分鐘
Drupal默认的节点表单(entity form)输入有时候并不能满足我们的需求,比如我想做一个类似excel表格输入形式的表单呢? = DEMO点这里 (PS. 用Pantheon的sandbox做了一个随意折腾的drupal站点,真的是折腾死我了= =) 首先,新建一个自定义模块,在你的*.module文件中hook_menu() 指定一个页面路径,设置页面调用表单,比如这样:

Drupal7 中Restful模组应用简单介绍

·1918 字·4 分鐘
安装并启用Restful Module # Restful 2.x 下载 drush 安装 drush dl restful, drush en restful 自定义RESTFUL API模组 # 可参考restful里的范例 sites/all/modules/restful/modules/restful_example 或者测试文件内容 sites/all/modules/restful/tests 模组文件结构 # 1custom_restfulapi/ 2├─ src/ 3│ ├─ Plugin/ 4│ │ ├─ resource/ 5│ │ │ ├─ entity/ 6│ │ │ │ ├─ Testentity__1_0.php 7├─ custom_restfulapi.info 8├─ custom_restfulapi.module API RESOURCES要放在src/Plugin下。 *.info 和 *.module 的内容跟其他自定义模组的相差无几,方法一样,此处从略。