Steps to Install & Configure Drupal on Ubuntu

Drupal is a free & open source content management system (CMS),which is written in PHP and released under GPL.It is used for creation of dynamic websites, even quite complex ones.

Prerequisites:

  • Ubuntu machine with Sudo Privileges.

There are some steps to setup Drupal on Ubuntu:

Step 1: Update the System.

apt update

Step 2:Install Apache2.

apt install apache2

  • Start & Enable the Apache2 service.

systemctl start apache2
systemctl enable apache2

Step 3: Install PHP.

apt install php libapache2-mod-php php-cli php-fpm php-json php-common php-mysql php-zip php-gd php-intl php-mbstring php-curl php-xml php-pear php-tidy php-soap php-bcmath php-xmlrpc

Step 4: Install MySQL Server.

apt install mysql-server

  • Start & Enable the MySQL server.

systemctl start mysql
systemctl enable mysql

Step 5: Configure the MySQL Database.

  • Login to MySQL Shell.

mysql -u root -p

  • Provide the Password or Press the Enter.
  • Here is the command output.

  • Create a User & Set a password.

CREATE USER drupal_user@localhost IDENTIFIED BY "Password";

  • Create database.

create database drupaldb;

  • Run Grant all privileges command.

GRANT ALL ON drupaldb.* TO drupal_user@localhost;

  • Run Flush privileges & Exit commands.

FLUSH PRIVILEGES;
exit

  • Here is the command output.

Step 6: Now Download the Drupal on system.

wget https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz

  • Here is the command output.

  • Extract the downloaded folder.

tar -xvf drupal.tar.gz

  • Move the extracted folder to /var/www/html/.

mv drupal-9.3.9 /var/www/html/drupal

  • Provide the following permissions.

chown -R www-data:www-data /var/www/html/drupal/
chmod -R 755 /var/www/html/drupal/

  • Here is the command output.

Step 7: Configure the Apache virtual host file.

  • Create a file.

vim /etc/apache2/sites-available/drupal.conf

  • Add the following lines:

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/drupal/
ServerName example.com
ServerAlias www.example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html/drupal/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/html/>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>
</VirtualHost>

  • Here is the output.

  • Disable the default file.

a2dissite 000-default.conf

  • Enable the file.

a2ensite drupal.conf

  • Run rewrite command.

a2enmod rewrite

  • Restart the Apache2 service.

systemctl restart apache2

  • Here is the command output.

Step 8: Open Drupal Web Interface.

http://server-ip

  • Here is the output.
  • Select the Language.
  • Click on Save & Continue.

  • Select Standard profile for Installation.
  • Click on Save & Continue.

  • Configure the database,provide the db username,db name & db password.
  • Click on Save & Continue.

  • Now Installation is started.

  • Configure the Site.
  • Provide the required information such as Site name,Email-address,username & password.

  • Select country & Time zone.
  • Click on Save & Continue.

  • Now Drupal is Ready.

Leave a Reply