Open Source Content Management Framework

Staging/Live Setup

  1. Staging Setup Overview
  2. Step by Step Instructions
    1. Test the connection
    2. Create a Live Blobs Directory
    3. Modify /var/lib/aegir/etc/config.pl
    4. Remove duplicate Aegir files and symlink to their Midgard clones
    5. Correct /var/lib/aegir/bin/repligard_staging_to_live.sh
    6. Modify /var/lib/aegir/etc/repligard_hourly_dump_staging.conf
    7. You need to make sure the following PERL Modules are installed
    8. Edit the crontab file
    9. Run the following commands
    10. Test Aegir by pointing your browser to

The method of Staging/Live described here is now deprecated in favor of the new system running on Midgard and Java Content Repository.

Staging Setup Overview

In most Aegir setups it is desirable that content is shown on the site only when it is approved, and that changes in content also require approval. Typically the staging/live concept is used here.

In staging/live you have two Midgard databases, either running on same system or on separate computers.

One of the databases is called staging, and that is where content is created and tested.

When content is approved it is then replicated to the live database.

This replication process is handled with Repligard. Repligard itself doesn't know anything about checking approvals, so some third party scripts are needed.

The Aegir-dirs package (available from http://www.midgard-project.org/projects/aegir/download) provides these scripts for you:

downgrade_unapproved.pl This script is called by the staging_to_live script. It goes through the Midgard database and determines which objects are approved and which are not. It then modifies the repligard table in the database, setting the "updated" field to NULL for each unapproved object. Because updated is marked as NULL repligard should not include these objects to the replication run.

repligard_staging_to_live.sh This script runs the required commands for transferring content from staging database to live database. The commands are:

  • Downgrade "updated" fields for unapproved content
  • Export updated objects from staging database
  • Import the exported file to live database

Note that these scripts assume that they're located in /var/lib/aegir/bin, and that they have the required configuration files (also from aegir-dirs package) in /var/lib/aegir/etc.

To make this replication process automatic, you should add the repligard_staging_to_live.sh command to cron. The typical way to run it is hourly.

In addition, Aegir has the "Publish" button in main navigation. If you want this button to initiate almost-instanteous replication, you can add the following command to be run every minute from cron:

if [ -r "/tmp/runreplication" ]  
  then  
    /var/lib/aegir/bin/repligard_staging_to_live.sh > /dev/null  
    rm /tmp/runreplication  
fi

Because the staging/live implementation uses Repligard for transferring data between the servers (or databases), your websites need to be written to be Repligard-safe.

Step by Step Instructions

  1. ### Setting the staging server port

Log into Aegir as 'System administrator' and click on the 'Company' tab.
Click on 'System Config'.
Make sure the Port of Staging Server value is set to 8001.

  1. ### Converting to a Staging/Live Setup

Go to the Tools Tab on the left.
Click on the 'Convert Images' link.
Click on the 'Convert to Staging' link.
Fill in the confirmation phrase and click Submit.
Aegir is going to stop working temporarily after this step.

  1. ### Creating the initial database

Before continuing you will need to create the live database.

$ mysqldump -u root -p midgard > /tmp/midgard.sql  
Enter password: (enter mysql root password)   

$ mysqladmin -u root -p create midgardlive  
Enter password: (enter mysql root password)   

$ mysql -u root -p midgardlive < /tmp/midgard.sql  
Enter password: (enter mysql root password)   

$ mysql mysql -u root -p  
Enter password: (enter mysql root password)  

>update db set Db='midgard%' where db='midgard';  
>\q  

$ mysqladmin -u root -p flush-privileges  
Enter password: **(enter mysql root password)**
  1. Test the connection

    $ mysql midgardlive -u midgard -p

    Enter password: (enter midgard db password)

    mysql>\q

  2. Create a Live Blobs Directory

    $ cp -r /var/lib/midgard/blobs/midgard /var/lib/midgard/blobs/midgardlive

  3. Modify /var/lib/aegir/etc/config.pl

Change 'midpass' to your midgard database password.

$DBNAME = "midgard";   
$DBUSER = "midgard";  
$DBPASSWD = "midpass";  
$BLOBS = "midgard";  

#LIVE SERVER  
$LIVEDBNAME = "midgardlive";  
$LIVEBLOBS = "midgardlive";   
$STAGINGPORT = 8001;  
$LIVEPORT = 80;  
$SSLPORT = 443
  1. Remove duplicate Aegir files and symlink to their Midgard clones

    $ cd /var/lib/aegir/etc/
    $ rm -f repligard_withsg.xml
    $ rm -f repligard.xml
    $ ln --symbolic /usr/share/midgard/repligard_withsg.xml repligard_withsg.xml
    $ ln --symbolic /usr/share/midgard/repligard.xml repligard.xml

  2. Correct /var/lib/aegir/bin/repligard_staging_to_live.sh

    Line 6 should read REPLIGARD not REPLGARD

  3. Modify /var/lib/aegir/etc/repligard_hourly_dump_staging.conf

Edit the following lines

<database  
    schema="/usr/share/midgard/repligard_withsg.xml"  
    name="midgard"  
    username="midgard"  
    password="midpass" **<** **use midgard db password here**
    encoding="ISO-8859-1"
    blobdir="/var/lib/midgard/blobs/midgard"
/>

<!-- Login account description for Repligard operation -->

<login 
    username="admin"
    password="password" **< password for the admin user**
/>
  1. ### Modify /var/lib/aegir/etc/repligard_hourly_import_live.conf

Edit the following lines

<database  
    schema="/usr/share/midgard/repligard_withsg.xml"  
    name="midgardlive"  
    username="midgard"  
    password="midpass" **<** **use midgard db password here**
    encoding="ISO-8859-1"
    blobdir="/var/lib/midgard/blobs/midgardlive"
/>

<!-- Login account description for Repligard operation -->

<login 
    username="admin"
    password="password" **< password for the admin user**
/>
  1. You need to make sure the following PERL Modules are installed

    install DBI::DBD
    install DBI
    install DBD::mysql

If required install the PERL modules used by the scripts using CPAN (you may need to do a 'perl -MCPAN -e shell' if this is the first time)
or
use Webmin to install them

  1. Edit the crontab file

    nano /etc/crontab

Add the following lines

01 * * * * root /var/lib/aegir/bin/repligard_staging_to_live.sh
* * * * * root /var/lib/aegir/bin/nadminstudio.sh
  1. Run the following commands

    $ touch /tmp/apachemodified
    $ cd /var/lib/aegir/bin/
    $ ./repligard_staging_to_live.sh
    $ ./nadminstudio.sh

  2. Test Aegir by pointing your browser to

http://hostname.mydomain.com:8001/aegir
and login as 'admin'

Congratulations! You now have an Aegir CMS setup with staging/live capabilities.

Designed by Nemein, hosted by Kafit