Creating a Joomla Testing Environment

Lately, I had the task of upgrading Joomla, due to a major version change. Before upgrading, it is important to check for the compatibility of the existing website. Therefore, I needed to take the entire website, not just the backend but also the database, and create a test environment on a virtual machine.

Some time ago, I used a virtual machine with a working Joomla installation from Bitnami. It was super easy: download, import into VirtualBox, and done—a running Joomla CMS. However, Bitnami by VMware is now part of Broadcom, and downloading the .ova file required login credentials and additional steps. Unfortunately, I was unable to obtain the file. So, I had to manually set up a working Joomla CMS on a local server.

Setup

Setting up the environment is straightforward. I created a VM with an Arch Linux minimal installation and configured port forwarding from port 55555 to 80. The website should then be accessible in your host machine’s browser via:

http://localhost:55555

Installation

I use an Apache server and MariaDB as the database. You will also need PHP for it to work:

sudo pacman -S apache php php-apache mariadb

You also need a copy of Joomla. Download the .zip file from the official website: https://www.joomla.org/

Configuration

Apache

Setting up an Apache server for our specific task is simple. After installing via pacman, open the httpd.conf file:

sudo nano /etc/httpd/conf/httpd.conf

Uncomment the lines:

LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule dir_module modules/mod_dir.so

Comment the line:

LoadModule mpm_event_module modules/mod_mpm_event.so

Add the following lines:

LoadModule php_module modules/libphp.so
AddHandler php-script php
Include conf/extra/php_module.conf

Ensure these lines are placed in the appropriate sections e.g. LoadModule statements should be grouped together and Include statements should align with existing Include directives.

Ensure the following section is configured correctly:

<Directory "/srv/http">
    AllowOverride All
    Require all granted
</Directory>

Database

Set up a database by running:

sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

Then, activate the database management system:

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

To create a database user, open MariaDB:

sudo mariadb -u root -p

The root user root@localhost (-u root) has no password, so leave blank and press Enter.

Then run the following commands:

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON joomla_db.* TO '$USER'@'localhost' IDENTIFIED BY '$PASSWD';
FLUSH PRIVILEGES;
quit

Replace $USER with your preferred username and $PASSWD with a strong password. Since this is a local VM, I used user and user for simplicity.

Now, create the database:

mariadb-admin -u '$USER' -p create joomla_db

Keep the database name as joomla_db for easier Joomla installation later.

PHP

Modify the PHP configurations by editing the php.ini file:

sudo nano /etc/php/php.ini

Uncomment the following lines (remove the ;):

extension=pdo_mysql
extension=mysqli

Additional PHP Settings

Joomla requires additional PHP settings for optimal performance:

sudo pacman -S php-gd

Then enable it in php.ini:

sudo nano /etc/php/php.ini

Uncomment the following lines:

extension=gd
extension=intl

Set:

output_buffering = Off

Do not use:

;output_buffering
;   Default Value: Off
;   Development Value: 0
;   Production Value: 0

Copy Joomla Files

Extract the contents of your downloaded Joomla .zip file and copy them to the /srv/http/ directory. Ensure that the files are directly in /srv/http/ and not in a subdirectory like /srv/http/joomla/.

Change ownership to allow Apache to read and write:

sudo chown -R http:http /srv/http

Run Joomla

Enable and start the Apache server:

sudo systemctl enable httpd.service
sudo systemctl start httpd.service

If everything is set up correctly, visit:

http://localhost:55555

Ensure you use the correct port. In my case, I use 55555 because of the VM. Normally, you would use 80.

Now, proceed with the Joomla installation. During setup, enter the database credentials: user@localhost with the password we created earlier. Leave the other settings as they are.

That’s it! You should now have a fully working local Joomla test environment.


Bonus: Migration from an Existing Site

Migrating an existing Joomla site to your local test environment is easy with the Akeeba Backup plugin: https://www.akeeba.com/ They provide a great tutorial for this process, which can be used instead of the “Copy Joomla Files” section.

Important Note: Disabling HTTPS Redirection For local machines, disable redirection from HTTP to HTTPS. Open the Joomla configuration file:

sudo nano /path/to/joomla/configuration.php

Set:

public $force_ssl = '0';