We hope you find this tutorial helpful. In addition to guides like this one, we provide simple cloud infrastructure for developers. Learn more →

Installing Contao CMS on an Ubuntu 12.04 VPS

Posted Mar 27, 2014 6.9k views CMS Ubuntu

About Contao

Contao is an open source content management system (CMS) for websites of any size. It is a flexible and scalable system that implements high security, accessibility, and SEO standards. Contao is modular as you can use hundreds of additional extensions to add functionality to your site.

It is built using modern PHP object-oriented programming and the MooTools JavaScript framework. Additionally, Contao has an intuitive interface that uses Ajax for a great user experience.

In this article we will install Contao on our VPS running Ubuntu 12.04. For this, I assume you already have your VPS set up and that you are running the LAMP stack (Linux, Apache, MySQL, PHP). If you don't already, there's a great tutorial on DigitalOcean that can get you set up.


Before we download Contao, we'll need to make sure that our Apache server will allow it to use the .htaccess file to rewrite its URLs. This is important for creating pretty and search engine friendly URLs. The following steps are necessary only if your virtual server has yet to be configured in this way.

In this tutorial, we will install Contao into the root folder of our Apache server (/var/www). Edit the virtual host file that is responsible for this folder:

sudo nano /etc/apache2/sites-available/default

Inside the block marked with this beginning:

<Directory /var/www/>

Make sure that instead of AllowOverride None you have AllowOverride All.

The next thing we need to do is enable mod_rewrite (again if you don't already have it enabled). To check if it's already enabled, use the following command:

apache2ctl -M

If you see "rewrite_module" in the list, you are fine. If not, use the following command to enable the module:

a2enmod rewrite 

After making any changes to either the virtual host file or enabling an Apache module, you have to restart Apache:

sudo service apache2 restart


Before we download, let's switch to a user that is not root. If you don't already have another user, go ahead and create one.

Let's create a user called contao:

useradd contao
passwd contao

And then specify the password. Go ahead also and create the home folder for this user if it doesn't already exist:

mkdir /home/contao

And add the user to the sudo group:

sudo adduser contao sudo

Now log out of your box and ssh back into it using this new user.

Now we can proceed to the downloading of the Contao source file. Let's first navigate to the folder we want to install it in:

cd /var/www

Next, we can run a command to automatically download the tarball containing the latest version of Contao and untar it:

sudo curl -L http://download.contao.org | sudo tar -xzp

Now if you look in the /var/www folder you should see a directory called core-master. Change its owner to the contao user:

sudo chown -R contao core-master

We'll move its contents one folder up to the web server root folder:

sudo mv core-master/* /var/www
sudo mv core-master/.gitignore /var/www
sudo mv core-master/.gitattributes /var/www
sudo mv core-master/.htaccess.default /var/www

And then delete the superfluous core-master folder:

sudo rmdir core-master


Before proceeding with the installation itself, we'll need to create a new database for Contao to use. I will guide you through some quick steps to set up your MySQL database, but there is a good tutorial for more information.

The first thing you need to do is log in to MySQL from your terminal (you can use PHPMyAdmin as well if you want but I will show you how to do it from the command line):

mysql -u `username` -p`password`

From there, run the follwing command to create a database called contao:

create database contao;

You can change its name to something else if you want. And that's pretty much it. When we soon run the installer for Contao, you'll specify the information to connect to this database.


Contao has a nice web installation tool that we can use to install it. But let's take care of some permissions first.

Change the ownership of the following folders to your user and the www-data group:

sudo chown -R contao:www-data assets/images
sudo chown -R contao:www-data system/logs
sudo chown -R contao:www-data system/tmp

Next, set the permissions to the www-data group to be able to write to these folders:

sudo chmod -R 775 assets/images
sudo chmod -R 775 system/logs
sudo chmod -R 775 system/tmp

Now you can proceed to the following URL to access the installer.


The first screen on the installer will ask for the FTP credentials, which it will use to write in the system/config folder. You can provide them there.

If you don't already have FTP set up on your virtual server, you can read this tutorial to get you started. I will quickly show you how to set up VSFTPD.

Run the following commands to install VSFTPD:

sudo apt-get update
sudo apt-get install vsftpd

Now you have FTP on your VPS. Don't forget to disable access to anonymous user. (You can find more information in the linked article on how to do that).

But one thing you'll need to do is edit the configuration file:

sudo nano /etc/vsftpd.conf

And uncomment these lines to allow local users to access FTP:


Then restart VSFTPD:

sudo service vsftpd restart 

Once you successfully passed the screen with the FTP credentials, read and accept the license. On the next screen you have to specify a password (make sure it is 8 letters long). Following that, you'll have to specify the database credentials. If the connection is successful, you can click on the update database button for the installer to create the necessary tables in your database. Then create an administrator user account to finalize the installation process.

You can then proceed to your Contao backend at http://your-ip/contao/ and log in with the account you just created and make sure everything works normally. You'll probably notice a Build Cache button once you're logged in that you should click for Contao to build up its cache.

One final thing we need to do is rename the .htaccess.default file in the Contao root folder to simply .htaccess:

mv /var/www/.htaccess.default /var/www/.htaccess

Congratulations! You have installed Contao onto your cloud server.

Submitted by: Danny Sipos
Creative Commons License