SilverStripe with Composer & Capistrano

Environment Setup

Update Ubuntu package lists dependencies:

apt-get update

Install LAMP stack:

sudo apt-get install lamp-server^

Enable ‘rewrite_module’ and restart apache:

a2enmod rewrite
service apache2 restart

Edit default config:

vi /etc/apache2/sites-enabled/000-default.conf

Add the following:

<VirtualHost *:80>
ServerAdmin zaid@pandauxstudio.com
DocumentRoot /var/www
ServerName pandauxstudio.com
ServerAlias www.pandauxstudio.com
<Directory /var/www/>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog logs/host.pandauxstudio.com-error_log
TransferLog logs/host.pandauxstudio.com-access_log
</VirtualHost>

Edit php.ini to add the timezone:

vi /etc/php5/apache2/php.ini

Uncomment timezone entry and set to:

date.timezone = Pacific/Auckland

Install PHP-GD graphics library:

apt-get updateapt-get install php5-gd

Restart Apache:

sudo service apache2 restart

Install Git:

apt-get install git

Install Composer PHP dependency manager

curl -s https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

Install SilverStripe (First time)

Checkout new empty git project

git clone https://pandauxstudio@bitbucket.org/pandauxstudio/pandauxstudio.git /var/www/pandauxstudio.com

Use composer to install SilverStripe

cd /var/www/pandauxstudio.comcomposer create-project silverstripe/installer html

Move files in parent directory

cd /var/www/pandauxstudio.com/html
mv * .* ..
cd ..
rm dir html

Edit .gitignorevi .gitignore

Ensure the following are added:

cms/framework/

Set www-data group as the owner of the following files, and grant write permissions:

cd /var/www/pandauxstudio.com
chown -R root:www-data assets
chown root:www-data .htaccess
chown root:www-data mysite/_config.php
chmod 775 -R assetschmod 775 .htaccess
chmod 775 mysite/_config.php

Create SilverStripe database and install

Create a db to hold cms content:

mysql -uroot -prootcreate database mynewsite;
quit

Load SilverStripe site

Fill in database details

Fill your username and password (Admin)
Run installation.

Setup deployment environment

Install the capistrano gem on your development machine

gem install capistrano

Change to your Silverstripe install directory

Create a Capistrano project

cap init

Update config/deploy.rb and config/deploy/staging.rb with your development machine, and deployment machine details

Add any needed deployment routines to the lib/capistrano/tasks/silverstripe.cap

run a test deploy

cap staging deploy

move any required files into location on your staging server and run the deployment again

cap staging deploy

References
How To Install Silverstripe on Your VPS