Drupal is a powerful open-source content management system (CMS) known for its flexibility and extensibility, making it an ideal choice for developers, marketers, and agencies to build complex websites and applications. This guide is designed to help newcomers navigate the process of installing Drupal on Ubuntu 23.04, offering detailed instructions with real command-line examples for each step of the installation and configuration process.
Step 1: Install Apache and PHP Extensions
Drupal requires a web server and PHP to run. Although you might already have Apache installed from the LAMP stack setup, you need to install specific PHP extensions that Drupal depends on.
- Update your package index:
sudo apt update
- Install PHP extensions required by Drupal:
sudo apt install php-gd php-xml php-mbstring php-json php-mysql -y
Step 2: Create a MySQL Database and User for Drupal
Drupal stores its content in a database. Here’s how to create a MySQL database and a user for Drupal:
- Log in to MySQL as the root user:
sudo mysql -u root -p
- Create a database for Drupal:
CREATE DATABASE drupal_db;
- Create a MySQL user and grant all privileges on the Drupal database:
CREATE USER 'drupal_user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON drupal_db.* TO 'drupal_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Make sure to replace 'password'
with a strong password of your choice.
Step 3: Install Drupal
With the environment ready, you can proceed to download and install Drupal.
- Navigate to the Apache web root directory:
cd /var/www/html
- Download the latest version of Drupal: You can find the latest version of Drupal on the official Drupal website. Use
wget
to download it directly to your server, for example:
sudo wget https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz
- Extract the Drupal archive and move it to a directory named
drupal
:
sudo tar -zxvf drupal.tar.gz
sudo mv drupal-* drupal
- Set the correct permissions for the Drupal directory:
sudo chown -R www-data:www-data /var/www/html/drupal
sudo chmod -R 755 /var/www/html/drupal
Step 4: Configure Apache for Drupal
Create an Apache virtual host file for your Drupal site.
- Create a new Apache configuration file for Drupal:
sudo nano /etc/apache2/sites-available/drupal.conf
- Add the following configuration to the file, adjusting
ServerAdmin
,ServerName
, andDocumentRoot
as necessary:
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName example.com
DocumentRoot /var/www/html/drupal
<Directory /var/www/html/drupal>
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
- Enable the new site and Apache’s rewrite module, then restart Apache:
sudo a2ensite drupal.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
Step 5: Finalize Drupal Installation
Navigate to your website in a web browser and follow the Drupal installation process. You’ll need to enter the database details you created earlier and configure your site settings.
After installing Drupal on Ubuntu 23.04, consider Shape.host for hosting your Drupal site. Shape.host offers Linux SSD VPS services, ensuring high performance, reliability, and scalability for your website or application. With Shape.host, you benefit from SSD storage for faster access to data, robust security features to protect your site, and the flexibility to scale resources according to your needs. Shape.host’s Linux SSD VPS solutions provide an optimal environment for running Drupal, allowing you to focus on building and managing your site without worrying about the underlying infrastructure.