Setup SVN With Attached Drives on CentOS

Setup SVN With Attached Drives on CentOS

Posted:  December 17, 2014

Setup SVN With Attached Drives on CentOS

These are the step that I took to create a SVN server using CentOS 7, while attaching drives as repositories instead of creating a monstrous system drive and importing everything there.

If you follow to a “T”, you too can have the play-ground I have =)

I will lay out my exact steps, including creating the virtual machine I used for this.  If you are currently using a VM or dedicated machine then you can skip those steps.  I imagine this would work on CentOS 5 and up, but don’t quote me on that.

  1. Create VirtualBox Virtual Machine
    1. Have a CentOS ISO ready
      1. I chose v7 as the latest
    2. Setup with 20G hard disk, Bridged Networking, 4G Ram, 2 Processors, 3 – 1GB test disks, no sound, minimal video memory
    3. Install CentOS as Basic Web Server, no GUI
      1. Include PHP, Perl, Python, NFS during initial install
      2. No need for CPanel
    4. Reboot
    5. Run yum update
    6. Run systemctl start httpd.service
    7. Run systemctl enable httpd.service
    8. Run the following 3 to allow ports 80 and 443 through the firewall
      1. firewall-cmd –permanent –zone=public –add-service=http
      2. firewall-cmd –permanent –zone=public –add-service=https
  • firewall-cmd –reload
  1. Now change SELinux to disabled in /etc/selinux/config, change SELINUX=enforcing to SELINUX=disabled
  2. Run yum install subversion mod_dav_svn
  3. Run the following
    1. mkdir /svn
    2. mkdir /var/www/svn
  • chown –R apache:apache /svn
  1. chown –R apache:apache /var/www/svn
  1. Now we need to configure SVN
    1. Run nano /etc/httpd/conf.modules.d/10-subversion.conf
    2. Add In:
      Alias /svn /var/www/svn
      <Location /svn>
      DAV svn
      SVNParentPath /svn/
      AuthType Basic
      AuthName “Emagine Repositories”
      AuthUserFile /etc/svn-auth-users
      Require valid-user
  2. The save the file by hitting CTRL-O, then CTRL-X to exit nano
  1. Now we need to setup user access
    1. Only the first user created needs the –c flag, all the rest need only the –m flag
    2. Run htpasswd –cm /etc/svn-auth-users kpirnie
      1. For some reason, I had to run this command twice
      2. Type in the new password twice
    3. And now the fun begins… I made 3 1GB dummy disks before, when setting up the VM, now we need to partition, format, mount them
      1. Run the following commands on each disk (NOTE: You can skip this step if simply attaching storage, run fdisk –l to see what’s attached for disks)
        1. fdisk /dev/sdb
        2. n
  • default the next 4 to create a primary partition using all space
  1. w
  2. mkfs.ext4 /dev/sdb1 (sdc1, sdd1 as well)
  1. Mount the disks
    1. mkdir /mnt/Disk1 (also for Disk2 and Disk3)
    2. nano /etc/fstab
  • add in a line for each disk, and make sure there is an empty line at the end of the file
  1. /dev/sdb1 /mnt/Disk1         ext4       defaults               0              0
  2. Repeat as necessary for each disk attached
  3. Remount everything with mount –a
  1. You can use step b above to mount any disk you have attached to the server
  2. Now we add the proper permissions
    1. Run the following for each disk added (replace Disk* for your mount point)
      1. chown -R apache:apache /mnt/Disk1
      2. chcon -h system_u:object_r:httpd_sys_content_t /mnt/Disk1
      3. chcon -h apache:object_r:httpd_sys_content_t /mnt/Disk1
    2. Now create & import the repos (replace Disk* with each disk you mounted, or whatever you want to name it)
      1. mkdir –p /mnt/Disk1/{trunk,branches,tags}
        1. Copy all content from the disk to the ‘trunk’ directory we just created
      2. svnadmin create /svn/Disk1
  • svn import –m “Initial Import” /mnt/Disk1 file:///svn/Disk1

Kevin Pirnie

20+ Years of PC and server maintenance & over 15+ years of web development/design experience; you can rest assured that I take every measure possible to ensure your computers are running to their peak potentials. I treat them as if they were mine, and I am quite a stickler about keeping my machines up to date and optimized to run as well as they can.