Subversion, also known as SVN, is an open-source version control system that manages files and tracks changes made to them. It allows you to recover older files and directories and examine the history of your files and directories to see how they have changed over time.
This tutorial will guide you through the process of installing and configuring Subversion 1.8 on CentOS 6.5.
Step 1: Preparing the WANdisco Repository
The first step in the installation process is to prepare the WANdisco repository. This can be done by executing the following commands:
wget opensource.wandisco.com/RPM-GPG-KEY-WANdisco -O /tmp/RPM-GPG-KEY-WANdisco
This command downloads the WANdisco repository’s GPG key and saves it to a temporary directory.
wget opensource.wandisco.com/RPM-GPG-KEY-WANdisco -O /tmp/RPM-GPG-KEY-WANdisco --2014-03-11 23:29:59-- http://opensource.wandisco.com/RPM-GPG-KEY-WANdisco Resolving opensource.wandisco.com... 54.248.108.17 Connecting to opensource.wandisco.com|54.248.108.17|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1759 (1.7K) [application/octet-stream] Saving to: â/tmp/RPM-GPG-KEY-WANdiscoâ 100%[==========================================================>] 1,759 --.-K/s in 0.003s 2014-03-11 23:30:00 (665 KB/s) - â/tmp/RPM-GPG-KEY-WANdiscoâ
Step 2: Importing the RPM-GPG-KEY-WANdisco
Once the key is downloaded, it needs to be imported. This can be done with the following commands:
rpm --import /tmp/RPM-GPG-KEY-WANdisco rm -rf /tmp/RPM-GPG-KEY-WANdisco
The first command imports the key, and the second command deletes the key from the temporary directory as it’s no longer needed.
Step 3: Configuring the WANdisco Repository File
The next step is to configure the WANdisco repository file. This can be done by editing the file at /etc/yum.repos.d/WANdisco-1.8.repo and adding the following content:
[WANdisco] name=WANdisco SVN Repo 1.8 enabled=1 baseurl=http://opensource.wandisco.com/rhel/6/svn-1.8/RPMS/ gpgcheck=1
This configuration enables the WANdisco SVN Repo 1.8 and sets the base URL for the repository.
Step 4: Installing Subversion Using Yum Install
With the repository configured, you can now install Subversion and the mod_dav_svn module using the yum install command:
yum install subversion mod_dav_svn -y
This command installs Subversion and the mod_dav_svn module, which is required for Subversion to work with the Apache HTTP server.
yum install subversion mod_dav_svn -y Loaded plugins: fastestmirror Determining fastest mirrors epel/metalink | 5.2 kB 00:00 * Webmin: download.webmin.com * base: centos.ipserverone.com * epel: epel.mirror.net.in * extras: centos.ipserverone.com * updates: centos.ipserverone.com WANdisco | 951 B 00:00 WANdisco/primary | 65 kB 00:00 WANdisco 309/309 Webmin | 951 B 00:00 Webmin/primary | 21 kB 00:00 Webmin 168/168 base | 3.7 kB 00:00 base/primary_db | 4.4 MB 00:45 epel | 4.2 kB 00:00 epel/primary_db | 6.0 MB 01:51 extras | 3.4 kB 00:00 extras/primary_db | 19 kB 00:00 updates | 3.4 kB 00:00 updates/primary_db | 2.1 MB 00:18 Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package mod_dav_svn.x86_64 0:1.8.8-1 will be installed ---> Package subversion.x86_64 0:1.8.8-1 will be installed --> Processing Dependency: libserf-1.so.1()(64bit) for package: subversion-1.8.8-1.x86_64 --> Running transaction check ---> Package serf.x86_64 0:1.3.2-2 will be installed --> Finished Dependency Resolution Dependencies Resolved ==================================================================================================== Package Arch Version Repository Size ==================================================================================================== Installing: mod_dav_svn x86_64 1.8.8-1 WANdisco 77 k subversion x86_64 1.8.8-1 WANdisco 2.2 M Installing for dependencies: serf x86_64 1.3.2-2 WANdisco 43 k Transaction Summary ==================================================================================================== Install 3 Package(s) Total download size: 2.3 M Installed size: 7.8 M Downloading Packages: (1/3): mod_dav_svn-1.8.8-1.x86_64.rpm | 77 kB 00:00 (2/3): serf-1.3.2-2.x86_64.rpm | 43 kB 00:00 (3/3): subversion-1.8.8-1.x86_64.rpm | 2.2 MB 00:19 ---------------------------------------------------------------------------------------------------- Total 112 kB/s | 2.3 MB 00:20 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : serf-1.3.2-2.x86_64 1/3 Installing : subversion-1.8.8-1.x86_64 2/3 Installing : mod_dav_svn-1.8.8-1.x86_64 3/3 Stopping httpd: [ OK ] Starting httpd: [ OK ] Verifying : mod_dav_svn-1.8.8-1.x86_64 1/3 Verifying : subversion-1.8.8-1.x86_64 2/3 Verifying : serf-1.3.2-2.x86_64 3/3 Installed: mod_dav_svn.x86_64 0:1.8.8-1 subversion.x86_64 0:1.8.8-1 Dependency Installed: serf.x86_64 0:1.3.2-2 Complete!
Step 5: Setting Up SVN Directories
After installing Subversion, you need to set up the SVN directories. This can be done with the following commands:
mkdir /svn mkdir /svn/repos mkdir /svn/users mkdir /svn/permissions chown -R apache:apache /svn
These commands create the necessary directories and set the ownership of the /svn directory to the Apache user.
Step 6: Configuring the Apache HTTP Server
Next, you need to configure the Apache HTTP server to work with Subversion. This can be done by editing the /etc/httpd/conf/httpd.conf file and adding the following content:
<VirtualHost *:80> ServerAdmin webmaster@svn.webhostinggeeks.local DocumentRoot /svn/repos ServerName svn.webhostinggeeks.local ErrorLog logs/svn.webhostinggeeks.local-error_log CustomLog logs/svn.webhostinggeeks.local-access_log common </VirtualHost>
This configuration sets up a virtual host for the Subversion repositories.
Step 7: Backing Up the Original Subversion File
Before making changes to the Subversion configuration, it’s a good idea to back up the original file. This can be done with the following command:
mv /etc/httpd/conf.d/subversion.conf /etc/httpd/conf.d/subversion.conf.bak
This command renames the original subversion.conf file to subversion.conf.bak.
Step 8: Creating and Configuring the subversion.conf File
Now you can create a new subversion.conf file and configure it for your setup. This can be done by creating the file at /etc/httpd/conf.d/subversion.conf and adding the following content:
LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so <Location /svn/repos> DAV svn SVNParentPath /svn/repos AuthType Basic AuthName "Authorization Realm" AuthUserFile /svn/users/passwords AuthzSVNAccessFile /svn/permissions/svnaccess Require valid-user </Location>
This configuration loads the necessary modules for Subversion and sets up basic authentication for the repositories.
Step 9: Creating the First Repository
With the server configured, you can now create your first repository. This can be done with the following commands:
svnadmin create /svn/repos/testrepo chown -R apache:apache /svn/repos/testrepo
These commands create a new repository named testrepo and set the ownership to the Apache user.
Step 10: Creating a User to Access the Repository
Next, you need to create a user that can access the repository. This can be done with the following command:
htpasswd -c /svn/users/passwords svnuser1
This command creates a new user named svnuser1 and prompts you to enter a password for the user.
Step 11: Creating the svnaccess File
To control access to the repository, you need to create an svnaccess file. This can be done by creating the file at /svn/permissions/svnaccess and adding the following content:
[testrepo:/] svnuser1 = rw
This configuration grants read and write access to the svnuser1 user for the testrepo repository.
Step 12: Restarting the Apache HTTP Server
Finally, you need to restart the Apache HTTP server for the changes to take effect. This can be done with the following command:
service httpd restart
Step 13: Testing the Subversion Server
With everything set up, you can now test your Subversion server by accessing the testrepo repository from a web browser at the following URL:
http://svn.webhostinggeeks.local/svn/repos/testrepo/
If everything is set up correctly, you should be prompted to enter the username and password for the svnuser1 user, and then be able to access the testrepo repository.
Commands Mentioned
- wget – Used to download files from the internet.
- rpm –import – Used to import a GPG key.
- vi – A text editor used to edit configuration files.
- yum install – Used to install packages.
- mkdir – Used to create directories.
- chown – Used to change the ownership of files or directories.
- mv – Used to move or rename files.
- svnadmin create – Used to create a new Subversion repository.
- htpasswd -c – Used to create a new user for the Subversion repository.
- service httpd restart – Used to restart the Apache HTTP server.
Conclusion
In this tutorial, we’ve walked through the process of installing and configuring Subversion 1.8 on CentOS 6.5. We’ve covered everything from preparing the WANdisco repository and importing the RPM-GPG-KEY-WANdisco, to configuring the Apache HTTP server and creating your first Subversion repository.
By following these steps, you should now have a fully functional Subversion server that you can use to manage your files and track changes. Remember, if you’re new to version control systems like Subversion, it’s worth taking the time to understand how they work and how they can benefit your web development projects. For more information on this and other related topics, be sure to check out our articles on Apache, Nginx, and LiteSpeed web servers, as well as our guides on dedicated server, VPS server, cloud hosting, and shared hosting.
FAQs
-
What is Subversion?
Subversion, also known as SVN, is an open-source version control system. It manages files and tracks changes made to them, allowing you to recover older files and directories and examine the history of your files and directories to see how they have changed over time.
-
What is the purpose of the WANdisco repository in this tutorial?
The WANdisco repository is used to download and install Subversion and the mod_dav_svn module, which is required for Subversion to work with the Apache HTTP server.
-
What is the role of the Apache HTTP server in this setup?
The Apache HTTP server is used to serve the Subversion repositories over HTTP. This allows you to access your repositories from a web browser.
-
What is the purpose of the svnaccess file?
The svnaccess file is used to control access to the Subversion repositories. It specifies which users have read and write access to each repository.
-
How do I test my Subversion server?
You can test your Subversion server by accessing one of your repositories from a web browser. If everything is set up correctly, you should be prompted to enter your username and password, and then be able to access the repository.