On my dev server
##Install git
su
apt-get install git-core
##Create ssh directory since it doesn't exists by default on the Amazon AMI
su
mkdir /var/www/.ssh
su
chown -R www-data:www-data /var/www/.ssh/
##Generate key for apache user
su www-data
ssh-keygen -t rsa -C "me@server" # chose "no passphrase"
cat /var/www/.ssh/id_rsa.pub
# Add the key as a "deploy key" at https://github.com/you/myapp/admin
##Get the repo
su
cd /home/freelancis/project.freelancis.net/
chown -R www-data www-data .
su www-data
git clone [email protected]:yourUsername/yourApp.git www
##Setup the update script
sudo www-data
www/update.php
<?php
$output = shell_exec('git pull');
echo "<pre>$output</pre>";
?>
##Set up service hook in github
- Go to Repository Administration for your repo (http://github.com/username/repository/admin)
- Click Service Hooks, and you'll see a list of available services. Select Post-Receive URL.
- Enter the URL for your update script (e.g. http://example.com/update.php) and click Update Settings.
##Sources