PHP Subversion Frontend – Part 1
Posted by Robert Swarthout | Filed under Apache, PHP, Subversion
Update: I no longer own/work for the company where I did this work. I do not have access to this code or the rights to distribute it, sorry.
——-
I am going to begin the process of explaining how to setup a PHP frontend to a remote subversion (SVN) working copy. The post today will talk about how to correctly setup apache to work in a multi-user setup.
One of the the nice things about SVN is that it keeps track of who changes what line and what changes they made on that line. SVN bases the username it stores on who committed the file. The trick in getting a PHP frontend to SVN to work correctly is that the user that apache is running as needs to be the user who is performing the commit action. To do this and make it work in a multiple user environment I have setup apache to proxy through requests to a specific URL to another instance of apache running as the needed user. In this setup you will need to have mod_proxy either loaded or compiled into your apache setup.
For example a request sent to http://rswarthout.svn.dummydomain.com would be routed through a proxy in apache to another instance of apache at http://127.0.0.1:8001. This internal address will handle the apache requests and pass it back to the web facing apache server instance.
The apache virtual host config below is for the web facing apache instance:
<VirtualHost 12.34.56.78:80>
ServerName rswarthout.svn.dummydomain.com
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8001/
ProxyPassReverse / http://127.0.0.1:8001/
<VirtualHost>
You will need to start a seperate instance of apache and pass it the config file to run. The config file below will start apache and have it listen on IP 127.0.0.1 only on port 8001.
Listen 127.0.0.1:8001
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .phpDocumentRoot “/home/svn.dummydomain.com/public_html”
<Directory “/home/svn.dummydomain.com/public_html”>
Options -Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>User rswarthout
Group rswarthoutDirectoryIndex index.php index.html
php_admin_value include_path “.:/home/svn.dummydomain.com/:/usr/share/pear”
In the above apache config you will see that I am setting the include path for PHP as well in the last line. This is not a requirement but it is good practice to only have files accessible through apache that need to be. To start a seperate instance of apache with the above config run the following command.
/path/to/apache/httpd -f /path/to/above/config/file.conf
That is all for this piece of the puzzle. Next time I will begin to explain the PHP side of the puzzle. When this puzzle is broken up into its smaller pieces it is quite easy to work through.