Drupal is an open source content management framework (CMF) written in PHP. Drupal consists of a content management system (CMS) and a PHP development framework. You can use Drupal to build dynamic websites that provide various features and services. Drupal is commonly used in a variety of applications from personal blogs to large communities. This topic describes how to build a Drupal e-commerce website on an Elastic Compute Service (ECS) instance that runs Alibaba Cloud Linux 2, Alibaba Cloud Linux 3, or CentOS 7.x.
Preparations
Create the ECS instance on which you want to build a Drupal website. For more information, see Create an instance on the Custom Launch tab.
The ECS instance meets the following requirements:
The ECS instance is assigned a public IP address by the system or is associated with an elastic IP address (EIP). For information about how to associate an EIP with an ECS instance, see Associate or disassociate an EIP.
The ECS instance runs Alibaba Cloud Linux 2, Alibaba Cloud Linux 3, or CentOS 7.x.
Inbound rules are added to a security group of the ECS instance to open ports 22, 80, and 443. For information about how to add an inbound security group rule, see Add a security group rule.
Build a Linux, Apache, MySQL, and PHP (LAMP) stack.
For more information, see Build a LAMP stack on an Alibaba Cloud Linux or CentOS 7.x instance.
Procedure
Connect to the ECS instance on which a LAMP stack is built.
For more information, see Connect to a Linux instance by using a password or key.
Install the required PHP dependencies for Drupal.
sudo yum install -y php-gd php-pdo php-opcache php-xml php-dom php-simplexml
Download the Drupal installation package.
Download and decompress the Drupal installation package.
In the following example, Drupal 10.3.0 is installed. If you want to install another version of Drupal, make sure that all required dependencies are installed. For more information, see Installing Drupal.
wget https://ftp-origin.drupal.org/files/projects/drupal-10.3.0.tar.gz tar -zxvf drupal-10.3.0.tar.gz
Move the installation files to the root directory of your Apache website.
sudo mv drupal-10.3.0/* /var/www/html sudo mv drupal-10.3.0/.* /var/www/html
Download the Chinese language package.
cd /var/www/html wget -P sites/default/files/translations https://ftp-origin.drupal.org/files/translations/all/drupal/drupal-10.3.0-beta1.zh-hans.po
Configure Drupal.
Grant write permissions to 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 write permissions to the file.sudo cp sites/default/default.settings.php sites/default/settings.php sudo chmod a+w sites/default/settings.php
Enable clean URLs for the Apache service.
Open the Apache configuration file.
sudo vim /etc/httpd/conf/httpd.conf
Press the
I
key to enter Insert mode.In the root directory of the Apache website, change
AllowOverride None
toAllowOverride All
.In the following example, the root directory of the Apache website is
<Directory "/var/www/html">
.Restart the Apache service.
sudo systemctl restart httpd
Install Drupal.
Open a web browser on your on-premises device and enter
http://<Public IP address of the ECS instance>
in the address bar to go to the Drupal installation page.Select the language that you want to use from the Choose language drop-down list and click Save and continue.
Select Standard and click Save and continue.
NoteThe system automatically checks whether the current environment meets the installation requirements.
Specify a database file and click Save and continue.
After Drupal is installed, enter the site information on the Configure site page and click Save and continue.
After the installation is complete, visit the Drupal website and customize the website based on your business requirements.
ImportantAfter the installation is complete, we recommend that you run the following commands to remove the write permissions from the
sites/default
andsites/default/files
directories and thesites/default/settings.php
file to 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