1. Install subversion and related modules using command,
sudo apt install subversion apache2 libapache2-svn apache2-utils
2. Create a directory for SVN root
mkdir /home/svn
3. Create a directory for your project repository
mkdir /home/svn/MyProject
4. Using the following command create the repository
svnadmin create /home/svn/MyProject
5. Open the conf directory inside the repository directory and edit the svnserve.conf. Uncomment and change settings as,
general6. Add user credentials in passwd file in same directory,
password-db = passwd
anon-access = none # note this change; default will be read
username = password
7. Start svn server using command,
svnserve -d -r /home/svn
(Note: Use options --foreground and --config-file=filename, if required)
8. To start the svn server automatically on boot-up, create svnserve.conf inside the directory /etc/init and add below contents,
# svnserve - Subversion serverdescription "Subversion Server"
start on (local-filesystems and net-device-up IFACE=lo and started udev-finish)
stop on runlevel [06]
#chdir /home/svn
#respawn
#respawn limit 2 3600exec /usr/bin/svnserve -d -r /home/svn
(Note: Use the commented options, if required)
9. Now the repository will be accessible via the url
svn://hostname/MyProject
Optional,
10. To work with repository using SSH, install ssh server & start it; then use url
11. To use HTTP edit the dav_svn.conf file in the directory /etc/apache2/mods-available. Add the following lines to it,svn+ssh://hostname/home/svn/MyProject
<Location /svn>12. Create a user group subversion using command,
DAV svn</Location>
SVNParentPath /home/svn
SVNListParentPath On
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/subversion/passwd
Require valid-user
sudo addgroup subversion13. Add www-data to subversion(group) using command,
sudo adduser www-data subversion14. Change ownership and permissions for the repository using below commands,
sudo chown -R www-data:www-data /home/svn/MyProject14. Restart apache server, using command,
sudo chmod -R g+rws /home/svn/MyProject
service apache2 restart15. Add SVN user credentials using command
sudo htpasswd -c /etc/subversion/passwd user-name16. Now the repository will be accessible via the url http://hostname/svn/MyProject
17. To use HTTPS configure the apache for SSL. Then the repository will be accessible via the url https://hostname/svn/MyProject
Note:-
1. To test repository access; use the command to checkout,
cd /home/Working-Directory2.a. To setup for HTTPS edit the default-ssl.conf or your own ssl configuration file in the directory /etc/apache2/sites-available
svn co http://hostname/svn/MyProject
or
svn co https://hostname/svn/MyProject
or
svn co svn://hostname/MyProject
or
svn co svn+ssh://hostname/home/svn/MyProject
SSLEngine on2.b. To setup for HTTPS edit the ports.conf in the directory /etc/apache2. Comment or remove the line,
SSLCertificateFile path_to_ssl_certificate
SSLCertificateKeyFile path_to_ssl_certificate_key_file
Listen 802.c. Enable SSL mod using
sudo a2enmod ssl3. Apache server restart can be done using any of the below commands,
systemctl reload apache2.service4. Enable or disable ssl enabled site configurations using commands,
service apache2 reload
service apache2 restart
/etc/init.d/apache2 restart
a2ensite default-ssl.conf5. To open directory with Admin power, use
a2dissite default-ssl.conf
gksu nautilus path_to_directory6. Replace the /home/svn with path to svn root
7. Replace the /home/svn/MyProject with Repository path
8. Replace /svn in HTTP(S) url with the location provided inside the tag <Location>