DEV Community

MuthuKumar
MuthuKumar

Posted on • Edited on

Install Drupal on Ubuntu using the terminal

To install Drupal on Ubuntu using the terminal, you can follow these steps:

  1. Update System Packages: Open a terminal and update the package list to ensure you have the latest information about available packages.
   sudo apt update
Enter fullscreen mode Exit fullscreen mode
  1. Install Apache Web Server: Install the Apache web server using the following command:
   sudo apt install apache2
Enter fullscreen mode Exit fullscreen mode
  1. Install MySQL Database Server: Install MySQL server for your Drupal installation:
   sudo apt install mysql-server
Enter fullscreen mode Exit fullscreen mode

During the installation, you'll be prompted to set a root password for MySQL.

  1. Install PHP and Required Extensions: Install PHP and the required extensions for Drupal:
   sudo apt install php libapache2-mod-php php-mysql php-gd php-xml php-mbstring php-ldap php-xmlrpc php-curl
Enter fullscreen mode Exit fullscreen mode
  1. Create a MySQL Database for Drupal: Log into MySQL as the root user:
   sudo mysql -u root -p
Enter fullscreen mode Exit fullscreen mode

Enter the MySQL root password, then create a database, user, and grant privileges to the user:

   CREATE DATABASE drupaldb;
   CREATE USER 'drupaluser'@'localhost' IDENTIFIED BY 'your_password';
   GRANT ALL ON drupaldb.* TO 'drupaluser'@'localhost';
   FLUSH PRIVILEGES;
   EXIT;
Enter fullscreen mode Exit fullscreen mode
  1. Download and Extract Drupal: Navigate to your Apache web root directory:
   cd /var/www/html
Enter fullscreen mode Exit fullscreen mode

Download the latest Drupal package:

   sudo wget https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz
Enter fullscreen mode Exit fullscreen mode

Extract the archive:

   sudo tar -xzvf drupal.tar.gz
Enter fullscreen mode Exit fullscreen mode

Rename the extracted folder to something cleaner (e.g., drupal):

   sudo mv drupal-x.y.z drupal
Enter fullscreen mode Exit fullscreen mode
  1. Adjust Permissions: Set proper permissions for Drupal to access its files:
   sudo chown -R www-data:www-data drupal
Enter fullscreen mode Exit fullscreen mode
  1. Configure Apache: Create a new virtual host configuration file:
   sudo nano /etc/apache2/sites-available/drupal.conf
Enter fullscreen mode Exit fullscreen mode

Add the following configuration, adjusting paths and domains as needed:

   <VirtualHost *:80>
       ServerAdmin admin@example.com
       DocumentRoot /var/www/html/drupal
       ServerName your_domain.com

       <Directory /var/www/html/drupal/>
           Options Indexes FollowSymLinks
           AllowOverride All
           Require all granted
       </Directory>

       ErrorLog ${APACHE_LOG_DIR}/error.log
       CustomLog ${APACHE_LOG_DIR}/access.log combined
   </VirtualHost>
Enter fullscreen mode Exit fullscreen mode

Enable the virtual host and Apache modules:

   sudo a2ensite drupal
   sudo a2enmod rewrite
Enter fullscreen mode Exit fullscreen mode

Restart Apache to apply the changes:

   sudo systemctl restart apache2
Enter fullscreen mode Exit fullscreen mode
  1. Drupal Installation: Open a web browser and visit http://your_domain.com. Follow the on-screen instructions to complete the Drupal installation.

Remember to replace your_domain.com with your actual domain name and adjust other settings according to your needs. This guide assumes a basic setup; you might need to adjust some details based on your specific environment and security requirements.

Try it Yourself:

Top comments (0)