How to Set up SVN with Apache
This is a tutorial on how to set up SVN with Apache, create users accounts and also disable anonymous viewing of the project from a web browser. Subversion also known as SVN is a tool that remembers versions of a project and takes notes of changes. If someone was to write code or even a novel and commit changes to SVN and a mistake was made, they could easily go back to a previous revision.
To install Subversion and the Apache module run the following command:
sudo apt-get install subversion libapache2-svn
Setting up SVN
The first that needs to be done is to set up a group for subversion:
sudo addgroup subversion
The next thing is to make a directory for the SVN repository. I usually create it in the root directory named repo or svn:
sudo mkdir /repo
The premissions and owner of the repo directory have to be changed. The owner of the directory to www-data and the group needs to be subversion:
sudo chown www-data:subversion /repo sudo chmod g+rws /repo
To create the actual SVN repository svnadmin is used with create. You can use any name you like for the SVN repository:
sudo svnadmin create /repo/YourRepoName
The owner and permissions have to be changed on the repository:
sudo chown www-data:subversion /repo/YourRepoName sudo chmod g+rws /repo/YourRepoName
Setting up the Apache Module
Edit the file /etc/apache2/mods-available/dav_svn.config with your favourite editor. I like to use nano:
sudo nano /etc/apache2/mods-available/dav_svn.config
At the bottom of the file add the following lines:
<Location /svn/yourrepo> DAV svn SVNPath /repo/mpshouse AUTHType Basic AUTHName "Your Subversion Repository" AuthUserFile /etc/subversion/passwd Require valid-user </Location>
The 2 lines that need attention are the first, the sixth ans the last. The first line:
has /svn/yourrepo in it which will be the address that you can access your SVN. If your domain is yourdomain.com, you can access the SVN at yourdomain.com/svn/yourrepo. The sixth line:
is where the password file is located. The last line:
will stop anonymous browsing of your projects and force the browser to show an authentication dialog to continue.
Adding a User Account
To add a user account to a new password file the -c flag is used. If the file already exists and a new user needs to be added to an existing file the -c flag is not needed. The password file needs to be created in the directory specified in the dav_svn.config file that was just edited. The command will ask you for the password of the user after pressing enter.
sudo htpasswd -c /etc/subversion/passwd bill
Comments are currently closed.