Installing Drupal on Debian 🌱

  1. Log into the Debian device
  2. Run the following commands in a terminal:
    # update repositories and install any available software updates
    sudo apt update
    sudo apt upgrade -y
    # install Apache HTTPD and MySQL
    sudo apt-get install apache2 mariadb-server mariadb-client curl
    # install PHP components
    sudo apt install php php-mysql php-cli php-json php-opcache php-gd php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip
    # configure the MySQL database
    sudo su
    mysql_secure_installation
  3. Press Enter to login as root
  4. Type Y and press Enter to set a root password, type the password twice to confirm
  5. Type Y and press Enter to remove anonymous users
  6. Type Y and press Enter to disallow root login remotely
  7. Type Y and press Enter to remove the test database
  8. Type Y and press Enter to reload privilege tables
  9. Run the following command to login into MySQL:
    mysql -u root -p
  10. Authenticate with the root password set earlier
  11. Run the following commands to create the Drupal database and database user
    CREATE DATABASE drupal DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
    GRANT ALL ON drupal.* TO 'drupal_rw'@'localhost' IDENTIFIED BY 'Dru4@l!!';
    FLUSH PRIVILEGES;
    EXIT;
    exit
  12. Continue with the following commands to download and extract Drupal in the Apache webroot
    # download latest drupal version
    sudo wget -O drupal.tar.gz https://www.drupal.org/download-latest/tar.gz
    # extract drupal.tar.gz
    sudo tar xzvf drupal.tar.gz --directory /var/www
    # rename drupal folder
    sudo mv /var/www/drupal* /var/www/drupal
    # create a new drupal.conf file to configure the site
    sudo nano /etc/apache2/sites-available/drupal.conf
  13. Paste the following configuration into drupal.conf

    Alias /drupal "/var/www/drupal/"
    <Directory /var/www/drupal/>
        AllowOverride All
    </Directory>

  14. Press CTRL+O, Enter, CTRL+X to write the changes to drupal.conf
  15. Continue with the following commands to enable the site and restart Apache:
    # enable the Drupal site and required PHP modules
    sudo a2ensite drupal
    sudo a2enmod rewrite
    # set the owner of the new drupal directory to www-data
    sudo chown -R www-data:www-data /var/www/drupal
    # restart apache2 service
    sudo systemctl restart apache2
  16. Open a web browser and navigate to http://DNSorIP/drupal
  17. The Drupal setup screen should be displayed
  18. Select a language > Click Save and continue
  19. Select the Standard profile > Click Save and continue
  20. Enter the database name, username and password > Click Save and continue
  21. Create a site title and Drupal login > Click Install Drupal
  22. When the installation completes, enter a site name, email address, username and password > Click Save and continue
  23. Welcome to your very own, self-hosted Drupal installation