Installing Contao on Debian Latest

Contao is an open-source content management system that allows you to easily manage your website's content, layout, and functionality. In this tutorial, we will guide you through the steps required to install Contao on a Debian system.

Requirements

Before you begin, ensure that your system meets the following requirements:

Step 1: Update system packages

To ensure that your system has the latest updates and security patches installed, run the following command:

sudo apt update && sudo apt upgrade -y

Step 2: Install Apache web server

Install Apache web server using the following command:

sudo apt install apache2 -y

Once the installation is complete, start the Apache service and enable it to start at boot time:

sudo systemctl start apache2
sudo systemctl enable apache2

Step 3: Install PHP

Contao requires PHP version 7.2 or later. Install PHP and its extensions using the following command:

sudo apt install php7.4 php7.4-mysql php7.4-curl php7.4-gd php7.4-imagick php7.4-json php7.4-mbstring php7.4-xml php7.4-zip -y

Once the installation is complete, restart the Apache service:

sudo systemctl restart apache2

Step 4: Install MariaDB database

Contao requires a MariaDB or MySQL database to store its content. Install the MariaDB server using the following command:

sudo apt install mariadb-server -y

Once the installation is complete, start the MariaDB service and enable it to start at boot time:

sudo systemctl start mariadb
sudo systemctl enable mariadb

Run the mysql_secure_installation script to secure your MariaDB installation:

sudo mysql_secure_installation

Step 5: Create a new MariaDB database and user

Login to the MariaDB server using the root user account:

sudo mysql -u root -p

Create a new database for Contao:

CREATE DATABASE contao;

Create a new user account and grant it full access to the Contao database:

CREATE USER 'contao_user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON contao.* TO 'contao_user'@'localhost';
FLUSH PRIVILEGES;

Replace password with a strong and secure password.

Exit the MariaDB console:

exit

Step 6: Download Contao package

Download the latest stable version of Contao from the official website:

cd ~
wget https://download.contao.org/latest.tar.gz

Once the download is complete, extract the archive:

tar -xvzf latest.tar.gz

Move the extracted files to the /var/www/html/ directory:

sudo rm -rf /var/www/html/*
sudo mv contao-*/ /var/www/html/

Set the correct ownership and permissions for the Contao files:

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

Step 7: Configure Contao

Copy the config/autoload/config_local.example.php file to config/autoload/config_local.php:

cp /var/www/html/app/config/autoload/config_local.example.php /var/www/html/app/config/autoload/config_local.php

Edit the config_local.php file and update the values for the database settings:

'doctrine' => [
    'dbal' => [
        'connections' => [
            'default' => [
                'driver' => 'pdo_mysql',
                'host' => 'localhost',
                'dbname' => 'contao',
                'user' => 'contao_user',
                'password' => 'password'
            ],
        ],
    ],
],

Replace password with the password you set for the contao_user account.

Step 8: Access Contao

Open your web browser and navigate to your server's IP address or domain name. You will see the Contao installation wizard page.

Follow the wizard's instructions to complete the installation process. Once the installation is complete, you can login to the Contao admin panel and start creating your website's content.

Conclusion

In this tutorial, you learned how to install Contao on a Debian Latest system. The next step is to explore the Contao documentation and learn more about the platform's features and capabilities. Happy coding!

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!