All Products
Search
Document Center

Elastic Compute Service:Build a Drupal website on an Alibaba Cloud Linux 2, Alibaba Cloud Linux 3, or CentOS 7.x instance

Last Updated:Jul 30, 2024

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

  1. 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.

  2. 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

  1. 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.

  2. Install the required PHP dependencies for Drupal.

    sudo yum install -y php-gd php-pdo php-opcache php-xml php-dom php-simplexml
  3. Download the Drupal installation package.

    1. 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
    2. 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
    3. 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
  4. Configure Drupal.

    1. Grant write permissions to the sites/default/files directory.

      sudo chmod a+w sites/default/files
    2. 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
    3. Enable clean URLs for the Apache service.

      1. Open the Apache configuration file.

        sudo vim /etc/httpd/conf/httpd.conf
      2. Press the I key to enter Insert mode.

      3. In the root directory of the Apache website, change AllowOverride None to AllowOverride All.

        In the following example, the root directory of the Apache website is <Directory "/var/www/html">.

        image

      4. Restart the Apache service.

        sudo systemctl restart httpd
  5. Install Drupal.

    1. 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.

    2. Select the language that you want to use from the Choose language drop-down list and click Save and continue.

      选择安装语言

    3. Select Standard and click Save and continue.

      Note

      The system automatically checks whether the current environment meets the installation requirements.

      选择安装方式

    4. Specify a database file and click Save and continue.

      设置数据库

    5. After Drupal is installed, enter the site information on the Configure site page and click Save and continue.

      设置站点信息

  6. After the installation is complete, visit the Drupal website and customize the website based on your business requirements.

    后续操作

    Important

    After the installation is complete, we recommend that you run the following commands to remove the write permissions from the sites/default and sites/default/files directories and the sites/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