How to Install Joomla on Ubuntu Linux with Apache

web desk 3345988 640

This brief post shows students and new users how to install and use Joomla content management system (CMS) on Ubuntu Linux with Apache HTTP web server. This post will also have a link to setup free Let’s Encrypt SSL certificates to secure your Joomla websites and applications.

Joomla is a free and open source CMS based on PHP and MySQL that also has many features and thousands of plugins and template or themes. If you want to create an online website or store, Joomla might be the simplest way to do it, especially if you will need support from users to manage and maintain the site.

This tutorial is based on Ubuntu Linux. We’ll be installing Apache web server, MariaDB database server and PHP modules. We’ll also link to another post that will show you how to secure your Joomla website using Let’s Encrypt free SSL certificates.

For more about Joomla, please check its homepage

To get started with installing Joomla on Ubuntu Linux, follow the steps below:

How to install Apache on Ubuntu Linux

As mentioned above, we’re going to be using Apache web server to run Joomla. Joomla requires a web server to function, and Apache is one of the most popular open source web servers available today.

To install Apache on Ubuntu, run the commands below:

sudo apt update
sudo apt install apache2

After installing Apache, the commands below can be used to stop, start and enable Apache services to always start up everytime your server starts up.

sudo systemctl stop apache2.service
sudo systemctl start apache2.service
sudo systemctl enable apache2.service

To test whether Apache is installed and functioning, open your web browser and browse to the server’s IP address or hostname.

http://localhost

apache2 test page

If you see the above page in your browser, then Apache is working as expected.

How to install MariaDB on Ubuntu Linux

A database server is required for Joomla to function. Joomla stores its content in a database, and MariaDB is probably the best database server available to run Joomla.

MariaDB is fast, secure and the default server for almost all Linux servers. To install MariaDB, run the commands below:

sudo apt install mariadb-server
sudo apt install mariadb-client

After installing MariaDB, the commands below can be used to stop, start and enable MariaDB services to always start up when the server boots.

sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

Next, run the commands below to secure the database server with a root password if you were not prompted to do so during the installation.

sudo mysql_secure_installation

When prompted, use the guide below to answer:

If you've just installed MariaDB, and haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): PRESS ENTER

Switch to unix_socket authentication [Y/n] n

Change the root password? [Y/n] n

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

All done!

To verify and validate that MariaDB is installed and working, login to the database console using the commands below:

sudo mysql -u root -p

You should automatically be logged in to the database server since we initiated the login request as root. Only the root can login without password, and only from the server console.

mariadb welcome

If you see a similar screen as shown above, then the server was successfully installed.

How to install PHP on Ubuntu Linux

As we also mentioned above, we’re installing PHP on Ubuntu since Joomla requires it. PHP packages are added to Ubuntu repositories. The versions the repositories might not be the latest. If you need to install the latest versions, you’ll need to add a third party PPA repository.

To a third party repository with the latest versions of PHP, run the commands below.

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php

At the time of this writing, the latest PHP version 8.0.

sudo apt update

Next, run the commands below to install PHP 8.0 and related modules.

sudo apt install php8.0 php8.0-common php8.0-mysql php8.0-gmp php8.0-curl php8.0-intl php8.0-mbstring php8.0-xmlrpc php8.0-gd php8.0-xml php8.0-cli php8.0-zip

Next, you’ll want to change some PHP configuration settings that work great with Joomla. Run the commands below to open PHP default configuration file.

sudo nano /etc/php/8.0/apache2/php.ini

Then change the line settings to be something line the lines below. Save your changes and exit.

file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 256M
cgi.fix_pathinfo = 0
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/Chicago

How to create Joomla database on Ubuntu

At this point, we’re ready to create Joomla database. As mentioned above, Joomla uses databases to store its content.

To create a database for Joomla, run the commands below:

sudo mysql -u root -p

Then create a database called joomladb

CREATE DATABASE joomladb;

Next, create a database user called joomladbuser and set password

CREATE USER 'joomladbuser'@'localhost' IDENTIFIED BY 'new_password_here';

Then grant the user full access to the database.

GRANT ALL ON joomladb.* TO 'joomladbuser'@'localhost' WITH GRANT OPTION;

Finally, save your changes and exit.

FLUSH PRIVILEGES;
EXIT;

How to download Joomla

We’re ready to download Joomla and begin configuring it. First, run the commands below to download the latest version of Joomla from its repository.

To view Joomla releases, see this page.

At the time of this writing, the latest version is 4.0.2. Future version will have different links to download from.

Run the commands below to download and extract Joomla version 4.0.2.

cd /tmp
wget https://downloads.joomla.org/cms/joomla4/4-0-2/Joomla_4-0-2-Stable-Full_Package.zip
sudo unzip -d /var/www/joomla /tmp/Joomla_4-0-2-Stable-Full_Package.zip

Then run command below to allow www-data user to own the Joomla directory.

sudo chown -R www-data:www-data /var/www/joomla/
sudo chmod -R 755 /var/www/joomla/

How to configure Apache for Joomla

We have downloaded Joomla content into a new folder we called Joomla. Now, let’s configure Apache to create a new server block to use with our Joomla website. You can create as many server blocks with Apache.

To do that, run the commands below to create a new configuration file called joomla.conf in the /etc/apache2/sites-available/ directory to host our Joomla server block.

sudo nano /etc/apache2/sites-available/joomla.conf

In the file, copy and paste the content below into the file and save.

<VirtualHost *:80>
  ServerName example.com
  ServerAlias www.example.com
  ServerAdmin admin@example.com
  DocumentRoot /var/www/joomla
    
  <Directory /var/www/joomla/>
       Options FollowSymlinks
       AllowOverride All
       Require all granted
  </Directory>

       ErrorLog ${APACHE_LOG_DIR}/error.log
       CustomLog ${APACHE_LOG_DIR}/access.log combined
    
