LoginSignup
2
1

More than 1 year has passed since last update.

LandoでDrupal9インストール

Last updated at Posted at 2020-08-12

※2ヶ月前の記録簿をざっくり編集しましたので共有しておきます。

6月3日にDrupal9がリリースされました。
ローカル環境でインストールをしたらphp7.3を要求されてインストール出来なかったので数秒間放心した。

新しい環境を求めて調べたら最近のDrupal開発環境はLandoが使われていることが多いと分かったので早速Landoをインストールしてみた。

LandoはDockerやDocker-composeを利用しますので事前にインストールしておきます。

Lando本体インストール

OS別にdmgなりexeのインストール。
今回はlando-v3.0.9で検証。
https://github.com/lando/lando/releases/

Drupal 9 Example

Lando初回インストール

インストールするディレクトリを作成して実行。特に指定しない場合はdrupal/legacy-projectでインストールされます。初回だけ少しかなり時間が掛かります・・・。

command
$ rm -rf drupal9 && mkdir -p drupal9 && cd drupal9
$ lando init --source remote --remote-url https://www.drupal.org/download-latest/tar.gz --remote-options="--strip-components 1" --recipe drupal9 --webroot . --name lando-drupal9
略
Extracted /tmp/source/tar.gz to /app
Killing landoinitlandodrupal9_init_1 ... done
Going to remove landoinitlandodrupal9_init_1
Removing landoinitlandodrupal9_init_1 ... done
   _  __                       _         
  / |/ /__ _    __  _    _____( )_______ 
 /    / _ \ |/|/ / | |/|/ / -_)// __/ -_)
/_/|_/\___/__,__/  |__,__/\__/ /_/  \__/               
  _________  ____  __ _______  _______  _      ______________ __  ___________  ______
 / ___/ __ \/ __ \/ //_/  _/ |/ / ___/ | | /| / /  _/_  __/ // / / __/  _/ _ \/ __/ /
/ /__/ /_/ / /_/ / ,< _/ //    / (_ /  | |/ |/ // /  / / / _  / / _/_/ // , _/ _//_/ 
\___/\____/\____/_/|_/___/_/|_/\___/   |__/|__/___/ /_/ /_//_/ /_/ /___/_/|_/___(_)  

Your app has been initialized!
Go to the directory where your app was initialized and run lando start to get rolling.
Check the LOCATION printed below if you are unsure where to go.
Oh... and here are some vitals:

 NAME      lando-drupal9                              
 LOCATION  /Users/*******/lando/drupal9                  
 RECIPE    drupal9                                    
 DOCS      https://docs.lando.dev/config/drupal9.html 

Lando起動

$ lando start

Let's get this party started! Starting app lando-drupal9...
WARN ==> May need site-local drush 
Starting landoproxyhyperion5000gandalfedition_proxy_1 ... done
Starting landodrupal9_database_1  ... done
Starting landodrupal9_appserver_1 ... done
Scanning to determine which services are ready... Please standby...
  _      __              _           __
 | | /| / /__ ________  (_)__  ___ _/ /
 | |/ |/ / _ `/ __/ _ \/ / _ \/ _ `/_/ 
 |__/|__/\_,_/_/ /_//_/_/_//_/\_, (_)  
                             /___/     

Your app started up but we detected some things you may wish to investigate.
These only may be a problem.

 ■ May need site-local drush
   Lando has detected you are trying to globally install drush ^10
   This version of drush prefers a site-local installation
   We recommend you install drush that way, see:
   https://docs.drush.org/en/master/install/

Here are some vitals:

 NAME            lando-drupal9                    
 LOCATION        /Users/*******/land/drupal7/drupal9 
 SERVICES        appserver, database              
 APPSERVER URLS  https://localhost:32798          
                 http://localhost:32799           
                 http://lando-drupal9.lndo.site/  
                 https://lando-drupal9.lndo.site/

サーバが2台(webとDB)立ち上がりました。
APPSERVER URLSのURLをクリックすると、ブラウザでアクセス出来ます。

サイトの確認

