Drupal Installation on Ubuntu
Drupal Installation on Ubuntu
Prerequisites
2. Root access or user with sudo privileges
You can check whether you have the proper Ubuntu version installed on your server with the following command:
lsb_release -a
You should get this output:
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal
Then, run the following command to make sure that all installed packages on the server are updated to the latest available version
sudo apt update && sudo apt upgrade
2. Install and Configure Web server
Drupal 9 supports many webservers, like Apache, nginx, LiteSpeed, even Microsoft IIS. In this tutorial, we will show you how to install Drupal 9 using apache or nginx on your Ubuntu 20.04. Drupal will be installed in directory /var/www/html/drupal. For this purpose, we need to create the directory.
sudo mkdir /var/www/html/drupal
a. Apache
If you want to use Apache, run this command to install it from the repository.
sudo apt install apache2
Once installed, Apache will run and we can start creating a virtual host.
sudo nano /etc/apache2/sites-available/drupal.conf
Paste the following in to /etc/apache2/sites-available/drupal.conf file. If you want change any other port, change it in there <VirtualHost *:______>.
<VirtualHost *:80>
ServerName drupal.libsciinfo.com
ServerAlias drupal.libsciinfo.com
ServerAdmin admin@libsciinfo.com
DocumentRoot /var/www/html/drupal/
CustomLog ${APACHE_LOG_DIR}/access.log combined
ErrorLog ${APACHE_LOG_DIR}/error.log
<Directory /var/www/html/drupal>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>
</VirtualHost>
Save the file then exit from nano editor. To enable the virtual host, let’s run this command:
sudo a2ensite drupal
As you can see in the Apache virtual host above, it contains Rewrite Rule. By default, the Apache mod rewrite in Ubuntu is not enabled. So, we need to enable the module and restart Apache.
sudo systemctl restart apache2
b. nginx
If you want to use nginx instead of apache, run this command to install it.
sudo apt install nginx
Now, let’s create an nginx server block to proceed with Drupal 9 installation.
sudo nano /etc/nginx/sites-enabled/drupal.conf
Paste the following contents in to the file
listen 80;
root /var/www/html/drupal;
index index.php index.html index.htm;
server_name drupal.libsciinfo.com;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; allow all; }
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
log_not_found off;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Save the file then exit.
3. Install Database Server
Drupal 9 requires MariaDB 10.3+ or MySQL/Percona 5.7.8+ or higher, PostgreSQL 10.0 or higher, SQLite 3.26 or higher, the database server is needed to store your Drupal data. In this step, we will install MariaDB from Ubuntu repository.
Run the following command to install the MariaDB server from the official Ubuntu repositories:
sudo apt install mariadb-server mariadb-client -y
Once installed, MariaDB will run and it’s already configured to run after reboot, by default. Next, secure the MariaDB installation using the following command:
sudo mysql_secure_installation
This script will set the MariaDB root password, disable remote root login and remove anonymous users as shown below:
Enter current password for root (enter for none):
Set root password? [Y/n] Y
New password: Admin@123 (Note down for database login)
Re-enter new password: Admin@123
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
4. Create a Database
Login to the MySQL cli as the root user and execute the following commands:
mysql -u root -p
You will be prompted for your MySQL root password, you create the password in the previous step. And, once logged in, run these commands.
CREATE DATABASE drupal9;
CREATE USER 'drupal9'@'localhost' IDENTIFIED BY 'Admin@123';
GRANT ALL PRIVILEGES ON drupal9.* TO 'drupal9'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Make sure to replace the ‘localhost‘ is the IP address of your Ubuntu 20.04 server where Drupal 9 will be installed, or you can also use ‘localhost’. Do not forget to replace the PASSWORD ‘Admin@123’ with a stronger and unique one.
5. Install PHP
In this section, we will install PHP 7.4. Rung the command below to install PHP 7.4
sudo apt install php7.4 libapache2-mod-php7.4 php7.4-{common,mbstring,xmlrpc,soap,gd,xml,intl,mysql,cli,zip,curl,fpm} -y
Once all the packages are installed, we will need to edit the php.ini file and modify some settings:
If PHP 7.4 then run below command
sudo gedit /etc/php/7.4/apache2/php.ini
If PHP 8.1 then run below command
sudo gedit /etc/php/8.1/apache2/php.ini
memory_limit = 512M
upload_max_filesize = 256M
post_max_size = 256M
max_execution_time = 300
output_buffering = off
date.timezone = Asia/Kolkata or America/Chicago
If you choose to use Apache, run this command and restart Apache.
sudo a2enmod php7.4
sudo systemctl restart apache2
If you choose nginx, simply restart nginx after installing PHP 7.4
sudo systemctl restart nginx
6. A. Install Drupal 9
In this section, we will download and install Drupal 9. At the time of writing this blog post, Drupal 9.3.3 is the latest version, you can check it at their release page at https://www.drupal.org/project/drupal. According to their documentation, this Drupal version 9.3.x will receive security coverage until December 8, 2022. Don't run both Drupal 9 and Drupal 10 commands. Install Drupal 9 or Drupal 10 any one of these.
cd /var/www/html
sudo wget https://ftp.drupal.org/files/projects/drupal-9.3.3.tar.gz
Once downloaded, we need to extract the compressed file.
sudo tar xzvf drupal-9.3.3.tar.gz -C /var/www/html/drupal --strip-components=1
Then, change the permissions.
sudo chown -R www-data. /var/www/html/drupal
Navigate to http://localhost/ and initiate the installation.
(OR)
B. Install Drupal 10
For Drupal 10 Version run this command
cd /var/www/html
sudo wget https://ftp.drupal.org/files/projects/drupal-9.3.3.tar.gz
Once downloaded, we need to extract the compressed file.
sudo tar xzvf drupal-9.3.3.tar.gz -C /var/www/html/drupal --strip-components=1
Then, change the permissions.
sudo chown -R www-data. /var/www/html/drupal
Navigate to http://localhost/ and initiate the installation.
Web installation: http://localhost/
1. Choose your desired language then click on the save and continue button.
2. Choose Profile ‘Standard’ then continue.
3. Database Configuration
Database Type: MySQL
Database Name: drupal9
Database Username: drupal9
Database Password: Admin@123
Leave other setting default
4. Configure Site
Site Name: Lib Science Info
Site Email: libsciinfo@blogspot.com
User Name: marimuthuofl (for site login account)
Password: Admin@12345678 (for site login account)
Email: libsciinfo@blogspot.com
Country: India
Time: Kolkata
Save and continue button to finalize the installation. And that’s it, you will be automatically redirected to your Drupal website’s backend.
https://linuxhostsupport.com/blog/how-to-install-drupal-9-cms-on-ubuntu-20-04/
Comments
Post a Comment