Page 1 of 1
Running SVN commands from PHP webpage
Posted: Mon Feb 21, 2011 12:36 pm
by selahlynch
Hello,
I am trying to run the command "svn info" from a php webpage.
Code: Select all
exec("svn info /var/www/html/appdir", $stddout, $succ);
The svn command works if I paste it into a terminal, however, when I run it from my PHP code, it fails.
Here is the error message...
svn: Can't open file '/root/.subversion/servers': Permission denied
I understand that when I run these commands from the webpage, I am running them as apache, not as myself, so that is why the same command works in my terminal, but doesn't work from my webpage.
How can I overcome this?
Re: Running SVN commands from PHP webpage
Posted: Mon Feb 21, 2011 12:44 pm
by selahlynch
And to follow that up, I see there are some suggestions on the web:
1) There is an svn option --config-dir where one can specify an alternate config directory for apache to use. The problem is I do not know of any available config directory that apache can access.
2)I also saw some recommendations having to do with using putenv() but I'm not sure just what environmental variable I should set.
3)I saw a recommendation to "configure apache user for subversion" but I do not know how to do this either.
Any advice would be very much appreciated!!
Re: Running SVN commands from PHP webpage
Posted: Mon Feb 21, 2011 12:59 pm
by Weirdan
what kind of svn operations you're planning to use? Can you install additional extensions on your server?
Re: Running SVN commands from PHP webpage
Posted: Mon Feb 21, 2011 1:22 pm
by selahlynch
I'm planning on using the command "svn info".
I am able to run this command just fine on the server when I am a normal user. It only does not work when I am the apache user.
I'm not sure why I would need any additional extensions.
Re: Running SVN commands from PHP webpage
Posted: Mon Feb 21, 2011 1:26 pm
by selahlynch
Okay a solution, maybe not the best, but a solution none the less.
I copied the entire .subversion directory from a normal user's home directory and put that in my /var/www/html html directory.
Then I altered my command to be
Code: Select all
exec("svn --config-dir /var/www/html/.subversion info /var/www/html/appdir", $stddout, $succ);
Now it works.
Re: Running SVN commands from PHP webpage
Posted: Mon Feb 28, 2011 4:02 pm
by selahlynch
Today I discovered the PHP SVN module and that proved to be a better solution than my previous one.
Perhaps that is what you were suggesting, Wierdan? I'm sorry I didn't investigate further at the time... but thank you for the response.
http://us.php.net/manual/en/book.svn.php
Now I have code that looks like this:
Code: Select all
$loginfo = svn_log("/var/www/html/selahtemp/includes");
$lastrev2 = $loginfo[0]['rev'];
echo "<br />Last Revision from svn_log() = $lastrev2 <br />";
Hooray

Re: Running SVN commands from PHP webpage
Posted: Mon Feb 28, 2011 4:25 pm
by Weirdan
selahlynch wrote:Today I discovered the PHP SVN module and that proved to be a better solution than my previous one.
Perhaps that is what you were suggesting, Wierdan?
That was one of the options I had in mind, yes.