CMS

Installing and setting up your own Joomla website

published on
https://www.joomla.org/

Whilst most people appear to prefer Wordpress, and it certainly has more installations than Joomla, I prefer to use Joomla where I need something more powerful than a static site.

Install Apache

To begin setting up your Joomla website on the Apache webserver start by following the instructions found in 'Installing and setting up Apache in Ubuntu'. This will give you a good basis to work from although you won't need the modpagespeed section.

Install PHP

The instructions in the above article don't include installing everything you need for Joomla. It is now time to install the extra packages you will need. This can be done by entering

sudo apt install php7.4 php7.4-common,php7.4-cli,php7.4-bz2,php7.4-zip,php7.4-curl,php7.4-intl,php7.4-mysql
sudo apt install php7.4-snmp, php7.4-memcached, php7.4-bcmath, php7.4-readline, php7.4-soap, php7.4-tidy
sudo apt install php7.4-xmlrpc, php7.4-xml, php7.4-gd, php7.4-gmp, php7.4-pspell, php7.4-mbstring
sudo apt install php7.4-opcache, php7.4-fpm, php7.4-imagick, php7.4-redis, php7.4-mcrypt

Now open the php.ini file that Joomla will use and make the edits shown below.

sudo nano /etc/php/7.4/fpm/php.ini
        output_buffering = Off
        expose_php = off
        max_execution_time = 30
        max_input_time = 1000
        max_input_vars = 3000
        memory_limit = 256M
        display_errors = Off
        display_startup_errors = Off
        log_errors = On
        html_errors = Off
        post_max_size = 128M
        upload_max_filesize = 128M
        date.timezone = Europe/London
        opcache.enable=1
        opcache.memory_consumption=128
        opcache.max_accelerated_files=10000
        opcache.revalidate_freq=200

Edit /etc/php/7.4/fpm/pool.d/www.conf and make sure to edit or uncomment the following lines to look like they do here:

       listen = /run/php/php7.4-fpm.sock
       listen.owner = www-data
       listen.mode = 0660

Install the MariaDB database

The database is going to be where all your content, amongst other things, are stored ready for when somebody visits your site and Joomla reads the data it needs to be displayed to the user.

To install MariaDB type

sudo apt-get install mariadb-server
sudo mysql_secure_installation

Remember that when running mysql_secure_installation the first time there is no root password and you can simply press enter.

Now create the actual database by running mysql -u root -p and entering the following commands

CREATE DATABASE [database_name] charset=utf8mb4;
CREATE USER '[user_name]'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON [database_name].* TO '[user_name]'@'localhost';
FLUSH PRIVILEGES;
exit

where [database_name] is the name of the Joomla database, [user_name] is the name of the user who has access to the Joomla database and [password] is a strong password.

Install Redis

Redis helps to cache some of the database data in memory for faster access. I find it much better to have some kind of server cache set up rather than relying purely on extensions.

To install Redis enter sudo apt-get install redis-server php-redis at the command line. Now type sudo nano /etc/redis/redis.conf to edit the configuration file and add or edit the following lines

supervised systemd
maxmemory 256mb
maxmemory-policy allkeys-lru
bind 127.0.0.1 ::1

Lastly, it is necessary to restart the redis and php-fpm servers. This can be done with the following three commands

sudo systemctl restart redis-server.service
sudo systemctl enable redis-server.service
sudo systemctl restart php7.4-fpm

Download and install Joomla

First go to the directory that your domain is pointed to: cd /var/www/[domain] and create a new 'joomla' directory: sudo mkdir joomla.

Now you can download the Joomla compressed file and install it in your 'joomla' folder.

sudo wget https://downloads.joomla.org/cms/joomla3/3-10-2/Joomla_3-10-2-Stable-Full_Package.zip
sudo unzip Joomla_3-10-2-Stable-Full_Package.zip -d /var/www/[domain]/joomla

Now change permissions and ownership on these files and folders

chown -R www-data:www-data /var/www/[domain]/joomla
chmod -R 755 /var/www/[domain]/joomla

Make sure that your Apache virtual server configuration points to/var/www/[domain]/joomla and visit your domain in a browser.

Joomla will now take you through a number of options where you are asked to provide certain details so that it can connect to your database and set up the admin user for you.

Once you have completed these steps make sure to click on the 'Remove Installation Folder' button. Back on your server type sudo cp /var/www/[domain]/joomla/htaccess.txt /var/www/[domain]/joomla/.htaccess to set up the .htaccess rules.

Enable Redis

Even though you have installed Redis earlier you now need to let Joomla know how to connect to it. In the 'Admin' menu choose 'System' then 'Global Configuration' then 'system' and finally 'cache settings'. Change the settings to those shown below

Cache-Handler: Redis
Persistent Redis: Yes
Redis Server Host: localhost
Redis Server Port: 6379
Redis Server Authentication: leave empty
Redis Database: 0
Cache Time: 30
Platform Specific Caching: No
System Cache: On – conservative Caching

Remember to save your changes.

Conclusion

You should now have a fully working Joomla installation just waiting for you to set up your website and start adding content. Watch out for future Joomla articles covering various aspects of Joomla configuration.