This gist shows how to setup a simple build server with Apache.
GitHub sends a push request to the server each time the repository is updated.
Apache handles this request and runs a python script in response, which pulls from the repository and creates a new build.
This assumes the Apache user is called "www-data" with a home directory of /var/www/ and that project files live in /var/www/PROJECT
(Note: The order of these steps is mostly arbitrary)
Copy the contents of apache.config to /etc/apache2/sites-enabled/000-default.conf
Modify as necssary, at minimum replacing PROJECT and making sure all directories and files exist as expected
Run
sudo service apache2 restart
Copy push script into /var/www/PROJECT
Modify as necessary
sudo mkdir /var/www/.ssh
ssh-keygen
(Location: /var/www/.ssh/)
sudo -R chown www-data:www-data /var/www/.ssh
sudo -R chmod 600 /var/www/.ssh/*
Then, add this ssh keypair to your GitHub Account
Create push webhook on GitHub (in project settings)
Point it to $IP/PROJECT/push
Give apache user permission to access all of the project files
sudo chown -R www-data:www-data /var/www/PROJECT
sudo chmod -R 777 /var/www/PROJECT
Note: If git pull
says "the authenticity of host cannot be established" each time, this probably means the www-data user doesn't have access to /var/www/.ssh, which it needs to create the known_hosts file.
sudo -u www-data /var/www/PROJECT/push
Apache/2.4.18 (Ubuntu)