Logicalwebhost Cheatsheet

Linux & Open Source Cheatsheets & Howto's

Skip to: Content | Sidebar | Footer

Subversion Howto

Subversion with mod_dav_svn allows you to keep track of different versions of your code (or whatever else) and roll back to earlier versions if you screw it up or someone overwrites it. I’ll also get into a web viewable code tool that allows you to look at your code on the web with a viewer

Setting up subversion

This is on CentOS, though it should work on Debian/Ubuntu with a few modifications.

yum install mod_dav_svn subversion
vi /etc/httpd/conf/httpd.conf
  ServerName www.yourserverurl.com (change to a real thing and delete the # in front of the line)
service httpd start
chkconfig httpd on
vi /etc/httpd/conf.d/subversion.conf (add/uncomment something like the following)
  <Location /repos>
   DAV svn
   SVNParentPath /var/www/svn
   AuthType Basic
   AuthName "your favorite name for your repos"
   AuthUserFile /etc/svn-auth-conf
   Require valid-user
 </Location>
htpasswd -cm /etc/svn-auth-conf yourusername
New password:
Re-type password:
mkdir /var/www/svn
cd /var/www/svn
svnadmin create yourproject
chown -R apache.apache yourproject
vi /etc/sysconfig/iptables (add this next line after the port 22 one)
  -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
service httpd restart

Debian Howto

apt-get install subversion libapache2-svn apache2
mkdir /var/svn
mkdir /var/secure
svnadmin create /var/svn/myrepository
chown -R www-data.www-data /var/svn
vi /etc/apache2/mods-available/dav_svn.conf (add following lines to end)
  <Location /svn>
      DAV svn
      SVNParentPath /var/svn
      AuthType Basic
      AuthName "Subversion Repository"
      AuthUserFile /var/secure/.htpasswd
      AuthzSVNAccessFile /var/svn/authz
      Require valid-user
      SSLRequireSSL
  </Location>
a2enmod ssl
a2enmod dav
a2enmod dav_svn
htpasswd -cm /var/secure/.htpasswd username
cp /var/svn/yourprojectname/conf/authz /var/svn/
vi /var/svn/authz (add these lines to end)
  [yourrepository:/]
  youruser = rw
mkdir /etc/apache2/ssl
cd /etc/apache2/ssl
openssl req -new -x509 -days 365 -nodes -out apache.pem -keyout apache.key
vi /etc/apache2/sites-available/yourprojectname (add these lines)
  <VirtualHost *:443>
   ServerAdmin admin@server.name
   ServerName your.server.name
   DocumentRoot /usr/share/websvn
   <Directory /usr/share/websvn>
     Options -Indexes FollowSymLinks
     AllowOverride None
     Order deny,allow
     Allow from all
   </Directory>
   ErrorLog ${APACHE_LOG_DIR}/error_ssl.log
   LogLevel warn
   CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
   SSLEngine On
   SSLCertificateFile /etc/apache2/ssl/apache.pem
   SSLCertificateKeyFile /etc/apache2/ssl/apache.key
  </VirtualHost>
a2ensite yourprojectname
apt-get install websvn
(select config now)
(deselect all options besides apache2)
(update paths to /var/svn)

Now set up your LAPTOP. First set up automatic login via ssh so you don’t have to type your password every time.

ssh-keygen -t dsa -f ~/.ssh/id_dsa -C "yourusername@laptop's_IP_or_hostname.com"
cat ~/.ssh/id_dsa.pub | ssh yourusername@server.ip.or.hostname 'cat - >> ~/.ssh/authorized_keys'
ssh-add

Now set up subversion on your LAPTOP and check out some code from your svn server:

sudo apt-get install subversion

http://blog.mattsch.com/2011/03/21/setting-up-apache-and-subversion-on-debian-squeeze/

Write a comment

You need to login to post comments!