Installing Emergence Preview

Server OS Installation Guides

Emergence requires PHP 5.3. This guide assumes you already know how to work with a Linux/Apache/MySQL/PHP environment but for those that need help setting up the server operating system take a look at the guide below.

This guide is for installing the preview version of Emergence only. If you would like to use the latest version of Emergence please check out the GitHub page for it.

Setting Up Emergence Preview

Now let's download the emergence files and extract them in the right directory.

If you would like to use git you should init the directory /var/emergence/ and pull from our github.

If you don't have unzip run sudo emerge -av unzip

$ cd /var 
$ sudo wget http://emr.ge/pkgs/emergence-0.1.zip
$ sudo unzip -d . emergence-0.1.zip
Archive:  emergence-0.1.zip
   creating: ./emergence/apache2/
  inflating: ./emergence/apache2/localhost.conf.example
   creating: ./emergence/kernel/
  inflating: ./emergence/kernel/bootstrap.php
   creating: ./emergence/kernel/lib/
  inflating: ./emergence/kernel/lib/DB.class.php
  inflating: ./emergence/kernel/lib/Debug.class.php
  inflating: ./emergence/kernel/lib/Emergence.class.php
  inflating: ./emergence/kernel/lib/File.class.php
  inflating: ./emergence/kernel/lib/MICS.class.php
  inflating: ./emergence/kernel/lib/Site.class.php
  inflating: ./emergence/kernel/lib/SiteCollection.class.php
  inflating: ./emergence/kernel/lib/SiteFile.class.php
   creating: ./emergence/kernel/root/
 extracting: ./emergence/kernel/root/index.php
   creating: ./emergence/sites/
   creating: ./emergence/sites/example/

Make sure to change the owner of the emergence directory as well as all of it's contents to the apache user so that apache2 can read all these files we just made.

$ sudo chown -R apache:apache /var/emergence

You'll want to run this command any time there are new files in /var/emergence/.

Setting Up an Emergence Preview Site

Apache2

$ sudo cp /var/emergence/apache2/localhost.conf.example /var/emergence/apache2/example.conf

Now we need to configure the conf file for apache2 to recognize this site and respond to it.

$ sudo nano -w /var/emergence/apache2/example.conf

Since we copied the conf file from the included example most of the instructions are in the conf file already. After you are done configuring the conf file you still need to make the right directories for your site. For now we'll use the example directory that is already in /var/emergence/sites/.

Don't forget to restart apache before moving on to make sure the conf file is correctly setup.

$ sudo /etc/init.d/apache2 restart

Let's take this opportunity to make apache2 automatically start when the server turns on from a restart or power failure.

$ sudo rc-update add apache2 default

MySQL

Now we need to configure MySQL for the site.

First lets make a database and username for the site.

Generate yourself a password first.

$ echo `</dev/urandom tr -dc A-Za-z0-9-_\$\? | head -c12`
ZZCHiyG3U?Md

Of course the password you get will be different. Now login to MySQL so we can make the database and username.

$ mysql -u admin -p

mysql> CREATE DATABASE example;
Query OK, 1 row affected (0.10 sec)

mysql> GRANT ALL ON example.* TO example@localhost IDENTIFIED BY 'ZZCHiyG3U?Md';
Query OK, 0 rows affected (0.09 sec)

mysql> exit
Bye

Now we need give the site the username and password with which to connect to MySQL with.

$ sudo nano -w /var/emergence/sites/example/Site.config.php

Now we need to populate our existing database with tables necessary for Emergence to work.

$ sudo wget http://emr.ge/pkgs/skeleton.sql -O - | mysql example -u admin -p
Enter password:

Now we're finally on the last step!

We need to configure site inhiritence so that all the code can be inherited from the Emergence skeleton site. We also need to make some directories that our templating engine will use for a cache.

$ mkdir /tmp/dwoo-compiled /tmp/dwoo-cached
$ chown apache:apache /tmp/dwoo-compiled /tmp/dwoo-cached

Now let's login to MySQL to configure site inhiritince.

$ mysql -u admin -p

First select the database you made for the site.

mysql> USE example
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

Now we'll populate _e_hosts with two sites. One for this site and one for our skeleton from which the site will be inheriting it's directory structure.

Make sure to replace 127.0.0.1 with your site's hostname.

mysql> INSERT INTO `_e_hosts` (`Hostname`, `SiteID`) VALUES ('127.0.0.1', 1),('skeleton.mics.me', 2);
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

Now for the last step we need to insert two rows into _e_sites to define the hosts we just inserted as sites and to also provide the key which is necessary to establish an HTTP connection with the parent site.

For this one the key shown is the actual one being currently used by the skeleton site.

mysql> INSERT INTO `_e_sites` (`ID`, `Type`, `Title`, `PrimaryHostnameID`, `ParentID`, `AccessKey`) VALUES (1, 'Local', NULL, 1, 2, NULL), (2, 'Remote', NULL, 2, NULL, 'm6Q136L0mDsWmShJ');
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0