All Products
Search
Document Center

Elastic Compute Service:Build a Drupal website on an ECS instance

Last Updated:May 15, 2026

Deploy the Drupal CMS on a LAMP stack to build a dynamic website on an ECS instance.

Prerequisites

  1. An ECS instance is created and meets the following requirements:

  2. A LAMP stack is deployed.

    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

  1. Connect to the ECS instance. See Log on to a Linux instance using Workbench.

  2. 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
  3. Download Drupal.

    Go to the Apache default directory and use Composer to download Drupal. This creates a my_site directory. You can specify a version such as 11.1.0.

    Important

    If 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"
  4. Configure Drupal.

    1. 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
    2. Enable clean URLs for Apache.

      1. Open the Apache configuration file.

        sudo vim /etc/httpd/conf/httpd.conf
      2. Press I to 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 press Enter to save and close the file.

      3. Restart Apache.

        sudo systemctl restart httpd
  5. Install Drupal.

    1. In a web browser, go to http://<Public IP address of the ECS instance>/my_site/web to open the Drupal installation page.

    2. Select a language and click Save and continue.

      image

    3. Select Standard and click Save and continue.

      image

    4. 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 with sudo systemctl restart httpd.

        image

    5. Configure the database parameters and click Save and continue.

      image

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

      image

      image

  6. Go to the Drupal website and configure settings based on your business requirements.

    Next steps

    Important

    After the installation is complete, remove the write permissions from sites/default, sites/default/files, and sites/default/settings.php 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

FAQ

What do I do if I cannot access a Drupal website?

  1. Check whether PHP-FPM and MySQL are running.

    1. Query the status of PHP-FPM:

      sudo systemctl status php-fpm
      • If the status is Running, proceed to the next step.

      • If the status is not Running, start PHP-FPM:

        sudo systemctl start php-fpm
    2. Query the status of MySQL:

      sudo systemctl status mysqld
      • If the status is Running, proceed to the next step.

      • If the status is not Running, start MySQL:

        sudo systemctl start mysqld
  2. Check whether the Drupal and PHP versions are compatible.

    Drupal requires a minimum PHP version. If your PHP version is incompatible, Drupal cannot be installed. See Drupal PHP requirements.

    If the PHP version is incompatible, uninstall it and install a matching version.