We currently host 4 websites with a single install of Contao CMS. This installation of Contao was hosted from our own unit's Linux server. This article covers how I moved the four websites from our unit's server to OIT hosted Linux server. Many pointers on how to move the Contao sits were taken from the Contao documentation
The move can be broken down into 7 steps:
- Create domain aliases
- Confige Apache httpd.conf file virtual host
- Copy over the files
- Change file ownership
- Copy the database
- Run the Contao install tool
- Configure the websites in Contao backend
1. Create domain aliases
Let's say that we had websites with following URLs:
I wanted to bring up the websites on the new server with different URLs. This would allow me to troubleshoot any problems with them and reduce the downtime to the production URLs. To do this, I requested 4 new DNS aliases to be assigned to the OIA Linux server from OIT Networking Services. Let's call these aliases:
Now I have URLs for my 4 websites that are all pointing to the new server.
2. Confige Apache httpd.conf file virtual host
In order to direct these aliases to correct location on the server I configured Apache to use Name Based virtual hosts. Since all four websites are hosted with Contao, I need to create one virtual host directive for the main server URL (name.unitname.umn.edu) and second virtual host directive for the 4 sites that are served with Contao.
allow from all
Options Indexes FollowSymLinks
Allow from all
ServerAlias siteB2.unitname.umn.edu siteC2.unitname.umn.edu siteD2.unitname.umn.edu
3. Copy over the files
Next, I created a compressed file of all files and directories of contaosites folder on the old server. This is where all the files are stored that make up the four websites. I copied the compressed file to the new server and uncompressed into /swadm/web/contaosites folder.
4. Change file ownership
In order for the Contao CMS application to work all files and folder have to be owned by the user account that is used by Apache webserver. On the old server which ran Ubuntu Linux, this account was www-data. On the new server which is Red Hat, the Apache runs under a user account called apache. Changing file ownership is something that swadm user account is not allowed to do. I send an email to oialinux at umn dot edu asking them to make this change.
5. Copy the database
Created a mysql dump file (mysqldum -B contaodb) of the Contao database and imported it into the mysql database ( mysql database < contaodb.sql) on the new server. I used this MySQL tutorial for the syntax.
6. Run the Contao install tool
Next I accessed http://name.unitname.umn.edu/contaosites/contao/install.php and logged in with the install tool username and password that I had used for my initial Contao installation on the old server. The installation tool allowed me to enter my database username and password to be used by Contao CMS.
7. Configure the websites in Contao backend
Once I had configured the database connection, I could access Contao backend by going to http://name.unitname.umn.edu/contaosites/contao with my browser and log in. Once logged in I navigated to Site Structure and changed the site website root DNS for each for the site to use the new aliases.
With this all 4 websites are active with new URLs. Once I have verified that everything works properly, I can transfer the correct site URLs to the new server.