Here is what I did:
First, manually do an svn checkout in the docroot:
su -
cd /var/www/html
svn co --username myusername svn://mysvnhost/svn/repositories/repository-name/projectname projectname
chown -R apache:apache projectname
Second, you will want a small PHP script to do all the work for you, so you will not have to ssh to machine all the time:
<?php
$docroot="/var/www/html";
$project="projectname";
$username="username";
$password="password";
$log = "ACTION LOG\n---------------\n\n";
$log .= shell_exec("sudo svn up --username $username --password $password $docroot/$project");
echo "<pre>$log</pre>";
?>
The thing is that since apache does not change it's user properly, svn cannot be properly run as apache, so will need the sudo there.
Third, in order for all of this to work, you will need to setup /etc/sudoers properly so go ahead and add this to it:
apache ALL=NOPASSWD:/usr/bin/svn
This will of course grow into something much more elaborate, that allows you to select projects, update on schedule, etc.
---
EDIT
---
note that if you do what i specified above, then every update from subversion will reset the owner for the files under the docroot to root. This is generally not a good idea, so i suggest you put the svn update line in a shell script and add a "chown -R apache:apache projectname" to that script. then you can just sudo yourscript.sh from the php file.
No comments:
Post a Comment
[Due to much spam, comments are now moderated and will be posted after review]
Note: Only a member of this blog may post a comment.