Subversion Installation
After many days trying to find a good tutorial on how to set up a working subversion server I decided to write my own that I know works. I followed these steps again on a new install on another server to make sure I was not missing anything so this should be a pretty complete walk through.
Hope this helps & Enjoy :)
1) INSTALLING SUBVERSION
go to whatever director you use to install stuff
cd /usr/local/src/installed wget http://subversion.tigris.org/downloads/subversion-1.4.4.tar.gz gunzip subversion-1.4.4.tar.gz tar -xf subversion-1.4.4.tar cd subversion-1.4.4 ./configure make && make install
You may get an error that Berkley DB is not installed. That’s fine, you don’t need it.
2) RECOMPILE APACHE TO WORK WITH SUBVERSION
go to your apache 2 source director
!!! MAKE A BACKUP OF YOUR CONFIG FILE FIRST (/usr/local/apache2/conf/httpd.conf) !!!
cd /usr/local/src/installed/httpd-2.2.3 make clean ./configure \ --with-included-apr \ --prefix=/usr/local/apache2 \ --enable-so \ --enable-dav \ --enable-dav=shared \ --enable-dav-fs=shared \ --enable-ssl \ --enable-rewrite make && make install
3) ADD THIS TO THE TOP OF APACHE CONFIG FILE
LoadModule dav_module modules/mod_dav.so LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so
4) ADD THIS TO THE BOTTOM OF APACHE CONFIG FILE
# ===================== # SUBVERSION # ===================== # !! MAKE SURE YOU DO NOT ALREADY HAVE USER OR GROUP DEFINED ELSEWHERE !! User apache Group svnusers # Setup permission for connecting to subversion directory <Location /svn/repos> DAV svn SVNPath /var/www/subversion AuthType Basic AuthName "Subversion :: Restricted Files" AuthUserFile /var/www/.htpasswd AuthGroupFile /var/www/.htgroup Require group svnusers </Location> # Disallow browsing of Subversion working copy administrative dirs. <DirectoryMatch "^/.*/\.svn/"> Order deny,allow Deny from all </DirectoryMatch>
5) CREATE INITIAL SUBVERSION DIRECTORY
# mkdir /var/www/subversion # svnadmin create /var/www/subversion # chmod 777 -Rv /var/www/subversion
6) CREATE ACCOUNTS FOR NEW USERS
Add any new accounts you might want
/usr/local/apache2/bin/htpasswd /var/www/.htpasswd username
Then add them to the group “svnusers”
nano /var/www/.htgroup svnusers: apache username
7) RESTART APACHE
service httpd restart
8) MAKE POST COMMIT FILE TO UPDATE LIVE SITES
cd /var/www/subversion/hooks cp post-commit.tmpl post-commit chmod 777 post-commit touch post-commit.log
now edit the post-commit file to contain only the text on #9
nano post-commit
9) POST-COMMIT FILE
#!/bin/sh /usr/local/bin/svn update /var/www/* > /var/www/subversion/post-commit.log
10) CREATING A SUBVERSION PROJECT FOR YOUR LIVE SITES
for all the project in your servers root that you want to make into a subversion project just do an initial import for each.
** myproject = the folder name for the project you want to import
cd /var/www svn import myproject file:///var/www/subversion/myproject -m "Initial import"
11) CREATING A SUBVERSION PACKAGE
Now that we have a subversion project in place we need to make the live site just a checked out version. In the post-commit file in step #9 we have set it up so that any updates to the subversion project will automatically be updated to the live site.
Make sure you have a complete backup of everything before you do this step as you will need to removed ALL the files from the folders you want to have contain the checked out copies of your projects.
cd /var/www rm -fr myproject/* svn co file:///var/www/subversion/myproject myproject
12) UPDATE OWNERS OF LIVE SITE TO BE SAME AS SERVER
Once you have created all these new projects we need to update the owner of the files to be apache. Since you most likely are not logged in through SSH as apache all the previous work you did above will have your username as the owner and subversion will not work through apache unless you make it the owner. If you leave this “as is” you can still do everything you normally could do the SSH but you just wont be able to have it work with apache.
If you have not already done so, make a new group on your server called svnusers and add your username as well as apache into the group. Also add any other users you want to have access into this group.
chown -Rv apache.apache /var/www
13) GETTING A LIST OF PROJECTS
If you would like to see what subversion projects exist, just type this:
svn list file:///var/www/subversion
14) DELETING A SUBVERSION PACKAGE
If you want to delete a project you can do this:
svn delete -m "Deleting Media Directories" file:///var/www/subversion/myproject
15) CONNECTING TO YOUR NEW SUBVERSION PROJECT
Go to http://tortoisesvn.net/downloads and download the TortoiseSVN application. Once you have it installed and restarted you system then you can begin connecting to your projects.
First let’s make sure that you can access your subversion project via a web browser.
** mywebsite.com = your websites URL
Go to http://www.mywebsite.com/svn/repos/ and enter the name and password you set up in step #6
If you could not connect then there were problems with your installation. Make sure you followed all the steps above correctly.
If you could connect, then great! You got everything working!
Now simply create an EMPTY folder with whatever name you want on your computer.
Right click on it and select “SVN Checkout…”
For the “URL of repository:” enter the full URL from your website
i.e. http://www.mywebsite.com/svn/repos/myproject
Then just press OK
You will be asked for the same username and password again. Just enter those and your good to go.
Once you make changes to your copy of the subversion project simply right click again on the parent folder you create and choose “SVN Commit…”.
You will be asked to enter some notes, which you should do so others know what’s going on.
Once you press OK then the file will be updated AND the post-commit feature we setup will automatically update your live site.
Finally, if you want to make a folder stop being connected to a subversion project on your local machine, but you want to keep the files… make sure you have hidden folders viewable and just delete the “.svn” folder in it. This will leave the main files in tact but will disconnect it from the subversion project.