Apache Subversion is also known as SVN, it is an open-source versioning and revision controlling program which helps in storing the present and past historic file versions like documents, source codes and web pages. SVN comes under Apache License.
In this tutorial, we will learn how install & configure SVN on RHEL 8 and Rocky Linux 8. Here authenticated users will be allowed to perform check-in and checkout operations on SVN repository.
Step 1) Install SVN and Apache
SVN & Apache (http) package are available in the default package repositories of RHEL 8 and Rocky Linux 8. Run following dnf command to install required packages,
$ sudo dnf install -y httpd subversion mod_dav_svn
Step 2) Edit Configuration File of Apache Subversion
Create a file ‘/etc/httpd/conf.d/subversion.conf’ and add the following lines to it.
$ sudo vi /etc/httpd/conf.d/subversion.conf <Location /svn> DAV svn SVNParentPath /var/www/svn/ AuthType Basic AuthName "SVN Repository" AuthUserFile /etc/svn/svn-auth-accounts Require valid-user </Location>
Above settings will allow only the authenticated users to use SVN repository.
Step 3) Create SVN Users via htpasswd command
Run the beneath command to create user for SVN via htpasswd command,
$ sudo htpasswd -cm /etc/svn-auth-accounts linuxtechi New password: Re-type new password: Adding password for user linuxtechi $
In the above htpasswd command we have used ‘-c’ & ‘-m’ options. -c is used to create the password file (/etc/svn-auth-accounts) and -m used to create MD5 encryption password for the user. To create second user remove the ‘-c’ from the above command otherwise it will overwrite existing file.
$ sudo htpasswd -m /etc/svn-auth-accounts pkumar New password: Re-type new password: Adding password for user pkumar $
Step 4) Create SVN Repository
Run following commands one after the another to create your first svn repository and to set the required permissions,
$ sudo mkdir /var/www/svn $ cd /var/www/svn/ $ sudo svnadmin create repo $ sudo chown apache.apache repo/
Note: In case SELinux is enable then apply below selinux rules by running,
$ sudo chcon -R -t httpd_sys_content_t /var/www/svn/repo/ $ sudo chcon -R -t httpd_sys_rw_content_t /var/www/svn/repo/
Step 5) Start and Enable Apache Service
Run the beneath systemctl commands to start and enable apache web server’s service.
$ sudo systemctl start httpd $ sudo systemctl enable httpd
In case firewall is enabled on your system then allow following port by running,
$ sudo firewall-cmd --permanent --zone=public --add-service=http $ sudo firewall-cmd --permanent --zone=public --add-service=https $ sudo firewall-cmd --reload
Step 6) Access SVN Repo from Web Browser
Type the following URL in your web browser,
http://<SVN-System-IP>/svn/repo
In the browser just replace ip address with your SVN Server’s IP
Step 7) Disable anonymous access on SVN Repository
Edit the file – /var/www/svn/repo/conf/svnserve.conf, add the below two lines
## Disable Anonymous Access anon-access = none ## Enable Access control authz-db = authz
Step 8) Import Project Directory’s Content to SVN repository
Let’s create our first sample project directory and its file.
$ mkdir devops $ cd devops/ $ touch testfile_1 ; touch testfile_2 $
Now use SVN command to import ‘devops’ project to the repo. As we have created sample ‘devops’ project on the svn server itself. So run following svn command,
$ sudo svn import -m "First SVN Repo" devops file:///var/www/svn/repo/devops Adding devops/testfile_1 Adding devops/testfile_2 Committing transaction... Committed revision 1. $
Now Check from the Browser
Step 9) Check Out the Project
In my case, I want to checkout the devops project on my Ubuntu laptop using SVN command. So to perform checkout operations, please make your system has subversion package installed, if not then use “sudo apt install -y subversion“ command to install required package.
$ mkdir svn_data $ svn co http://192.168.1.180/svn/repo/devops/ /home/pkumar/svn_data/ --username linuxtechi A svn_data/testfile_1 A svn_data/testfile_2 Checked out revision 1. $
Step 10) Committing Changes
After making required changes in the project code , we can commit the changes to the SVN repos. In my case i have created one more file in linuxproject folder.
$ cd svn_data/ $ touch testfile_3 $ svn add testfile_3 --username linuxtechi A testfile_3 $ $ svn commit -m "New File addedd" --username linuxtechi Adding testfile_3 Transmitting file data . Committed revision 2. $
Note: While committing the changes if you are getting below error
svn: E000013: Commit failed (details follow):
svn: E000013: could not begin a transaction
Then to solve this error , make sure that Apache user has read & write access to the entire repository.
$ cd /var/www/svn/repo $ sudo chown -R apache:apache * $ sudo chmod -R 664 *
That’s all from this tutorial, please do share your feedback and queries in below comments section.
Nice article with well-explained procedure. BUT.
The real tricky part for the source-control tools is the authentication. Especially if/when you want to open-up your server to the public.
Obviously you (really) need to avoid storing your password unencrypted!
The latest trend is to use SSH-keys instead of username/password. Is it possible with SVN?
Hi.
Directive Alias /svn /var/www/svn causes “svn: E195019: Redirect cycle detected for URL ‘http://….” error and you are unable to do checkout for example! Problem detected on Centos 7 , Server version: Apache/2.4.6 (CentOS), svn version 1.7.14
# vi /etc/httpd/conf.modules.d/10-subversion.conf
Alias /svn /var/www/svn
Commenting out # Alias /svn /home/testsvn solves this problem – after a few hours of googling and pounding my head against the wall.
Thanks Josef. It solved my problem too. thanks for sharing solution
Thanks Josef!!! thanks for sharing!
Thank you Josef !! You save me for a lot of time !!
Hello, I am following the tutorial and I think I’ve got it all right. But now I do not interpret php files, if I agree to index.php is downloaded to my computer, it seems that does not recognize the php, but if I access the HTML if it looks good.
Do you know if I have to set something else to see the php?
Thank you !!
hello…
very nice tutorial but only one thing is in step 8 when i try to import i am getting a error E205000:Invalid URL…. please help me
Can you give me the full command which you are trying to run to import sample project. In my Case i am using file
The result of: svn import -m “First SVN Repo” /mnt/linuxproject
or
svn import -m “First SVN Repo” –username MYUSER–password MYPASSWORD /mnt/linuxproject
results in this console output:
svn: E205000: Try ‘svn help’ for more info
svn: E205000: Invalid URL ‘/mnt/linuxproject’
sorry for copy and paste error… the -username and -password really are two hyphens, not a long dash.
Never mind. I figured out the problem. It works when we append the URL of the server, for example:
#svn import -m “First SVN Repo” –username MYUSER –password MYPASSWORD /mnt/linuxproject ‘http://MYSERVER/svn/repo’
(above should show hyphen hyphen before username and password switches; if it shows long dash, it really should be hyphen hyphen)
svn import is giving me this error:
svn: E175011: Repository moved permanently to ‘http://MYSERVER/svn/repo’; please relocate
Excellent writeup. We were using subversion in ClearOS 6.8. Recently we upgraded to ClearOS 7.3. Ran into an issue and while looking it up came across your article. We are able to follow the steps and checkout and commit changes. However not able to connect from TortoiseSVN client on windows. When we try to connect to repo, it prompts for the password, and after that its waits for a while before finally giving an error “Error running context. The server unexpectedly closed the connection”. Any thoughts as to what might be going on?
Hi Parveen,
We have not tested these steps on ClearOS 7.3, For the basic troubleshooting make sure required permissions are set on the Project, SELinux rules should be properly set in case it is enabled and check the Apache logs for errors
Hi ,
I followed the same procedure . I have not got any error while doing .
After runnig this commnand — > systemctl enable httpd.service
Got this output
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/ httpd.service.
but still am not able to access svn repo
am getting this error
Not Found
The requested URL /svn/repo was not found on this server.
Can someone suggest me what needs to be changed . if there problem with my machine .
Excellent article
Hi there,
I am currently moving from Windows SVN to CentOS 7
I have a folder which contains the all the users designated to each repo.
I have imported it into CentOS.
My question is, where do i put this file? I checked “svn-auth-accounts” and I just have the one user which i created, and the password is hashed.
Where is the file that contains the groups?