How to Install Drupal with Apache Support on Ubuntu 24.04
- 25 steps
- Needs administrator rights
Drupal with Apache on Ubuntu 24.04 sets up a free content management system (CMS) to build and run websites on your server. Drupal is open-source software that stores your site pages, while Apache acts as the web server to load them for visitors.
Ubuntu 24.04 hosts all these files and services on your system. This setup gets your new website online and ready for content.
The full stack has four parts: Apache as the web server, MariaDB as the database, PHP to run Drupal’s code, and the Drupal files themselves. You install them in that order, then add a virtual host so Apache knows where your site lives, and finish in the browser with Drupal’s install wizard.
Before you start, make sure you have an Ubuntu 24.04 server, a user account with sudo rights, and an internet connection. If you plan to use a domain name, point its DNS record at the server’s IP address now so it can resolve by the time you reach the SSL step. Allow about 20 to 30 minutes.
To install Drupal with Apache on Ubuntu 24.04, first run sudo apt update and sudo apt install apache2 to set up the web server, then add MariaDB, PHP and the Drupal files. Apache starts immediately. Open http://localhost in a browser and the Apache2 Default Page confirms it is running.
Install Apache HTTP server on Ubuntu Linux
Install Apache HTTP server on Ubuntu Linux to handle incoming web traffic for your Drupal site. Apache is a reliable web server that works well with PHP and MySQL. Open your terminal and run the standard package manager commands to download and start the Apache service on your system.
Apache is the first piece to install because everything else sits behind it. Ubuntu 24.04 includes Apache 2.4 in its default repositories, so you don’t need to add any third-party source.
To do that, open the Ubuntu terminal and run the commands below to install the Apache web server.
- Open the terminal on your Ubuntu server, or connect to it over SSH.
- Run the commands in the block below. The first refreshes the package list and the second installs Apache.
- If prompted to confirm, type Y and press Enter. The install is finished when you get the shell prompt back with no errors.
sudo apt update
sudo apt install apache2
Once Apache is installed, the commands below can start, stop, and enable the Apache web server to start automatically when your server boots up.
On Ubuntu, Apache usually starts on its own right after installation. Still, run the enable command so the service comes back after every reboot. If you ever need to stop it for maintenance, the stop command does that, and you start it again with the start command.
sudo systemctl stop apache2
sudo systemctl start apache2
sudo systemctl enable apache2
You test that the Apache web server is running by opening your web browser and browsing to the server’s localhost or IP address.
- Open a web browser on the server itself, or on any computer that can reach it.
- Type one of the addresses shown below in the address bar, using localhost if you are on the server, or its IP address if you are on another machine.
- Press Enter.
http://localhost

