Install Contao on Ubuntu 20.04 LTS - Step by step guide ?

Ubuntu

 

Contao is an open-source content management system (CMS). It is designed for ease of use to allow business owners and power users to create powerful and dynamic content websites. Contao can also be integrated into a regular Symfony application.

Here at Fixwebnode, as part of our Server Management Services, we regularly help our Customers to perform related Linux system Software Installation queries on Ubuntu Linux System.

In this context, we shall look into how to install Contao on Ubuntu 20.04 LTS.

 

Steps to Install Contao on Ubuntu 20.04 LTS Focal Fossa

1. Perform System Update

To begin, ensure that all your system packages are up-to-date by running the following apt commands in the terminal:

$ sudo apt update
$ sudo apt upgrade

 

2. Install the LAMP stack

Now, we will install the LAMP stack on Ubuntu Linux system.

i. First, we will Install Apache by running the following command:

$ sudo apt install apache2

After the installation is completed, you should enable Apache to start automatically upon server boot with:

$ sudo systemctl --now enable apache2

You can also check the status of your Apache service with the following command:

$ sudo systemctl status apache2

ii. Next, you can create an apache virtual host and change the file name and the domain name to reflect your actual domain name:

$ sudo nano /etc/apache2/sites-available/your-domian.com.conf

The add the following to the file:

$ sudo mkdir -p  /var/www/html/your-domian.com/web 
<VirtualHost *:80>
ServerAdmin admin@your-domian.com
ServerName your-domian.com
ServerAlias www.your-domian.com
DocumentRoot /var/www/html/your-domian.com/web
ErrorLog ${APACHE_LOG_DIR}/your-domian.com_error.log
CustomLog ${APACHE_LOG_DIR}/domain2.com_access.log combined
<Directory  /var/www/html/your-domian.com/web>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

Save the file then exit, then change the domain's webroot permission with this command:

$ sudo chown -R www-data. /var/www/html/your-domian.com/web

Contao requires us to activate the apache mod_rewrite. In Ubuntu, mod_rewrite is not enabled by default, we need to run this command below to enable it:

$ sudo a2enmod rewrite

Remember, always check your Apache configuration to make sure there is no type or other issues by running this command prior to restarting it:

$ sudo apache2ctl -t
$ sudo systemctl restart apache2

iii. Next, we will Install MySQL. In Ubuntu 20.04, MySQL 8 is available in the repository and we will install the MySQL server. To do this, simply run the following command:

$ sudo apt install mysql-server -y

By running the command above, you will install MySQL 8 on your Ubuntu 20.04 server.

 

3. Install Composer

Now, Run the following command below to install Composer https://linuxapt.com/blog/401-install-php-composer-on-ubuntu-20-04 to your system:

$ sudo curl -sS https://getcomposer.org/installer -o composer-setup.php
$ sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Verify and check the Composer version:

$ composer -V

 

4. Configure MariaDB

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script. you should read and below each step carefully which will set a root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:

$ mysql_secure_installation

Configure it like this:

- Set root password? [Y/n] y
- 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

Next, we will need to log in to the MariaDB console and create a database for the Contao by executing the following command:

$ mysql -u root -p

This will prompt you for a password, so enter your MariaDB root password and hit Enter. Once you are logged in to your database server you need to create a database for Contao installation:

CREATE DATABASE contaodb;
CREATE USER 'contaouser'@'localhost' IDENTIFIED BY 'Your-Strong-Passwd';
GRANT ALL PRIVILEGES ON `contaodb`.* TO 'contaouser'@'localhost';
FLUSH PRIVILEGES;

 

5. Install Contao on the system

Now we install Contao using Contao Manager, First, let's enter /var/www/html/your-domain.com/web and download the contao package:

$ cd /var/www/html/your-domian.com/web
$ sudo -u www-data wget https://download.contao.org/contao-manager/stable/contao-manager.phar -O contao-manager.phar.php

 

How to access Contao Web Interface ?

  1. Once successfully installed, open up your favorite browser and navigate to http://your-domian.com in the address bar. You will see Contao Manager login page,
  2. You would need to fill the forms to create an account. After clicking on the 'Create Account' button, the script will check your server and once finished you can click on the 'Setup' button.
  3. Next, you can choose which Contao version to install and the installation type, click on Finish.
  4. The script will download Contao files and perform a composer install, this step will take a few minutes to complete.
  5. If there is no issue, you will be brought to the next step and update the database.
  6. Then, we shall continue this by clicking on the green 'Update Database' button. This action will bring you to http://your-domain.com/contao/install.
  7. This is where the installation begins, you need to click on the Accept license button and follow the steps to finalize the installation. The installation process will ask you to fill the database credentials and create an administrator user and password.
  8. Once completed, you can go to your Contao backend at http://your-domain.com/contao using the credentials you created in the previous step.
  9. This is where you are now after logging in to the Contao backend. In this page, you can see some menus to navigate.
  10. Unlike any other CMS-es, you need to create your own index page, and you can follow the documentation at https://docs.contao.org/manual/en/guides/add-first-index-page/

 

[Need help in fixing Linux System issues ? We can help you. ]

 

 


Conclusion

This article covers how to install Contao which is an open source content management system (CMS) on Ubuntu 20.04 LTS Focal Fossa system. In fact, Contao is a powerful open source content management system (CMS) that is easy to use, intuitive, and versatile and it allows you to create websites in multiple languages and themes.

Your Cart