Staging/Live Setup
- Staging Setup Overview
- Step by Step Instructions
- Test the connection
- Create a Live Blobs Directory
- Modify /var/lib/aegir/etc/config.pl
- Remove duplicate Aegir files and symlink to their Midgard clones
- Correct /var/lib/aegir/bin/repligard_staging_to_live.sh
- Modify /var/lib/aegir/etc/repligard_hourly_dump_staging.conf
- You need to make sure the following PERL Modules are installed
- Edit the crontab file
- Run the following commands
- Test Aegir by pointing your browser to
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
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
- ### 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.
- ### 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.
- ### 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)**
Test the connection
$ mysql midgardlive -u midgard -p
Enter password: (enter midgard db password)
mysql>\q
Create a Live Blobs Directory
$ cp -r /var/lib/midgard/blobs/midgard /var/lib/midgard/blobs/midgardlive
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
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.xmlCorrect /var/lib/aegir/bin/repligard_staging_to_live.sh
Line 6 should read REPLIGARD not REPLGARD
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**
/>
- ### 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**
/>
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
Add the following lines
01 * * * * root /var/lib/aegir/bin/repligard_staging_to_live.sh
* * * * * root /var/lib/aegir/bin/nadminstudio.sh
Run the following commands
$ touch /tmp/apachemodified
$ cd /var/lib/aegir/bin/
$ ./repligard_staging_to_live.sh
$ ./nadminstudio.shTest 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.
