Tutorial

Installing Contao CMS on an Ubuntu 12.04 VPS

Published on March 28, 2014
Installing Contao CMS on an Ubuntu 12.04 VPS

Status: Deprecated

This article covers a version of Ubuntu that is no longer supported. If you are currently operate a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu:

Reason: Ubuntu 12.04 reached end of life (EOL) on April 28, 2017 and no longer receives security patches or updates. This guide is no longer maintained.

See Instead: This guide might still be useful as a reference, but may not work on other Ubuntu releases. If available, we strongly recommend using a guide written for the version of Ubuntu you are using. You can use the search functionality at the top of the page to find a more recent version.

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.

Prerequistes

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

Download

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

Database

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.

Install

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.

http://your-ip/contao/install.php

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:

local_enable=YES
write_enable=YES

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.

<div class=“author”>Submitted by: <a href=“http://www.webomelette.com/”>Danny Sipos</a></div>

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
1 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.