Will install Drupal on Mac and set up a working environment.
This article was written when I was testing Drupal on a local environment before publishing it on Lightsail. After that, I selected Bitnami's Drupal, which I installed in the Tokyo region using the Lightsail blueprint, and it was set to 10.3.3 by default. After installation, I updated it, so this website is published using Drupal 10.3.5. *As of 30th September 2024
As mentioned in the article, the Mac environment is built using Drupal 11.0.4. We had planned to run Drupal 11.0.4 on AWS, but the Drupal instance provided by the Lightsail blueprint is not compatible with Drupal 11.0.4, so please understand that the article is published using Drupal 10.3.5 and the content is difficult to understand.
I will write about Amazon Lightsail in a separate article.
- MacBookProM1(2021) model
- Local server (required to run Drupal on a Mac) Orbstack Pro
- Local Docker environment DDEV v1.23.4
- I am using PHP8.3.10, MariaDB10.11.8, Drupal11.0.4, Bootstrap5 4.03.
- Terminal: iTerm > Shell: Mac standard Shell Zch
- Package Manager: HomeBrew 4.3.22
- Composer Version 2.7.9
- Editor: Vscord 1.93.1
- Github Copilot 1.229.0
- Japanese Language Pack 1.93
- PHP Debag 1.35.0
- Remote SSH 0.114.3
- SSH: Editing Configuration Files 0.86.0
- Remote Explorer 0.4.3
- Vim 1.28.1
As of 16/09/2024 (Mon)
Originally, the Drupal 10.x website was built using CivicTheme, but when we updated to Drupal 11.x and checked the compatibility, we found that CivicTheme was not yet compatible with the 11 series, so we looked for another theme and found that Bootstrap 5 4.03, which we are using this time, was already compatible, so we adopted Bootstrap 5 as the design theme.
Drupal is a CMS for web applications that run on PHP and a database, so you need to set up PHP and the database to run on your Mac.
When using WordPress, I was using MAMP as a local server, but as I want to use Docker containers with Drupal, I need to build an environment where Docker containers can run, so I will use Orbstack, a Docker provider (an image that builds a Linux server within Mac, and has a packaged web server function). we will use Orbstack. Docker Desktop is the most popular Docker container, but when using DDEV, Orbstack is recommended, and we will use Orbstack because it is also excellent in terms of performance and stability.
The advantages of Orbstack are that it is easy to install, and even though it is a local environment, it starts up and runs quickly (e.g. web page display speed), and SSL functionality is available as standard. MAMP also allows you to use SSL, but the settings can be quite troublesome, and I myself use the paid version MAMP Pro when I run WordPress locally.
Orbstack download page - Download in Zip format from here. As with other apps, you can install it simply by extracting the downloaded Zip and moving the app to the app folder. You can also install it using Home Brew, so it's very easy to introduce.
Orbstack documentation - After installation, click the icon to start up. As mentioned in the documentation, you can also start it up using a command from the terminal.
Once you have installed Orbstack, install DDEV. DDEV makes it easy to use Docker containers on your Mac.
DDEV has a simple installation of CMS. Drupal also has a simple installation, and using Composer, Drupal can be installed on a Mac in a few steps and used immediately.
Once you have installed DDEV, install Drupal.
// Creating and moving to a folder
% mkdir my-drupal-site && cd my-drupal-site
// Write Drupal settings to the folder--php-version=8.3 is specified as PHP 8.3 because the stable version of PHP for Drupal 10.3 and later is PHP 8.3.
% ddev config --project-type=drupal --php-version=8.3 --docroot=web
// Drupal installation:recommended-project:^11 installs a stable version of Drupal Core 11 or higher.
% ddev start ddev composer create drupal/recommended-project:^11
// Update the configuration file
% ddev config --update
// Drush update
% ddev composer require drush/drush
// Initial settings for the Drupal admin screen - The login name is ‘account-name=admin’ - The password is set with ‘account-pass=admin -y’.
% ddev drush site:install --account-name=admin --account-pass=admin -y
// use the one-time link (CTRL/CMD + Click) from the command below to edit your admin account details.
// Issue a one-time login URL for the Drupal administrator login
% ddev drush uli
// Starting Drupal
% ddev launch
// The Drupal installation is now complete, and you can log in to the administration screen from your browser and start building your website with Drupal.
// Once the installation is complete and Drupal is running,
% ddev describe
// You can view the configuration file (you can also view it in composer.json in the root directory).
After installing DDEV, install nss, mkcert and configure mutagen.
nss > Client and server libraries for using https
mkcert > Library for issuing SSL certificates for https in a local environment
mutagen > Fast directory synchronisation tool
// mksert and mutagen settings
// nss installation
% brew install nss
// Install mkcert
% mkcert -install
// mutagen settings
% ddev config global --mutagen-enabled
The installation folder for brew install was set up for an Intel Mac, which is what I was running into trouble with. Because of this, I needed to change the path, but I was unable to proceed due to a Rozetta error. The settings I had used when I was using an Intel Mac were still in place after I had switched to an M1 Mac, so I took the opportunity to reinstall Homebrew and fix the problem.
/opt/homebrew/ Installation destination for Apple Silicon homebrew
/usr/local/Homebrew Installation destination for HomeBrew on Intel Mac
Drupal Core specifies the PHP version, and if the locally enabled PHP version does not match, you will not be able to install Drupal, so please use the PHP version specified by the Drupal Core you are installing.
% php -v *Check the PHP version.
Drupal 11.x has only just been released, and depending on the theme, there are still many issues with Drupal 11.x, and there are also many that cannot be installed or updated due to dependency checks, so depending on the theme used, there may be cases where you need to use Drupal 11 or earlier , since the operating environment for Drupal 11.x is PHP 8.3 or higher, it is convenient to use Direnv when using Drupal 11 and PHP 8.3 or earlier, or when using Drupal 10.x or earlier projects in combination.
Direnv allows you to assign multiple PHP versions to each working folder, so you can use different versions of PHP to match the DrupalCore version specified by the theme you want to use, and you can use multiple projects with different versions on your Mac locally.
This time, I set up my Mac to be able to use Drupal, and I actually installed and ran Drupal. Here is a brief summary of the work I did.
- Building a local server environment - Installing Orbstack
- Building a container environment on a local server - Installing DDEV
- Setting up the local server environment, including Mutagen
- Checking the environment before installing Drupal - PHP version, DB version, etc.
- I updated or installed the relevant software using Homebrew to prepare the necessary environment
- I installed Drupal using the easy installation function of DDEV CMS.
I installed Drupal 11.0.4 on my MacBook in this way.
The reason I installed Drupal 11 is that I want to use AWS later on. When I looked into the AWS environment, I found that Lightsail has partnered with Bitnami to provide a Drupal environment.
When I checked the status of Drupal installations in the regions available on Lightsail, I found that all of them were the latest versions, and the versions of Drupal that could be used as standard were the latest 10.3.5 and 11.0.4, so I thought it would be better to use the latest 11 series if I was going to use AWS later on, and so I chose the latest Drupal 11.0.4 this time.
I'm still considering how to use AWS, but using a combination of EC2 and RDS, which is the most AWS-like way to use it, would be overkill for my environment and go over budget, so I'm considering using LightSail.
This article was written when I was testing Drupal on a local environment before publishing it on Lightsail. After that, I chose Lightsail and installed Bitnami's Drupal on the Tokyo region, and the version was 10.3.3 by default. After the installation, I updated it, so this website is published on Drupal 10.3.5. *As of 30th September 2024
As mentioned in the article, we are using Drupal 11.0.4 to build the Mac environment. We had planned to run Drupal 11.0.4 on AWS, but since the Tokyo region of Lightsail does not support Drupal 11.0.4, we are publishing it using Drupal 10.3.5, so please understand that the article content is difficult to understand.
We will write about Amazon Lightsail in a separate article.
In the next section, we will select a theme that can be used with Drupal 11 and actually use it.
Drupal Themes.
Olivero, which is the standard Drupal theme, is also a well-made theme, but Bootstrap 5, which is more flexible, can be used without any problems in the 11.x series, so we will install and configure Bootstrap 5.