Deploy the Drupal CMS on a LAMP stack to build a dynamic website on an ECS instance.
Prerequisites
-
An ECS instance is created and meets the following requirements:
-
Runs Alibaba Cloud Linux 2, Alibaba Cloud Linux 3, CentOS 7.x, or CentOS 8.x.
-
A static public IP address is assigned, or an Elastic IP Address (EIP) is associated.
-
Ports 22 and 80 are allowed in the inbound security group rules.
-
-
Important
Drupal requires a minimum PHP version. See Drupal PHP requirements. This topic uses Drupal 11.1.0 with PHP 8.4 or PHP 8.3.
Procedure
-
Connect to the ECS instance. See Log on to a Linux instance using Workbench.
-
Install the required tools and related dependencies.
# Install Composer and grant the execute permissions to Composer. sudo php -r "copy('https://mirrors.aliyun.com/composer/composer.phar', '/usr/local/bin/composer');" sudo chmod +x /usr/local/bin/composer # Install PHP and related extensions. sudo yum install -y php-gd php-pdo php-opcache php-xml php-dom php-simplexml php-zip unzip # Restart Apache for the extensions to take effect. sudo systemctl restart httpd # Install Git. sudo yum install -y git -
Download Drupal.
Go to the Apache default directory and use Composer to download Drupal. This creates a
my_sitedirectory. You can specify a version such as11.1.0.ImportantIf your server resides in the Chinese mainland, specify the Alibaba Cloud mirror to accelerate the download. Otherwise, skip this step.
sudo /usr/local/bin/composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/# Access the default directory of the Apache website. cd /var/www/html # Download Drupal core software by using Composer. sudo /usr/local/bin/composer create-project drupal/recommended-project:11.1.0 "my_site" -
Configure Drupal.
-
Download the Chinese language package and grant write permissions for Drupal installation.
Note-
To download a different version, replace the version number in the command. For example, for Drupal 10.3.0, use
sudo wget -P sites/default/files/translations https://ftp-origin.drupal.org/files/translations/all/drupal/drupal-10.3.0-beta1.zh-hans.po. -
Skip this step if you choose English during Drupal installation.
# Go to the my_site/web directory. cd /var/www/html/my_site/web # Create related directories. sudo mkdir -p sites/default/files/translations # Download the Chinese translation package. If you want to choose the installation language as English when you install Drupal, you do not need to download the Chinese translation package. sudo wget -P sites/default/files/translations https://ftp-origin.drupal.org/files/translations/all/drupal/drupal-11.1.0-beta1.zh-hans.po # Grant the write permissions on the sites/default/files directory. sudo chmod a+w sites/default/files # Create the sites/default/settings.php configuration file for Drupal installation and grant the write permissions on the configuration file. sudo cp sites/default/default.settings.php sites/default/settings.php sudo chmod a+w sites/default/settings.php -
-
Enable clean URLs for Apache.
-
Open the Apache configuration file.
sudo vim /etc/httpd/conf/httpd.conf -
Press
Ito enter Insert mode and add the following content:<Directory "/var/www/html/my_site/web"> AllowOverride All Require all granted </Directory>Press Esc, enter
:wq, and pressEnterto save and close the file. -
Restart Apache.
sudo systemctl restart httpd
-
-
-
Install Drupal.
-
In a web browser, go to
http://<Public IP address of the ECS instance>/my_site/webto open the Drupal installation page. -
Select a language and click Save and continue.

-
Select Standard and click Save and continue.

-
The system checks whether the environment meets the installation requirements.
-
If the requirements are met, you are redirected to the next step.
-
If the requirements are not met, a warning message appears. Resolve the issue, then click Retry to recheck.
For example, if a missing extension warning appears, install it with
yum install -y php-mbstring, then restart Apache withsudo systemctl restart httpd.
-
-
Configure the database parameters and click Save and continue.

-
Enter the site information on the Configure site page and click Save and continue.


-
-
Go to the Drupal website and configure settings based on your business requirements.
ImportantAfter the installation is complete, remove the write permissions from
sites/default,sites/default/files, andsites/default/settings.phpto prevent security risks:sudo chmod a-w /var/www/html/sites/default sudo chmod a-w /var/www/html/sites/default/files sudo chmod a-w /var/www/html/sites/default/settings.php