First step is to create separate system user in order to enhance security:
- Code: Select all
useradd phpmy
Next step is to clone STABLE branch of PhpMyAdmin from the official PhpMyAdmin SCM Git repository:
- Code: Select all
sudo -u phpmy -H git clone --single-branch --depth=1 -b STABLE https://github.com/phpmyadmin/phpmyadmin.git /home/phpmy/public_html
"sudo -u" is used to preserve user:group.
Alternatively you can apply recursively phpmy:phpmy or phpmy:nobody on /home/phpmy/public_html (what better suits your web service configuration).
Or even use Git hooks.
Used options are:
--depth <depth>
Create a shallow clone with a history truncated to the specified number of revisions. A shallow repository has a number of limitations (you cannot clone or fetch from it, nor push from nor into it), but is adequate if you are only interested in the recent history of a large project with a long history, and would want to send in fixes as patches.
--branch <name>
-b <name>
Instead of pointing the newly created HEAD to the branch pointed to by the cloned repository’s HEAD, point to <name> branch instead. In a non-bare repository, this is the branch that will be checked out.
--single-branch
Clone only the history leading to the tip of a single branch, either specified by the --branch option or the primary branch remote’s HEAD points at. When creating a shallow clone with the --depth option, this is the default, unless --no-single-branch is given to fetch the histories near the tips of all branches. Further fetches into the resulting repository will only update the remote-tracking branch for the branch this option was used for the initial cloning. If the HEAD at the remote did not point at any branch when --single-branch clone was made, no remote-tracking branch is created.
List all branches:
- Code: Select all
# cd /home/phpmy/public_html
# git branch -a
* STABLE
remotes/origin/STABLE
Update of PhpMyAdmin can be done with the following command:
- Code: Select all
cd /home/phpmy/public_html; sudo -u phpmy -H git pull"
Lets put it into cron to run periodically:
- Code: Select all
# crontab -lu phpmy
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * command to be executed
0 0 15 * * cd /home/phpmy/public_html; sudo -u phpmy -H git pull >> /var/log/cron 2>&1