This article will share with you about the PHP project version control and release process. Friends in need can take a look
# 1. [Local==> GIT warehouse==> Test server] When the submission to the GIT warehouse is completed, GIT triggers the test server hook script to automatically PULL the update code:
www.xxx.com.php, Note: Need to be in Delete the system in disable_function in php.ini (that is, enable the script execution permission)
http://XXX.XXX.COM/hook/www.xxx.com.php
##SHELL script:/home/git/hook/
www.xxx.com.sh#!/bin/bash
#log
echo "`date +%Y%m%d_%H%M%S`,Pull code success[Master]" >> "/home/git /hook/log/pull_www.xxx.com_`date +%Y%m`.log"
GIT warehouse hosting code:
https://git.oschina.netCreate a private project www.xxx.com
Set the webhook address to the php script URL of the above test server:
http://XXX.XXX.COM/hook/www.xxx.com.phpAdd the public key to the project or personal user settings (recommended for individuals In user settings, all projects can use the same public key globally)
Note .gitignore, set to exclude files and directories that do not need to be synchronized
Add/modify files
git add .
git commit -m test
git pull
git rebase master
git push
sudo -Hu www git config --global user.name "echobar"
sudo -Hu www git config --global user.email "15516026@qq.com" # Please contact oschina for email Consistent with
git configuration
git submits local code to the warehouse
View on oschina Whether the project file is updated successfully
Check whether the test server code is updated. If it is updated, it means the configuration is successful; if it sometimes succeeds and sometimes fails, it may be a delay problem in the hook call and needs to be modified. PHP script delay time, or manually execute the following code to pull: http://xxx.xxx.com/hook/www.xxx.com.php?HTTP_USER_AGENT=git-oschina-hook
## 2. [Test server ==> Official server] Write a remote synchronization script and execute it manually when publishing. Synchronization method: RSYNC+SSH
, Note: --exclude-from exclude files list, pay attention to exclude files that do not need to be synchronized
#!/bin/sh10.10 .10.10
:/home/wwwdata/www.xxx.comPerform synchronization from test server to official server (rsync+ssh)
www.xxx.com_from_test_to_prod.sh
Note: The yellow parts above are the codes required to publish locally to the test server and publish the test server to the official server
.
The above is the detailed content of PHP project version control and release process. For more information, please follow other related articles on the PHP Chinese website!