Study Guide: Installing a Drupal 9 Local Development Environment
Notes on command line setup of a new Drupal 9 site using Homebrew, ddev, Docker, and git.
Prerequisites
- Homebrew https://docs.brew.sh/Installation
- Git https://git-scm.com/
- Docker https://docs.docker.com/get-docker/
- ddev https://ddev.readthedocs.io/en/stable/
1. Install ddev
$ brew tap drud/ddev && brew install drud/ddev/ddevVerify version
$ ddev version2. Create Project Directory
Warning: Avoid project-names-with-hyphens! ddev doesn’t like them.
$ mkdir d9
$ cd d93. Create default Drupal 9 directory structure.
$ ddev config --project-type=drupal9 --docroot=web --create-docroot4. Build a Docker container for the project based on settings in .ddev dir.
$ ddev start5. Install Drupal core, libraries, and resources, and create a default project.
$ ddev composer create "drupal/recommended-project"6. Install drush.
$ ddev composer require "drush/drush"7. Configure the Drupal 9 Project
Option 1: Launch interactive configuration, or…
ddev launchOption 2: Use Drush.
$ ddev exec drush site:install --account-name=admin --account-pass=admin
$ ddev launch8. Adjust and check file security
$ chmod 555 web/sites/default
$ chmod 444 web/sites/default/settings.php
$ ls -alhd web/sites/default web/sites/default/settings.php# Output
$ dr-xr-xr-x 8 [ron] staff 256 Jul 21 12:56 web/sites/default
$ -r--r--r-- 1 [ron] staff 249 Jul 21 12:12 web/sites/default/settings.php9. A few more useful ddev commands
ddev stop
ddev stop [project]
ddev list10. Create .gitignore file.
# gitignore template for Drupal 8 projects
#
# earlier versions of Drupal are tracked in `community/PHP/`
#
# follows official upstream conventions:
# https://www.drupal.org/docs/develop/using-composer
# Ignore configuration files that may contain sensitive information
/web/sites/*/*settings*.php
/web/sites/*/*services*.yml
# Ignore paths that may contain user-generated content
/web/sites/*/files
/web/sites/*/public
/web/sites/*/private
/web/sites/*/files-public
/web/sites/*/files-private
# Ignore paths that may contain temporary files
/web/sites/*/translations
/web/sites/*/tmp
/web/sites/*/cache
# Ignore drupal core (if not versioning drupal sources)
/web/vendor
/web/core
/web/modules/README.txt
/web/profiles/README.txt
/web/sites/development.services.yml
/web/sites/example.settings.local.php
/web/sites/example.sites.php
/web/sites/README.txt
/web/themes/README.txt
/web/.csslintrc
/web/.editorconfig
/web/.eslintignore
/web/.eslintrc.json
/web/.gitattributes
/web/.htaccess
/web/.ht.router.php
/web/autoload.php
/web/composer.json
/web/composer.lock
/web/example.gitignore
/web/index.php
/web/INSTALL.txt
/web/LICENSE.txt
/web/README.txt
/web/robots.txt
/web/update.php
/web/web.config
# Ignore vendor dependencies and scripts
/vendor
/composer.phar
/composer
/robo.phar
/robo
/drush.phar
/drush
/drupal.phar
/drupal
# Ignore directories generated by Composer
/drush/contrib/
/vendor/
/web/core/
/web/modules/contrib/
/web/themes/contrib/
/web/profiles/contrib/
/web/libraries/
# Ignore SimpleTest multi-site environment
/web/sites/simpletest
# Ignore files generated by common IDEs
/.idea/
/.vscode/
# Ignore .env files as they are personal
/.env11. Configure git
$ git init
$ git remote origin drupal
$ git remote add origin path/to/git/repo
$ git add .
$ git commit -m "Initial commit"
$ git status
$ git pushSources
- https://www.digitalocean.com/community/tutorials/how-to-develop-a-drupal-9-website-on-your-local-machine-using-docker-and-ddev
- https://it.umn.edu/services-technologies/how-tos/drupal-9-set-local-environment
Source: //study/drupal/installing-drupal9-local-dev/
