Getting started.

Install a LAMP server

To get our software up and running you first need to install a LAMP server, the Subversion version control system, and other tools that will help in development. Assuming you are running an Ubuntu environment this can be done via the following.

sudo apt-get update
sudo apt-get install lamp-server^
sudo apt-get install php5-cli
sudo apt-get install phpmyadmin
sudo apt-get install subversion

During installation, you will be asked to select a root user and corresponding password for MySQL. To confirm that the lamp server is up and running, navigate to http://localhost. You should see the following.

Likewise, to check that phpmyadmin is installed correctly, navigate to http://localhost/phpmyadmin. Hopefully it looks like this.

You should be able to login using the root username and password you selected earlier.

The default LAMP installation serves files from the /var/www directory. The Apache configuration file is located here /etc/apache2/sites-available/default. Since we will be altering this file in the next section, and since we will be using subversion extensively, you might want to read about placing your /etc directory under version control.

Installing property management software

Next, lets prepare a place to contain the software in your home directory.

cd ~
mkdir projects
cd projects
svn co http://www.nerdsofgotham.com/svn/pms/branch/appukp pms

appukp is your exclusive branch of the code and it will be exported into the pms directory.

We will now need to point Apache’s webroot to the checked out web directory. First, we will need to change the Apache user and group to be yours.

cd /etc/apache2/
vi envvars

you need to change the following lines to correspond to your username and group.

export APACHE_RUN_USER=your_username
export APACHE_RUN_GROUP=your_group

Depending on your distribution, you may need to update the Apache config file ( /etc/apache2/sites-available/default ) so that it allows Apache to follow symlinks. Make sure that the <Directory “/var/www” > section of the config file looks like below. In particular that you allow the FollowSymLinks option for this directory. Secondly, to see Symfony’s debugging icons, add the section corresponding to the Alias /sf.

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
 
        DocumentRoot /var/www
        <Directory "/var/www" >
                Options Indexes FollowSymLinks MultiViews
                AllowOverride all
                Order allow,deny
                Allow from all
        </Directory>
 
        Alias /sf /home/your_username/projects/pms/lib/vendor/symfony/data/web/sf
        <Directory "/home/your_username/projects/pms/lib/vendor/symfony/data/web/sf">
                AllowOverride All
                Allow from All
        </Directory>
 
        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>
 
        ErrorLog ${APACHE_LOG_DIR}/error.log
 
        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
 
        CustomLog ${APACHE_LOG_DIR}/access.log combined
 
    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
 
</VirtualHost>

To have these changes take affect you will need to restart the Apache server.

sudo apache2ctl restart

Next, we will need to set up the database. I have written a small script to get this done. You can find it below.

cd ~/projects/pms/data/sql
mysql -u root -p < setup_databases.sql

Now lets build the app.

cd ~/projects/pms
bash build

At last, you should be able to navigate to the app http://localhost/pm_dev.php .

Merging two similar directories via subversion.

grep “^M” ~/Desktop/modified_files.txt | sed “s/^M[ \t]*\(.*\)/mv pms_backup\/\1 pms\/\1/g” > movefiles

What this does: copys files from pms_backup directory to pms directory. the command svn status, identifies modified files with a ‘M’ in the initial line, followed by some white-space. the [ \t]* matches all spaces and tabs (\t). the \(.*\) says to match everything and to store it all in variable \1. the rest is straight-forward.

Using SVN to keep /etc files under version control.

If you have every had to tamper with configuration files (typically in the /etc directory), you know the value of having prior versions of these files at hand to revert to in case things go wrong. Placing the configuration files in any Linux distribution under version control is useful, and straight forward to implement. Let us start by creating a subversion repository for the files. If you already have a subversion repository, skip down to the the next section and replace “/var/svn/etc” with the path to your repository. This location should be empty.

Installing Subversion

If you have not done so already, you can install subversion on Ubuntu through the following command.

sudo apt-get install subversion

Creating the SVN repository

We shall create the repository under /var/svn. though of course you can choose to place it somewhere else.

  sudo svnadmin create /var/svn

We shall now create a directory in the repository to store our /etc files.

  sudo svn mkdir file:///var/svn/etc

Checking in the configuration files.

Having created a subversion repository to store our configuration files in /var/svn/etc, the last step is to do an in place check in / check out of the files.

  cd /etc/
  sudo svn co file:///var/svn/etc .
  sudo svn add ./*
  sudo svn ci

Thats it! the files are now under version control. Basically the above procedure checks out the empty /var/svn/etc repository into the /etc directory, we then add and check in all the files found there.