Since this site was published on AWS, I haven't had the chance to use Drupal on my local Mac environment, but I recently used Orbstack > DDEV to run Drupal on my Mac to check the Bootstrap5 and CivicTheme sites, which are Drupal projects installed on my local environment.
We have summarised OrbStack and DDEV in previous articles, but let's review the outline.
- OrbStack is a virtual machine for Linux that runs locally on a Mac and can be used as Docker.
- From the official OrbStack website: ‘OrbStack is a fast, lightweight, simple, and easy-to-use drop-in replacement for Docker Desktop on macOS. It runs both containers and Linux machines.’
- DDEV is a tool for building a local environment for LAMP and Node.js, and it enables a Docker workflow in a local environment.
- DDEV is a tool for building locally, so if you are using containers on a VPS or similar, you can use Orbstack to set up Docker and Kubernetes. In my environment, I only use CMS such as Drupal and WordPress individually, so I don't use collaborative development tools such as Docker and Git.
- I use Git occasionally, but I have never used containers, so I would like to use them if I get the chance.
I am using these two applications to run Drupal in the following way.
- I am running a Linux virtual machine provided by Orbstack in a local Mac environment, and it is running as a container by default.
- I am using DDEV on the Linux virtual machine to build a LAMP environment (optimised for Drupal) and install Drupal.
Update the tools
As I haven't been running my local environment for a while, I'll update a few things, including DDEV, Composer, Drush, Drupal Core, themes, and modules. The following is the local environment introduced in #C01. I'm using Orbstack and operating it with a GUI, so when there are updates, I get a notification and can update to the latest version by following the instructions, so I'll skip the procedure.
There were also some updates to the editor Vscord and the tools that were installed along with the feature enhancements, but the Vscord update has already been completed, so we will skip the procedure.
MacBookProM1(2021) model / mac OS Sequoia 15.1.1
- Terminal iTerm 3.5.10 > Shell Mac standard Shell Zch
- Package Manager > HomeBrew 4.3.22
- Local server (required to run Drupal on Mac) Orbstack Pro V1.8.2
- Local Docker environment DDEV v1.23.4 > Updated to 1.24.0
- PHP 8.3.10
- MariaDB 10.11.8
- Composer Version 2.7.9 > Updated to 2.8.3
- Drupal Core 11.0.4 > Updated to 11.0.9 / Bootstrap5 Theme
- Drupal Core 10.0.3 > 10.3.10 / Civic ThemeBootstrap5 4.03
- Civic Theme 1.8.1 > 1.9.0
Editor Vscord 1.93.1 > 1.95.3
- Github Copilot 1.229.0 > 1.248.0 Vscord feature enhancement
- Japanese Language Pack 1.93 >1.95 Vscord feature enhancement
- PHP Debug 1.35.0 Vscord feature enhancement
- Remote SSH 0.114.3 > 0.115.1 Vscord feature enhancement
- SSH: Editing Configuration Files 0.86.0 > 0.87.0 Vscord feature enhancement
- Remote Explorer 0.4.3 Vscord feature enhancement
- Vim 1.28.1 > 1.29.0 Vscord feature enhancement
This is all. * As of 6th December 2024 (Fri). This time, we updated DDEV, Composer, Drupal Core, modules and themes. As we haven't started it for a while, there are updates accumulated.
Building a Drupal site on my local environment involves
- Starting Orbstack from the Mac GUI
- starting iTerm and moving to the directory where Drupal was installed > $ cd drupal11-bootstrap5[project name]
- starting DDEV $ ddev start > The virtual server will start up and Drupal will be available.
- Checking the Drupal site https://drupal11-bootstrap5[project name].site
- Log in to the Drupal Admin console
- Build the site in the Admin console
This time's update was carried out using Homebrew and Composer in iTerm.
The local environment is used for Drupal site construction, to test the modules to be installed, check for problems due to version-based dependencies, test and check the configuration of features such as content types and Views, and for the rough design of the site. Once the specifications are more or less complete, a similar environment is created on the server for publication, and from then on, the work is done on the web.
The reason for running a local environment this time is that I wanted to prepare a test environment on a local environment for updating the currently published 10.3x series site to the 11x series. As I'm also creating the site design in a rush, I'd like to think about a more readable format, so I'll also be using it as a design draft at the same time.
I'll start updating it right away.
About the notation of the terminal prompt
- The reason the prompt on the console screen is % is because the shell I usually use in iTerm is the Mac standard Zsh. All the terminal command prompts related to the Mac environment are written in %.
- In the second half of the article, you will log in to an Orbstack container, but since Orbstack containers run on Linux and use Bash as the shell, the prompt is written as $ . The prompt for all Linux terminal commands is written as $ .
- The terminal commands described in other articles are mostly for working with Lightsail and Bitnami, and since the standard shell is Bash, the prompt is written as $ .
DDEV 1.23.4 > 1.24.0
I updated the version of DDEV from 1.23.4 to 1.24.0. I used Homebrew to update DDEV. The update was completed with the version check and update commands.
DDEV Update
To update DDEV, use Homebrew.
// Check the current version
% DDEV --version
ddev version v1.23.4
---
// Update to the latest version
% brew upgrade ddev/ddev/ddev
---
==> Auto-updating Homebrew...
Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with
HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:303bed4c7fc431a685db3c3c151d873740114adbdccd23762ea2d1e39ea78f47
######################################################################### 100.0%
==> Pouring portable-ruby-3.3.6.arm64_big_sur.bottle.tar.gz
==> Auto-updated Homebrew!
Updated 4 taps (homebrew/services, ddev/ddev, homebrew/core and homebrew/cask).
==> New Formulae
action-docs fltk@1.3 php@8.3
afl++ foot pie
--- Completed ---
// Version check
% DDEV --version
ddev version v1.24.0
---
// Updated to the latest version v1.24.0
DrupalCore11x / Bootstrap5
Orbstack > Check the update status of Drupal Core 11x and Bootstrap5 Theme installed in the DDEV environment and perform updates. The following updates are being performed.
- Composer 2.7.9 > Update to 2.8.3.
- Drush 13.1.1 > Update to 13.3.3.
- Drupal Core 11.0.4 > Update to 11.0.9.
- Bread Crumb 2.0.8 > 2.0.9 update.
Composer 2.7.9 > 2.8.3 update.
Composer Update
To update Composer, use the Composer self-update command.
// Check the current version
% composer --version
Composer version 2.7.9 2024-9-04 12:34:56
---
// Update to the latest version
% composer self-update
---
// Version check
% composer --version
Composer version 2.8.3 2024-11-17 13:13:04
PHP version 8.4.1 (/opt/homebrew/Cellar/php/8.4.1_1/bin/php)
Run the "diagnose" command to get more detailed diagnostics output.
// Updated 2.8.3
---
// If you want to know about Composer or its commands
% composer -v
---
______
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
Composer version 2.8.3 2024-11-17 13:13:04
Usage:
command [options] [arguments]
Options:
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
--profile Display timing and memory usage information
--no-plugins Whether to disable plugins.
--no-scripts Skips the execution of all scripts defined in composer.json file.
-d, --working-dir=WORKING-DIR If specified, use the given directory as working directory.
--no-cache Prevent use of the cache
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
about Shows a short information about Composer
archive Creates an archive of this composer package
audit Checks for security vulnerability advisories for installed packages
browse [home] Opens the package's repository URL or homepage in your browser
bump Increases the lower limit of your composer.json requirements to the currently installed versions
check-platform-reqs Check that platform requirements are satisfied
clear-cache [clearcache|cc] Clears composer's internal package cache
completion Dump the shell completion script
config Sets config options
create-project Creates new project from a package into given directory
depends [why] Shows which packages cause the given package to be installed
diagnose Diagnoses the system to identify common errors
dump-autoload [dumpautoload] Dumps the autoloader
exec Executes a vendored binary/script
fund Discover how to help fund the maintenance of your dependencies
global Allows running commands in the global composer dir ($COMPOSER_HOME)
help Display help for a command
init Creates a basic composer.json file in current directory
install [i] Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json
licenses Shows information about licenses of dependencies
list List commands
outdated Shows a list of installed packages that have updates available, including their latest version
prohibits [why-not] Shows which packages prevent the given package from being installed
reinstall Uninstalls and reinstalls the given package names
remove [rm|uninstall] Removes a package from the require or require-dev
require [r] Adds required packages to your composer.json and installs them
run-script [run] Runs the scripts defined in composer.json
search Searches for packages
self-update [selfupdate] Updates composer.phar to the latest version
show [info] Shows information about packages
status Shows a list of locally modified packages
suggests Shows package suggestions
update [u|upgrade] Updates your dependencies to the latest version according to composer.json, and updates the composer.lock file
validate Validates a composer.json and composer.lock
Provides an overview of the [create-project] and [update] commands used to install and update Drupal core and modules, as well as an explanation of their options.
Drush 13.1.1 > 13.3.3 will be updated.
Drush Update
To update Drush, use Composer's require command with the --update-with-all-dependencies option.
// Check the current version
% ddev drush --version
Drush Commandline Tool 13.1.1.0
---
// Update to the latest version
% composer require drush/drush:^13 --update-with-all-dependencies
---
./composer.json has been updated
Running composer update drush/drush --with-all-dependencies
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 15 updates, 0 removals
- Upgrading chi-teck/drupal-code-generator (4.0.0 => 4.1.0)
- Upgrading consolidation/config (3.0.0 => 3.1.0)
- Upgrading consolidation/output-formatters (4.5.0 => 4.6.0)
- Upgrading consolidation/robo (5.0.0 => 5.1.0)
- Upgrading drush/drush (13.1.1 => 13.3.3)
- Upgrading grasmash/expander (3.0.0 => 3.0.1)
- Upgrading illuminate/collections (v11.23.5 => v11.34.2)
---omission---
- Upgrading chi-teck/drupal-code-generator (4.0.0 => 4.1.0): Extracting archive
- Upgrading drush/drush (13.1.1 => 13.3.3): Extracting archive
Generating autoload files
43 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
No security vulnerability advisories found.
---Completed---
---
// Check for updates
% ddev drush --version
Drush Commandline Tool 13.3.3.0
// Latest version 13.3.3.0 update
---
// The commands that are often used with Drush are
$ drush updatedb
$ drush cache:rebuild
---
etc. These are commands that are used to clear the cache and update the database after installation or updating, but they also have elements of the shell function. By combining commands and options, it is possible to use them in a way similar to bash, and it is easy to check the list of views, etc., as shown below.
---
% ddev drush views:list --fields=machine-name,status
------------------------- ----------
Machine name Status
------------------------- ----------
block_content Enabled
comment Enabled
comments_recent Enabled
content Enabled
content_recent Enabled
files Enabled
frontpage Enabled
list_footer Enabled
taxonomy_term Enabled
term_list Enabled
test Enabled
user_admin_people Enabled
vews_life_style_article Enabled
views_post78 Enabled
watchdog Enabled
who_s_new Enabled
who_s_online Enabled
archive Disabled
glossary Disabled
------------------------- ----------
Drupal Core 11.0.4 > 11.0.9 will be updated.
Drupal Core Update
To update Drupal Core, use the Composer update command with the --with-all-dependencies option.
// Check the current version
% ddev drush core:status --field=drupal-version
11.0.4
---
// Update to the latest version
---
# Clear cache
% ddev drush cache:rebuild
[success] Cache rebuild complete.
---
# Update
% ddev composer update "drupal/core-*" --with-all-dependencies
---
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 27 updates, 0 removals
- Upgrading composer/semver (3.4.2 => 3.4.3)
- Upgrading drupal/core (11.0.4 => 11.0.9)
- Upgrading drupal/core-composer-scaffold (11.0.4 => 11.0.9)
- Upgrading drupal/core-project-message (11.0.4 => 11.0.9)
- Upgrading drupal/core-recommended (11.0.4 => 11.0.9)
---the rest is omitted---
---finished---
// clear cache and update DB
---
% drush updatedb
[success] No pending updates.
% drush cache:rebuild
[success] Cache rebuild complete.
---
// Check for updates
% ddev drush core:status --field=drupal-version
11.0.9
// Updated to 11.0.9
---
// Check the update status with core:status.
---
% ddev drush core:status
---
Drupal version : 11.0.9
Site URI : https://drupal11-bootstrap5.ddev.site
DB driver : mysql
DB hostname : db01test
DB port : 3306
DB username : db01test
DB name : db
Database : Connected
Drupal bootstrap : Successful
Default theme : b5subtheme
Admin theme : claro
PHP binary : /usr/bin/php8.3
PHP config : /etc/php/8.3/cli/php.ini
PHP OS : Linux
PHP version : 8.3.14
Drush script : /var/www/html/vendor/bin/drush.php
Drush version : 13.3.3.0
Drush temp : /tmp
Drush configs : /var/www/html/vendor/drush/drush/drush.yml
Install profile : standard
Drupal root : /var/www/html/web
Site path : sites/default
Files, Public : sites/default/files
Files, Temp : /tmp
Bread Crumb 2.0.8 > 2.0.9 update.
Bread Crumb Update
To update Bread Crumb, use the Composer update command with the --with-all-dependencies option, just like you would for an update to Drupal Core.
// Check the current version
% ddev composer show drupal/easy_breadcrumb
---
name : drupal/easy_breadcrumb
descrip. : Adds configuration to the system breadcrumbs.
keywords :
versions : * 2.0.8
type : drupal-module
license : GNU General Public License v2.0 or later (GPL-2.0-or-later) (OSI approved) https://spdx.org/licenses/GPL-2.0-or-later.html#licenseText
homepage : https://www.drupal.org/project/easy_breadcrumb
source : [git] https://git.drupalcode.org/project/easy_breadcrumb.git 2.0.8
dist : [zip] https://ftp.drupal.org/files/projects/easy_breadcrumb-2.0.8.zip 2.0.8
path : /var/www/html/web/modules/contrib/easy_breadcrumb
names : drupal/easy_breadcrumb
support
source : https://git.drupalcode.org/project/easy_breadcrumb
issues : https://www.drupal.org/project/issues/easy_breadcrumb
---
// Update to the latest version
---
# Clear cache
% ddev drush cache:rebuild
[success] Cache rebuild complete.
---
# Update
% ddev composer update drupal/easy_breadcrumb --with-all-dependencies
-----
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 10 updates, 0 removals
- Upgrading drupal/easy_breadcrumb (2.0.8 => 2.0.9)
- Upgrading symfony/dependency-injection (v6.4.15 => v6.4.16)
-----
---the rest is omitted---
---finished---
// clear cache and update DB
---
% ddev drush updatedb
[success] No pending updates.
% ddev drush cache:rebuild
[success] Cache rebuild complete.
---
// Check for updates
% ddev drush pm:list
---
--------------------- ---------------------------------- ---------- ----------
Package Name Status Version
--------------------- ---------------------------------- ---------- ----------
Core Announcements Enabled 11.0.9
(announcements_feed)
Core Automated Cron (automated_cron) Enabled 11.0.9
~~~ 中略 ~~~
Navigation Easy Breadcrumb Enabled 2.0.9
(easy_breadcrumb)
---
// Updated to the latest version 2.0.9
This completes the update of the Drupal Core 11.09 / Bootstrap5 Theme project installed on DDEV in Orbstack.
Handling errors
The following error is displayed in Drupal installed on Orbstack's DDEV, so we will investigate the cause and take action.
Home > Administration > Reports > Site Status
Protection is invalid
The file sites/default/settings.php is not protected against changes and is therefore a security risk. Please change the file permissions to disallow writing.
This error is caused by a problem with the permissions of the setting.php file. When Drupal is installed, the setting.php file is set to 644, so change the permissions to 444 [read-only]. This is usually resolved by the following command. When Drupal is installed on Xserver, the following command is also used to resolve the issue. Bitnami installs an instance with the basic settings for Drupal already completed, so there is no error from the start.
$ cd web
$ chmod 444 sites/default/settings.php
I'll change it right away.
Changing permissions
Change the permissions by entering a command from iTerm.
// Move to the web directory
% cd web
---
// Change the permissions of setting.php
% chmod 444 sites/default/settings.php
---
// Confirm changes
% ls -l sites/default/settings.php
---
// It has been changed to 444.
% -r--r--r-- 1 s-takeda drupal 65432 Dec 6 10:00 settings.php
The permissions for settings.php have been changed to read-only, so please check this in the Drupal administration console.
The error has not disappeared. Let's investigate the cause.
The changes you made in the past on the web server such as Xserver have been reflected, but the changes you made locally on your Mac this time have not been reflected, so the DDEV settings are suspicious. Checking DDEV and Orbstack will reveal the cause.
DDEV Configuration
DDEV runs in a container. The following is a configuration diagram.
|-ddev-drupal11-bootstrap5
| |-db
| |-web
|
|-ddev-router
| |-ddev-router
|
|-ddev-ssh-agent
|-ddev-ssh-agent
To fix this error, you need to change the permissions of the settings.php file. This file is not in the drupal11-bootstrap5/web directory that appears in the Mac terminal, but in the ddev-drupal11-bootstrap5/web container in Orbstack. You need to change the permissions of this settings.php file, so to do this you need to connect to the ddev-drupal11-bootstrap5/web container using ssh. You can use the DDEV ssh command to connect to the container.
ssh into the container using DDEV
Use DDEV's ssh to enter the container and change the permissions of settings.php.
// Use ddev's ssh to log in to the container.
% ddev ssh
It will change from zsh to bash.
s-takeda@drupal11-bootstrap5-web:/var/www/html$ ls -al
// From here on, we will use $ [command].
---
drwxr-xr-x 1 s-takeda dialout 406 Dec 6 22:14 vendor
drwxr-xr-x 1 s-takeda dialout 336 Nov 26 18:44 web
---
// Checking the directory structure
$ cd web
$ ls -al
---
-rw-r--r-- 1 s-takeda dialout 2005 Sep 17 05:21 robots.txt
drwxr-xr-x 1 s-takeda dialout 168 Sep 17 05:21 sites
drwxr-xr-x 1 s-takeda dialout 46 Sep 17 06:17 themes
---
$ cd sites/default
$ ls -al
---
-rw------- 1 s-takeda dialout 2015 Dec 6 22:08 settings.ddev.php
---
// The permissions for settings.php are read and write.
-rw------- 1 s-takeda dialout 36727 Dec 7 18:37 settings.php
---
// Change the permissions.
$ chmod 444 settings.php
// Check for changes.
$ ls -al
---
-rw------- 1 s-takeda dialout 2015 Dec 6 22:08 settings.ddev.php
// It has been changed to 444, which is for reading only.
-r--r--r-- 1 s-takeda dialout 36727 Dec 7 18:37 settings.php
---
// Clear the cache.
$ drush cr
[success] Cache rebuild complete.
---
// End of ssh
$ exit
---
// Reference When working in the Mac terminal, you need to add ddev before entering the command due to the path, but you do not need to add ddev in the container.
// Mac terminal
% ddev drush cr
// Orbstack container
$ drush cr
I used DDEV to ssh into the container and changed the permissions for web:/var/www/html/web/sites/default/settings.php from read/write to read only.
Check for errors in the Drupal admin console.
Home > Administration > Reports > Site status
32 confirmed Details
The error has disappeared.
Conclude.
As part of the local environment maintenance, we updated DDEV, Composer and Drush, and also updated Drupal Core and modules. We also dealt with the security warning error due to permissions in settings.php, which had been left as it was since the installation.
We frequently perform Drupal-related updates on our public sites, so we are used to doing this kind of work. In comparison, updating DDEV, Composer and Drush is a good opportunity to learn new things, as you have to look through new tutorials and check commands before doing it.
This time, we did the work locally, but you can also update Composer and Drush on Lightsail and Xserver, which are public sites, so we will do it when we get the chance.
From the very beginning of setting up the Drupal environment on my Mac, I was getting security warning errors due to the permissions of settings.php, but as it was a local environment, I didn't worry about it and just built the site as I went along. When I went to publish it, I changed the permissions on the server and the errors disappeared, so I left it as it was. This time, when I investigated the cause of the error, it turned out to be a simple problem: DDEV was running in a container, and I hadn't changed the container settings, so I dealt with it. I was using DDEV, but I didn't realise it was a container, and I was using it as a local LAMP environment server in the same way as MANP, so I left it as it was.
The biggest advantages of Orbstack and DDEV are the ease of configuration and fast browsing. MAMP > WordPress is also easy to configure, but it doesn't have the fast browsing of Orbstack and DDEV. I was using it for this advantage alone, but I was interested in containers, even if it was local, and I had a vague image of containers because I had not had the opportunity to actually use them, so I would like to try an environment such as Docker if I get the chance.
As I'm not a developer myself, I mainly use CMS such as Drupal and WordPress, and my work is mainly on the web admin screen, so I don't need to use Git or Docker at the moment, but I think I'd like to try using them in some way, as they are essential technologies for embodying the recent evolution of web technology.
Originally, I thought I would write about the update of the Civic Theme installed on DDEV for Orbstack, but it ended up being quite long, so I'll do that next time.
Civic Theme
As I mentioned in the previous article about setting up my MacBook, I have the Bootstrap 5 theme and the Civic Theme theme installed on my MacBook. In this article, I will be summarising the Civic Theme.