MysqlをなどDB名等の状態など確認したい場合、lando infoで諸々確認します。
実行するとcredsの箇所を見るとDBのdb名・ユーザー名・パスワードは「drupal9」が、DBのホスト名が「database」を使います。

$ lando info
  __  __        __     __        ___            _ __     __   __    ______
 / / / /__  ___/ /__ _/ /____   / _ |_  _____ _(_) /__ _/ /  / /__ / / / /
/ /_/ / _ \/ _  / _ `/ __/ -_) / __ | |/ / _ `/ / / _ `/ _ \/ / -_)_/_/_/ 
\____/ .__/\_,_/\_,_/\__/\__/ /_/ |_|___/\_,_/_/_/\_,_/_.__/_/\__(_|_|_)  
    /_/                                                                   

Updating helps us provide the best support and saves us tons of time

Use the link below to get the latest and greatest
https://github.com/lando/lando/releases/tag/v3.0.9

Lando is FREE and OPEN SOURCE software that relies on contributions from developers like you!
If you like Lando then help us spend more time making, updating and supporting it by contributing at the link below
https://github.com/sponsors/lando

WARN ==> May need site-local drush 
[ { service: 'appserver',
    urls:
     [ 'https://localhost:32773',
       'http://localhost:32774',
       'http://lando-drupal9.lndo.site/',
       'https://lando-drupal9.lndo.site/' ],
    type: 'php',
    healthy: true,
    via: 'apache',
    webroot: '.',
    config: { php: '/Users/*******/.lando/config/drupal9/php.ini' },
    version: '7.4',
    meUser: 'www-data',
    hasCerts: true,
    hostnames: [ 'appserver.landodrupal9.internal' ] },
  { service: 'database',
    urls: [],
    type: 'mysql',
    healthy: true,
    internal_connection: { host: 'database', port: '3306' },
    external_connection: { host: '127.0.0.1', port: '32775' },
    healthcheck: 'bash -c "[ -f /bitnami/mysql/.mysql_initialized ]"',
    creds: { database: 'drupal9', password: 'drupal9', user: 'drupal9' },
    config: { database: '/Users/*******/.lando/config/drupal9/mysql.cnf' },
    version: '5.7',
    meUser: 'www-data',
    hasCerts: false,
    hostnames: [ 'database.landodrupal9.internal' ] } ]

Drupal9インストール

順にインストールを進めます。
高度なオプションのホストはdatabaseに設定します。

Drushインストール

$ lando composer require drush/drush
$ lando drush cr
$ lando drush st
$ lando drush uli
http://default/user/reset/1/1627019267/mi-szVVrqS7W36ETu3YMBa9_-dTzVAKjKWAA0-bVONM/login

APPSERVER URLSで表示されたURLにhttp://default以下を貼り付けブラウザでアクセスします。

http://localhost:32799/user/reset/1/1627019267/mi-szVVrqS7W36ETu3YMBa9_-dTzVAKjKWAA0-bVONM/login

通常モジュールのインストールやコアのアップデートはcomposerを利用してインストール・アップデートを実行します。

モジュールインストール・有効

$ lando composer require drupal/admin_toolbar drupal/redirect drupal/paragraphs drupal/ds
$ lando drush -y en admin_toolbar redirect paragraphs ds

sshでサーバにログイン

設定変更したい場合やハマってしまった場合にサーバにログインすることが出来ます。

webサーバログイン
$ lando ssh --service appserver
DBサーバログイン
$ lando ssh --service database

Lando終了

$ lando poweroff

NO!! SHUT IT ALL DOWN!!!
   ___                     _                  ______    
  / _ \___ _    _____ ____(_)__  ___ _  ___  / _/ _/    
 / ___/ _ \ |/|/ / -_) __/ / _ \/ _ `/ / _ \/ _/ _/ _ _ 
/_/   \___/__,__/\__/_/ /_/_//_/\_, /  \___/_//_/(_|_|_)
                               /___/                    
Bye bye landodrupal9_database_1 ... 
Bye bye landodrupal9_appserver_1 ... 
Bye bye landoproxyhyperion5000gandalfedition_proxy_1 ... 
Lando containers have been spun down.

モジュールのバージョン指定やDrupal以外のphpやDB等細かく設定可能です。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1