Install and keep updated PhpMyAdmin with git

Here you can find tutorials and notes for server-side maintenance/configuration

Install and keep updated PhpMyAdmin with git

Postby lik » Sat Feb 02, 2013 7:59 am

Suppose, you need phpMyAdmin running on your server to provide simple web interface for end users for MySql databases management and perform regular updates with cron task.
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 /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.


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

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
Posts: 497
Joined: Wed Dec 15, 2010 3:21 am

Return to Server Side Actions


  • Related topics
    Last post