When you see the Apache2 Default Page, it means the Apache HTTP server is successfully installed.
Additional help on installing Apache on Ubuntu is in the link below.
Install MariaDB database server on Ubuntu Linux
Install MariaDB database server on Ubuntu Linux to store all your Drupal site content, user accounts, and settings. MariaDB is a fast and open-source database system that connects securely with PHP. Use the terminal to install the server package and complete the basic security setup.
To install and use the MariaDB database server, use the instructions below.
Open the Ubuntu terminal and run the commands below to install the MariaDB database server.
- Open the terminal if it is not already open.
- Run the install command from the block below.
- Confirm with Y if asked. When the prompt returns without errors, MariaDB is installed.
sudo apt update sudo apt install mariadb-server
Once the MariaDB database server is installed, use the commands below to stop, start, and enable the MariaDB server to start automatically when the server boots.
As with Apache, the enable command is the one that matters most. It makes sure the database is running after a reboot, so your site doesn’t show a database error when the server restarts.
sudo systemctl stop mariadb sudo systemctl start mariadb sudo systemctl enable mariadb
Run the following commands to validate and test if the MariaDB database server is installed successfully.
These commands check the service status and then connect to the database console. Run them in the order shown in the block below.
sudo mariadb
Once you run the commands above, it will log you onto the MariaDB console and display a message similar to the one below.
The prompt changes to the MariaDB prompt when you are logged in. Your screen should show text like the block below, including the server version.
Welcome to the MariaDB monitor. Commands end with ; or g. Your MariaDB connection id is 32 Server version: 10.11.2-MariaDB-1 Ubuntu 23.04 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. MariaDB [(none)]>
The message tells you that the server is installed successfully.
If you get an access denied error instead, you most likely need to run the command with sudo. Type exit to leave the console when you are done.
Additional help on installing MariaDB.
- How to install MariaDB on Ubuntu Linux
- MariaDB without password prompt
Create a Drupal database
Create a Drupal database in MariaDB by opening the database command line interface and running SQL queries. You need a dedicated database and a secure user account so Drupal can read and write application data without sharing permissions with other services.
Using a separate database and user for each application is a good habit. If one site is ever compromised, the damage stays limited to that one database.
This database will store the Drupal application content and data.
We will create a database called drupaldb. We will also create a database user account called drupaldbuser.
Grant drupaldbuser full access to the drupaldb database, allowing the Drupal application to create and manage tables necessary for its operation. This step ensures that Drupal can properly store and retrieve all its content and configuration data on the MySQL server.
The access is limited to that one database. The user cannot touch any other database on the server.
All the database steps above can be done using the commands below:
Do this in two parts: first log on to the MariaDB console, then run the SQL statements inside it.
But first, log on to the MariaDB database server:
- Run the login command from the block below in the terminal.
- Check that the prompt changes to the MariaDB prompt before you go on.
sudo mariadb
Then run the commands below to complete the steps:
- Paste or type the statements from the block below at the MariaDB prompt, one at a time.
- Press Enter after each statement. Each one should reply with a short confirmation such as Query OK.
- If you see a syntax error, check for a missing semicolon or quote at the end of the statement and run it again.
CREATE DATABASE drupaldb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER drupaldbuser@localhost IDENTIFIED BY 'type_your_password_here';
GRANT ALL ON drupaldb.* TO drupaldbuser@localhost WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit
Ensure to replace ‘type_your_password_here‘ with your password.
Install PHP on Ubuntu Linux
Install PHP on Ubuntu Linux along with the required modules like php-mysql and php-intl to make Drupal run correctly. Drupal is built on PHP, and your server needs these specific software extensions to process site code, handle languages, and connect to your database.
Ubuntu 24.04 ships PHP 8.3 by default, which current Drupal releases support. The Apache PHP module is also needed so Apache can run PHP files.
Run the commands below to install PHP.
- Run the install command from the block below in the terminal.
- Confirm with Y if asked and wait for the packages to finish installing.
- Restart Apache afterwards if the PHP module was not picked up, so it loads the new PHP files.
sudo apt install php libapache2-mod-php php-intl php-mysql php-curl php-cli php-zip php-gd php-common php-mbstring php-xml php-opcache php-readline php-sqlite3 php-zip php-apcu
Additional help on installing PHP
Download Drupal files
Download Drupal files directly to your Ubuntu web directory using the command line tool wget or curl. This places the core website software into the correct Apache folder so visitors can load your new site in their web browsers.
Check the Drupal website for the latest release number before you download, and make sure the version in the commands matches the one you want.
The command block below will download and create a new Drupal folder in the Apache root directory.
It runs in three short stages: create the folder, download and unpack Drupal in a temporary location, then move the files into place.
First, create a Drupal folder in the Apache root directory.
Please change it to the /tmp directory and download Drupal files. Unzip the file and move the content into the created Drupal folder.
Working in /tmp keeps the downloaded archive out of your web folder. Once the files are moved, the Drupal folder should contain items like core, modules, themes and index.php directly, not another nested folder. If you see an extra folder level, move its contents up one level.
Apache web server permissions must change to allow the web server to read Drupal files for proper website operation. Specifically, you should set the ownership of the Drupal installation directory to the Apache user, which is typically `www-data` on Ubuntu 24.04. This ensures Apache can access and serve the Drupal core, modules, and themes correctly.
Drupal also needs to write to its settings and uploaded files during setup, so wrong ownership is a common reason the install wizard fails later. Run the commands in the block below to apply the ownership and permissions.
sudo mkdir -p /var/www/drupal
cd /tmp/
wget https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz
tar -xvf drupal.tar.gz
sudo mv drupal-*/* /var/www/drupal
sudo chown -R www-data:www-data /var/www/drupal/
sudo chmod -R 755 /var/www/drupal/
Once you have completed all the above steps, continue below to configure the Apache web server to serve the Drupal content.
Run the commands below to create an Apache virtual host file for Drupal.
A virtual host file tells Apache which domain name or IP address maps to which folder. Running the command below opens a new, empty file in a text editor.
sudo nano /etc/apache2/sites-available/drupal.conf
Then, copy and paste the content block below into the Apache server block.
Before you save, edit the values in the block to match your setup. Change the server name to your own domain or server IP address, and check that the document root points to the Drupal folder you created earlier.
<VirtualHost *:80>
ServerName drupal.example.com
ServerAlias www.drupal.example.com
ServerAdmin admin@example.com
DocumentRoot /var/www/drupal
<Directory /var/www/drupal/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/drupal/>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>
</VirtualHost>
Save the file.
In the nano editor, press Ctrl+O then Enter to write the file, and Ctrl+X to exit.
The server block enables Apache to serve your Drupal website. Run the commands `sudo a2ensite drupal.conf` and `sudo systemctl restart apache2` to turn on the server block and restart the Apache server for your Drupal installation.
The restart is required, because Apache only reads new site files when it restarts or reloads. If Apache fails to restart, it usually points to a typo in the virtual host file, so reopen the file and check it. Also, if clean URLs do not work later, check that Apache’s rewrite module is enabled and that the Drupal directory allows .htaccess overrides.
sudo a2ensite drupal.conf
sudo a2enmod rewrite
sudo systemctl reload apache2
sudo systemctl restart apache2
Setup Let’s Encrypt SSL/TLS for Drupal
Setup Let’s Encrypt SSL/TLS for Drupal to encrypt all traffic between your visitors and your server. An SSL certificate protects user passwords and personal data while helping your site build trust and rank better in search engines.
Let’s Encrypt certificates are free, and Certbot renews them automatically. This step needs a real domain name that already points to your server. It will not work with a bare IP address.
Please read the post below for additional resources on installing and creating Let’s Encrypt SSL certificates for Apache.
How to set up Let’s Encrypt SSL certificate for Apache on Ubuntu Linux
After installing, the Apache server block file /etc/apache2/sites-available/drupal.conf will automatically be configured with HTTPS, done by the Certbot Apache plugin.
Open the file afterwards to confirm that the HTTPS settings were added. The HTTPS version of the site needs port 443 open in your firewall, in addition to port 80.
Once you have restarted the Apache web server, open your browser and browse to the server hostname or IP address defined in the Apache server block.
- Restart Apache if you have not done so since the last change.
- Open your browser and type the server hostname or IP address from the Apache server block in the address bar.
- Press Enter. The Drupal install wizard should open. If you still see the Apache default page, the new site is probably not enabled yet, or the server name in the virtual host does not match what you typed.
http://drupal.example.com
A new Drupal installation wizard will appear. Choose a language and continue to the next page.
- Select your language from the list.
- Click Save and continue.

Next, select the installation profile.
The Standard profile is the usual pick, since it includes the common content types and features most sites need. Minimal gives you a bare-bones install if you prefer to build everything yourself. Make your choice and continue.

Then, type in the database name, username, and password created above.
- Make sure the database type is MySQL, MariaDB, Percona Server, or equivalent.
- Enter the database name, the database user name and the password you created earlier.
- Continue to the next page. Drupal will now install its modules, which can take a minute or two.
If the wizard reports that it cannot connect, go back and check the three values for typos and confirm MariaDB is running. If it complains about file permissions, review the ownership step earlier in this guide.

Finally, set up your site name and create an admin account to login in.
Enter a site name, an admin user name, a strong password and a working email address. This admin account has full control over the site, so keep its password safe. Then finish the wizard.

Your new Drupal site should be created and ready to use.
Log in with the admin account you just created to open the administration area and start adding content. Drupal may show a status report with a few warnings after installation. Review them, since they often point to small settings worth fixing before the site goes public.

That should do it!
Conclusion:
- Installing Drupal with Apache support on Ubuntu is a robust choice for creating and managing websites of varying complexities.
- Combining Apache and Drupal ensures compatibility with modules and extensions, creating a stable and efficient environment.
- Let’s Encrypt SSL/TLS for Drupal to secure the site with HTTPS, enhancing its security and trustworthiness.
- The step-by-step guide provided comprehensive instructions for installing and configuring Drupal with Apache support, ensuring a successful setup.
- Users are encouraged to provide feedback or seek additional assistance via the comments section for queries or improvements.
Have a question about this guide?
Answered by AI from this guide. Good questions may be added to this page — please don't include personal details.
Did this guide fix your problem?
About the Author
Richard
Tech Writer, IT Professional
Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.
No comments yet — be the first to share your thoughts!