</VirtualHost>

Save the file and exit.

After saving the file above, run the commands below to enable the new file that contains our Joomla server block. Restart Apache after that.

sudo a2ensite joomla.conf
sudo systemctl reload apache2

At this stage, Joomla is ready and can be launched by going to the server’s IP or hostname.

http://localhost

However, we want to make sure our server is protected with Let’s Encrypt free SSL certificates. So, continue below to learn how to generate Let’s Encrypt SSL certificate for websites.

How to setup Let’s Encrypt for Joomla

We have written a great post on how to generate and manage Let’s Encrypt SSL certificates for Apache web server. You can use that post, to apply it here for your Joomla website.

To read the post on how to generate Let’s Encrypt SSL certificates for website, click on the link below:

How to Setup Let’s Encrypt on Ubuntu Linux with Apache – Website for Students

If you were successful in generating a Let’s Encrypt SSL certificate, you should then reopen the server block for our Joomla website by running the commands below.

sudo nano /etc/apache2/sites-available/joomla.conf

The new Joomla server blocks configurations should look similar to the line below. Take notes of the highlighted lines.

  • The first server block listens on port 80.  It contains a 301 redirect to redirect HTTP to HTTPS.
  • The second server block listens on port 443. It contains a 301 redirect to redirect www to non-www domain.
<VirtualHost *:80>
  ServerName example.com
  ServerAlias www.example.com

  Redirect permanent / https://example.com/
</VirtualHost>

<VirtualHost *:443>
  ServerName example.com
  ServerAlias www.example.com
  DocumentRoot /var/www/joomla

  Protocols h2 http:/1.1

  <If "%{HTTP_HOST} == 'www.example.com'">
    Redirect permanent / https://example.com/
  </If>
  
  ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
  CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined

  SSLEngine On
  SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
  SSLOpenSSLConfCmd DHParameters "/etc/ssl/certs/dhparam.pem"
  
  SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384

  SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
  SSLCompression off
  SSLUseStapling on

  Header always set Strict-Transport-Security "max-age=63072000"

  <Directory /var/www/joomla/>
       Options FollowSymlinks
       AllowOverride All
       Require all granted
  </Directory>
 
</VirtualHost>

Save the file above, then restart Apache and PHP using the commands below.

sudo systemctl reload apache2

Finally, if everything went as planned, you should be able to start Joomla setup wizard by browsing to the server hostname or IP address over HTTPS.

https://example.com/

A Joomla setup wizard should appear. Follow the wizard to complete the setup.

Select the installation language, Site Name, Super User account details, including email address, username and password.

Then click Next to continue.

Joomla installation on Ubuntu

On the next screen, enter the database info created above and click Next to continue.

Joomla installation on Ubuntu

Next, validate that all requirements and packages are installed.

After that, click Install to complete the wizard.

Joomla installation on Ubuntu

You can now login to the admin backend and begin setting up your website environment.

Joomla installation on Ubuntu

When you’re done, Joomla should be installed and ready to use. Login as admin and begin configuring your site.

Joomla installation on Ubuntu

That’s it!

Conclusion:

This post showed you how to install Joomla on Ubuntu Linux with link to setting up Let’s Encrypt. If you find any error above, or have something to add, please use the comment form below.

4 Comments

  1. Thanks for this very clear manual.
    I use kubuntu 21.04
    The result of following everything repeatedly, to be sure, was that in localhost I didn’t get an installation, but the text of index.php. In Vivaldi nicely formatted, in Firefox not formatted.
    I had installed php according to your directions, got php8.
    Though, when I uninstalled all php-files (yes, sounds like the desperation it was), and installed php8 with the synaptic package manager (php8-mysql included) things started happening.
    No more text of index.php, only straight into a j4.x fatal error, in both browsers, though I had finally arrived in the joomla installation, so php now worked.
    Just to inform you.
    Don’t know how to solve that new problem, but I don’t think that has anything to do with your directions. Again, only to inform you:
    The solution joomla gave:

    edit /configuration.php
    Change
    $debug = false;
    to
    $debug = true;

    to get a REAL error message didn’t help, because I did find a configuration.php-dist file, where $debug already was true, only $debug_lang was false, making that true did not help, of course.
    But I suppose that has nothing to do with your clear installation manual.
    I don’t know whether it has to do with the above, but I got the impression that
    sudo systemctl reload apache2
    did not do very much: I couldn’t see any effects of changing /etc/apache2/sites-available/joomla.conf.
    It is now:

    ServerName localhost
    ServerAlias localhost
    ServerAdmin admin@localhost
    DocumentRoot /var/www/

    Options FollowSymlinks
    AllowOverride All
    Require all granted

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined


    Directing it to /home/jan/public_html didn’t work, for instance.
    Anyway, thanks again.

    1. I missed a line. Need to run the commands below to enable the virtual host.

      sudo a2ensite joomla.conf

      1. Thanks. Only it did not make any visible difference, still fatal error.
        And I installed also php8.1 with the synaptic package manager. I saw in some log that it was directed to, again no difference. I’ll keep trying… 😉

  2. Whatever I retried, I failed, so because I was afraid that I had spoiled unknowingly my installation I reinstalled kubuntu 21.04.
    Then followed again your directions and succeeded. 🙂
    After I reinstalled kubuntu I saw that now php.8.0 was not available in the Synaptic Package Manager (it said that 7.4 was the last known stable version), so I also followed you redirection for php.
    Because my first post now appears to be meaningless it serves no purpose and I am fully ok with you removing it.
    Thanks again for your clear directions.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.