Automatically deploy the code using PHP and Git.
git and rsync are required on the server that's running the script
(server machine).
tar is required for backup functionality (BACKUP_DIR option).composer is required for composer functionality (USE_COMPOSER
option).www-data) needs to have the necessary
access permissions for the TMP_DIR and TARGET_DIR locations on
the server machine.deploy-config.php file.
Rename deploy-config.example.php to deploy-config.php and edit the
configuration options there. That way, you won't have to edit the configuration
again if you download the new version of deploy.php.https://github.com/USERNAME/REPOSITORY/settings/keys and add your server
SSH key.https://github.com/USERNAME/REPOSITORY/settings/hooks.http://example.com/deploy.php?sat=YourSecretAccessTokenFromDeployFile.https://bitbucket.org/USERNAME/REPOSITORY/admin/deploy-keys and add your
server SSH key.https://bitbucket.org/USERNAME/REPOSITORY/admin/services.http://example.com/deploy.php?sat=YourSecretAccessTokenFromDeployFile..git/hooks/post_receive script that calls the script e.g.#!/bin/sh
echo "Triggering the code deployment ..."
wget -q -O /dev/null http://example.com/deploy.php?sat=YourSecretAccessTokenFromDeployFile
Next time you push the code to the repository that has a hook enabled, it's
going to trigger the deploy.php script which is going to pull the changes and
update the code on the server machine.
For more info, read the source of deploy.php.
rsync is used for deployment, the TARGET_DIR doesn't have to be
on the same server that the script is running e.g. define('TARGET_DIR', '[email protected]:/full/path/to/target_dir/'); is going to work as long
as the user has the right SSH keys and access permissions.deploy.php to something else, for example deploy_master.php and
deploy_develop.php and configure them separately. In that case, the
configuration files need to be named deploy_master-config.php and
deploy_develop-config.php respectively.If you find this script useful, consider donating BTC to 1fLnPZkMYw1TFNEsJZCciwDAmUhDw2wit.
606 followers · starred May 2014
273 followers · starred Feb 2015
48 followers · starred Apr 2015
6 followers · starred Apr 2021
Automatically deploy the code using PHP and Git.
git and rsync are required on the server that's running the script
(server machine).
tar is required for backup functionality (BACKUP_DIR option).composer is required for composer functionality (USE_COMPOSER
option).www-data) needs to have the necessary
access permissions for the TMP_DIR and TARGET_DIR locations on
the server machine.deploy-config.php file.
Rename deploy-config.example.php to deploy-config.php and edit the
configuration options there. That way, you won't have to edit the configuration
again if you download the new version of deploy.php.https://github.com/USERNAME/REPOSITORY/settings/keys and add your server
SSH key.https://github.com/USERNAME/REPOSITORY/settings/hooks.http://example.com/deploy.php?sat=YourSecretAccessTokenFromDeployFile.https://bitbucket.org/USERNAME/REPOSITORY/admin/deploy-keys and add your
server SSH key.https://bitbucket.org/USERNAME/REPOSITORY/admin/services.http://example.com/deploy.php?sat=YourSecretAccessTokenFromDeployFile..git/hooks/post_receive script that calls the script e.g.#!/bin/sh
echo "Triggering the code deployment ..."
wget -q -O /dev/null http://example.com/deploy.php?sat=YourSecretAccessTokenFromDeployFile
Next time you push the code to the repository that has a hook enabled, it's
going to trigger the deploy.php script which is going to pull the changes and
update the code on the server machine.
For more info, read the source of deploy.php.
rsync is used for deployment, the TARGET_DIR doesn't have to be
on the same server that the script is running e.g. define('TARGET_DIR', '[email protected]:/full/path/to/target_dir/'); is going to work as long
as the user has the right SSH keys and access permissions.deploy.php to something else, for example deploy_master.php and
deploy_develop.php and configure them separately. In that case, the
configuration files need to be named deploy_master-config.php and
deploy_develop-config.php respectively.If you find this script useful, consider donating BTC to 1fLnPZkMYw1TFNEsJZCciwDAmUhDw2wit.
606 followers · starred May 2014
273 followers · starred Feb 2015
48 followers · starred Apr 2015
6 followers · starred Apr 2021