[Drupal] Setting up a local environment for Drupal 9 Part 1
~Running Linux on Virtual Box

In this article, we will explain how to install Drupal 9 on a local environment.

The methods described on this site are as of 2021. Although the information is outdated, it is still a useful reference for setting up the environment.

We will build the environment under the following conditions:

・Windows 10 Home

This time, we will prepare the OS environment in preparation for starting the server OS.

If you already have a server prepared, please check if it meets the environment requirements. If there are no problems, you can skip this article.

The environment requirements are as follows (as of February 12, 2023).

Regenerate response

Middlewareversion
Nginx0.7.xor later
Apache2.4.7or later
PHPPHP7.3(PHP7.4 is not required, and PHP8 is supported from Drupal 9.1.0.)
MySQLまたはPercona5.7.8or later
MariaDB10.3.7or later
SQLite3.26or later
PostgreSQL10or later

※This article contains information from when the author was using Drupal for work in 2021.

Since CentOS support ended at the end of December 2021, please install AlmaLinux or other alternatives if you are looking for a server environment.”

About CentOS…

CentOS is a type of operating system (called a distribution) of Linux.

An operating system, or OS, is software used to run applications, with popular examples being Windows, MacOS, and Android.

The characteristics of Linux include that it is free to use and easy to start up web server software (among other things).
Linux is free and open-source software, meaning that it can be customized to suit the needs of individual users and can be provided for a fee.

An example of a paid distribution is Red Hat Enterprise Linux (RHEL) (nicknamed “Rel” by some).
While RHEL is a great OS, it can be difficult to use due to its cost. This is where CentOS comes in.
CentOS is a free, community-driven version of RHEL, created using the source code of RHEL (source).
Thanks to CentOS, we can use a paid-level Linux OS for free.

This time, we will run CentOS 8.1 using Virtual Box.

What is VirtualBox?

VirtualBox is software that uses virtualization technology to run an operating system on top of another operating system.

By using VirtualBox, even if your OS is Windows, you can run CentOS.

Let’s get started and install VirtualBox. Access this website and download the installer.

Depending on the version, VirtualBox may fail to install.

If you encounter an error, try installing a different version.

Let’s start by launching the downloaded installer and installing VirtualBox. I think it’s okay to install with the default settings.

If VirtualBox starts up, then it’s a success.

Next, let’s create a virtual machine. Click “Machine” and then “New”. Enter the information as shown in the image below, and click “Next” (feel free to choose any name you like).

Select the memory size and click “Next”. I think around 4G should be sufficient.

Select “Create a virtual hard disk” and click the “Create” button.

Leave it as default and click “Next”.

Leave it as default and click “Next”.

“Create” with default settings.

The virtual machine has been created.

Before starting the virtual machine, let’s configure network settings. Click “Settings” and then “Network,” and set “Host-Only Adapter” for Adapter 2.

This time, we will download “CentOS-8.3.2011-x86_64-dvd1.iso”. Since the file size is large, it will take some time to download.

In VirtualBox, go to “Settings” -> “Storage”, select “Empty” under “Controller: IDE”, click the CD icon on the right, and select “Choose Virtual Optical Disk File”.

And then, specify the downloaded ISO file.

Please click “Start” to begin.

In the “Select start-up disk” menu, click “Start”.

Select “Install CentOS Linux 8” and press Enter.

Select your preferred language and click “Continue”.

Clicking on the console will cause the mouse to be trapped inside the virtual machine and not return to the Windows side.

You can release the mouse by pressing the “ctrl” key on the left side of the keyboard.

Click on “Time & Date”.

Select Japan and click “Done”.

Click on “Software Selection” (I forgot to take a screenshot..)

Select “Server” and click “Done”

Choosing “Server with GUI” allows you to use CentOS with a graphical user interface (GUI).

If you’re going to use CentOS as a web server, you don’t necessarily need a GUI, so we won’t be choosing it this time.
For those who have only used Windows or macOS, you may find it difficult to get used to using the command-line interface (CLI), as you may have become accustomed to operating with a GUI.
However, command-line operations are the foundation of most web servers in the world.
I wonder why that is… I feel that GUI is more intuitive, but we have no choice but to get used to using the CLI.

I can’t see the screen as it is cut off, but please click on “Installation Destination.”

Just click “Done” as is.

Click on “Root Password”.

Please enter a password for root and click “Done”.

Please make sure not to forget the password.

Click “Begin Installation” and wait until it’s complete.

Click “Reboot” to restart the system.

If CentOS starts up like this, the installation is successful.

Let’s try logging in as root.

Since the console (operating screen) is difficult to use, we will connect using Teraterm.

What is Teraterm?

Teraterm is software that provides a console for communicating with servers using the SSH protocol (which can be thought of as a set of communication rules).

For those working in IT, it has become an essential software tool. Teraterm allows you to run servers through the CLI.

When you start Teraterm, you will see a screen like the following. Enter the IP address of CentOS in the “Host” field.

You can display the IP address by entering the following command in CentOS:

$ ip a

Displaying a screen like the following, enter the IP address starting with “192.168.” into Teraterm.

When you enter the IP address, you will be prompted for a username and password, so enter the root user and the root user’s password.

Meaning of IP address starting with “192.168.”

An IP address is a number assigned to identify a computer. In the protocol called IPv4, which is commonly used nowadays, an IP address is expressed as a sequence of 32 bits, i.e., 32 zeros and ones. Since it is difficult for humans to understand a combination of 32 zeros and ones, it is divided into 8 digits and displayed as decimal numbers.

For example, “11000000 10101000 00111000 00000010” is displayed as “192.168.56.2”.

In the world of networking, there is a rule that IP addresses should be assigned according to rules rather than arbitrarily. IP addresses starting with “192.168.” follow the rule of assigning the “x” part of “11000000 10101000 xxxx xxxx” to each device that is not directly connected to the external internet.

There are IP addresses starting with “10.” and “172.” assigned in a similar way. You can learn more about IP address allocation by searching for “Private IP address”.

If you can connect to CentOS with Teraterm, it will be considered a success.

Next, let’s connect CentOS to the internet. Open the network configuration file with the following command:

$ vi /etc/sysconfig/network-scripts/ifcfg-enp0s3

Change “ONBOOT=no” to “ONBOOT=yes” to enable the network, save with “:wq!”, and execute the following command.

$ systemctl restart NetworkManager.service
$ ip a

If an IP address starting with “10.” is displayed in the “enp0s3:” item, the configuration is successful.

If you can no longer connect to an IP address starting with “192.”, specify “IPV6INIT=no” in ifcfg-enp0s8, add “IPADDR=192.168.56.x” (x is any number from 2 to 254) and “PREFIX=24”, and then restart the OS.

That’s all for now. Next time, we’ll cover setting up a web server.

I am studying Drupal using the following book.
It contains specific implementation methods for Drupal that are not found in Japanese books on Drupal 9.