Install SVN (Subversion) Server on Fedora 18/17, CentOS/Red Hat (RHEL) 6.4/5.9
This is guide, howto install SVN (Subversion) server on Fedora 18/17/16/15/14, CentOS 6.4/6.3/6.2/6.1/6/5.9, Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9.
What is SVN (Subversion)?
Subversion is a free/open-source version control system. Subversion manages files and directories, and the changes made to them, over time. This allows you to recover older versions of your data, or examine the history of how your data changed. In this regard, many people think of a version control system as a sort of “time machine”.
Install SVN (Subversion) Server on Fedora 18/17/16/15/14, CentOS 6.4/6.3/6.2/6.1/6/5.9, Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9
1. Change root user
su - ## OR ## sudo -i |
2. Install needed packages (mod_dav_svn and subversion)
yum install mod_dav_svn subversion |
Note: If you don’t have Apache installed already, this command installs it also. Read more about installing Apache and PHP >>
3. Modify Subversion config file /etc/httpd/conf.d/subversion.conf
Add following config to /etc/httpd/conf.d/subversion.conf file:
LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so <Location /svn> DAV svn SVNParentPath /var/www/svn AuthType Basic AuthName "Subversion repositories" AuthUserFile /etc/svn-auth-users Require valid-user </Location> |
Read more SVN Access Control >>
4. Add SVN (Subversion) users
Use following command:
## Create testuser ## htpasswd -cm /etc/svn-auth-users testuser New password: Re-type new password: Adding password for user testuser ## Create testuser2 ## htpasswd -m /etc/svn-auth-users testuser2 New password: Re-type new password: Adding password for user testuser2 |
Note: Use exactly same file and path name as used on subversion.conf file. This example use /etc/svn-auth-users file.
Read more SVN Access Control >>
5. Create and configure SVN repository
mkdir /var/www/svn cd /var/www/svn svnadmin create testrepo chown -R apache.apache testrepo ## If you have SELinux enabled (you can check it with "sestatus" command) ## ## then change SELinux security context with chcon command ## chcon -R -t httpd_sys_content_t /var/www/svn/testrepo ## Following enables commits over http ## chcon -R -t httpd_sys_rw_content_t /var/www/svn/testrepo |
Restart Apache:
/etc/init.d/httpd restart ## OR ## service httpd restart |
Goto http://localhost/svn/testrepo address and you should see something like following, write username and password:
6. Configure repository
To disable anonymous access and enable access control add following rows to testrepo/conf/svnserve.conf file:
## Disable anonymous access ## anon-access = none ## Enable access control ## authz-db = authz |
7. Create trunk, branches and tags structure under testrepo
Create “template” directories with following command:
mkdir -p /tmp/svn-structure-template/{trunk,branches,tags} |
Then import template to project repository using “svn import” command:
svn import -m 'Initial import' /tmp/svn-structure-template/ http://localhost/svn/testrepo/ Adding /tmp/svn-structure-template/trunk Adding /tmp/svn-structure-template/branches Adding /tmp/svn-structure-template/tags Committed revision 1. |
Check results on browser and see testrepo revision 1:
Remember also take regular backups. Here is guide howto backup and restore SVN (Subversion) Repositories.
Our forums user Will have also written guide, howto to install and configure SVN (Subversion). This is little bit different method.
246 Comments
Leave a Comment
Trackbacks/Pingbacks
- Install SVN Server on Fedora 13/14, CentOS/Red Hat (RHEL) 5.5/6 « svn - [...] Więcej: Install SVN Server on Fedora 13/14, CentOS/Red Hat (RHEL) 5.5/6 [...]
- Install SVN (Subversion) Server on Fedora 15/14, CentOS/Red Hat (RHEL) 5.6/6 | 資訊與工作 - [...] Install SVN (Subversion) Server on Fedora 15/14, CentOS/Red Hat (RHEL) 5.6/6 Install SVN (Subversion) Server on Fedora 15/14, CentOS/Red ...
This is guide, howto install SVN (Subversion) server on Fedora 18/17/16/15/14, CentOS 6.4/6.3/6.2/6.1/6/5.9, Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9.


hi, I installed subversion on fedora 13 following this guide, when i do “svn import -m ‘Initial import’ /tmp/svn-structure-template/ http://localhost/svn/testrepo/” ask me the root password Authentication realm: Subversion repositories
Password for ‘root’:
I typed any password and then ask me the username
Authentication realm: Subversion repositories
Username:
I typed testuser2
Password for ‘testuser2′:
ask me the password
I typed the password for testuser2, and send me this message
svn: Repository moved permanently to ‘http://localhost/svn/testrepo/’; please relocate
can you helpme
Hi gb,
Sounds like some configuration error. Please post your subversion.conf file content. Do you have any other config for subversion or svn path?
Try to check out your repository on some test directory, like following:
Is this working ok?
JR thanks for the answer
this is my subversion.conf
[myserver]#cat /etc/httpd/conf.d/subversion.conf
#############
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
DAV svn
SVNParentPath /var/www/svn
AuthType Basic
AuthName “Subversion repositories”
AuthUserFile /etc/svn-auth-users
Require valid-user
#####################
i tryed
mkdir /tmp/testrepo
cd /tmp/testrepo
svn co http://localhost/svn/testrepo/ .
the result still this
[myserver]#svn co http://localhost/svn/testrepo/ .
Authentication realm: Subversion repositories
Password for ‘root’:
Hi again,
Do you have
and
on your subversion.conf?
After Password for ‘root’: press return and then insert your username and password, is it working then ok?
hi
I found the problem
I was using /var/www/html/ to create svn dir
I changed for /var/www/ and it works
I really appreciate your help
Really nice hear that you got it working! Excellent!
put root password and then it will ask you for svn repos username and password
hii. my name is deepti and i m a trainee .i m working on Linux and my project is to setup a svn server for my office i understand your guidline but i m not able to connect with my clients will you help me..
Hi Deepti,
Are you trying to connect to SVN server from the other office computers?
hii.thanx’s for reply.No i m not connect to svn server from other office. but i have more problem in svn. in my office there is svn server but i m not able to lock the existing file in server and even if i enable auto-prop=yes in /root/subversion/conf then it only lock php file as a new file.please help me it’s really important for me my deadline is coming near.
Hi Deepti,
Plz send me the complete practical of SVN server side and client side both. plz plz
great, thanks for the info — very helpful
Worked Fine! No modifications on install, just followed the how-to!
Hello,
I have follow your instructions but when i try to execute the svn import:
svn import -m ‘Initial import’ /tmp/svn-structure-template/ http://localhost/svn/testrepo/
Reino de autentificación: Subversion repositories
password ‘root’:
Reino de autentificación: Subversion repositories
User: testuser
password ‘testuser’:
Reino de autentificación: Subversion repositories
User: testuser
password ‘testuser’:
svn: OPTIONS de ‘http://localhost/svn/testrepo’: authorization failed: Could not authenticate to server: rejected Basic challenge (http://localhost)
i have also tried:
mkdir /tmp/testrepo
cd /tmp/testrepo
svn co http://localhost/svn/testrepo/ .
But it is the same…i can do it…
My config file is:
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
DAV svn
SVNParentPath /var/www/svn
AuthType Basic
AuthName “Subversion repositories”
AuthUserFile /etc/svn-auth-users
Require valid-user
I dont know why happens….please if you could help me.
Thanks
I try execute chcon -R -t httpd_sys_content_t /var/www/svn/testrepo :
chcon: can’t apply partial context to unlabeled file `db.lock’
chcon: can’t apply partial context to unlabeled file `db-logs.lock’
….
Why?
I am facing the same prob. Dunno wat went wrong?
Hi Parikshit Tiwari,
Try following instead:
Looks like some reason you don’t have user or/and role…is this working for you?
Hey awsm! it started wokring for me!
thanx a tonnn!!!
So, I have the same error….
Perfect tutorial everything works!
One thing is missing:
- before launching http://localhost/svn/testrepo in the browser apache webserver must be started
/etc/init.d/httpd start
Thanks for the tutorial!
Good guide, I can connect locally, however I cannot connect to the server from a different computer.
I’ve added rules to the firewall config (and even tried disabling the firewall) however I still can’t reach the server from another system.
HI
I followed above steps, I able to install and configured and able to login using http://php.justfordemo.biz/svn/testrepo URL, but, once I try to commite any file I am getting Couldn’t perform atomic initialization error, please help me
Thanks
Jyothi
Hi jyothi,
Did you tried just one time or multiple times?
Could you tell more specific are you using command line or are you using some graphical client?
I tried the first initial import and this is what I get:
svn: access to ‘/svn/wvsrepo’ forbidden
I am not using a AuthzSVNAccessFile
Please help.
Hi ad,
Could you post output of following commands:
Nice one, followed this one,
But after the “step 5. Create and configure SVN repository” please add the apache restart command. I know you do know this.
service httpd restart
I followed this one and had a working SVN repo.. Thanks..
Hi Aneek,
I added apache restart thanks! :)
You are Most welcome JR..
I always keep following your linux based tutorials and articles…
Do you have anything about Samba Server.? I have a great interest in it.
Thanks Aneek! :)
Nice to hear that you follow my Linux based tutorials and articles! ;)
I don’t have anything about Samba Server, because I don’t use Samba and I don’t have any Windows machines… :) But if you have some knowledge about Samba you can of course share it with us. :)
I have followed your tutorial to the letter however when I navigate to the repository via a web browser it does not prompt me for a password.
Hi Brian,
Try to restart apache (as Aneek recommend) with following command:
If it doesn’t help, then please let me know?
Yes, I have the same problem…
I’m having the same problem as raqeul. You didn’t replied to his question.
Please Reply whats the issue. I’m having the exact problem. when i use http:// to import it does not work.
I have follow your instructions but when i try to execute the svn import:
svn import -m ‘Initial import’ /tmp/svn-structure-template/ http://localhost/svn/testrepo/
Reino de autentificación: Subversion repositories
password ‘root’:
Reino de autentificación: Subversion repositories
User: testuser
password ‘testuser’:
Reino de autentificación: Subversion repositories
User: testuser
password ‘testuser’:
svn: OPTIONS de ‘http://localhost/svn/testrepo’: authorization failed: Could not authenticate to server: rejected Basic challenge (http://localhost)
Hi Talha,
Did you create testuser with testuser password?
Did you enabled commits over http on step 5:
hi, I copy your step on my fedora 15 server, but it doesn’t work. I input http://localhost/svn/testrepo/ in my browser, there isn’t any hint.
thanks for introduce, I expect your more advice.
hi, JR, please! thank you!
Hi Marvin,
Do you get any SELinux alerts, when you try to access your svn repo?
Hi, JR.
when I accessed my svn repo, I didn’t get any SELinux alerts.
It seems as the basic auth don’t work either..
thank you!
JR, by the way, when I get the status of my selinux, which is disabled.
hi, JR, are you online? thank you!
Hi Marvin,
Could tell more specific, do you get some error (on browser) when you try to access http://localhost/svn/testrepo/ address?
I tested this guide on clean Fedora 15 install and it’s working just as it should be. So I suggest you try again!
Then if you can’t get it working you could post your /var/log/httpd/error_log to pastebin…
JR, Thank you very much. I reinstalled my fedora 15 system, and reinstalled subversion accorded to your doc. It’s working.
thank you again!
Excellent Marvin! :) You are welcome!
Help>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
chcon: can’t apply partial context to unlabeled file
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
when I input
chcon -R -t httpd_sys_content_t /var/www/svn/testrepo
>>>>>>>>>>>>>>>>>>
Any advice ? Thanks
>>>>>>>>>>>>>>>>>>>>
Hi wx,
Could you post full error message and output of following commands:
Hi JR,
everything is fine and working good for me as you instructed. But i want to restrict the few users to access some of the directories in the project.
Can you help me how can i do that.
Regards,
Abdul.
Hi Abdul,
Nice to hear that you got it working… :)
Check another guide, SVN (Subversion) Access Control with Apache and mod_authz_svn.
Hi JR,
I followed the above steps what you have written on this page and with your help I am able to see my repository working fine.
Now I want to use my stsyem ip address instead of localhost and want to access from other computers. what will be the command.
I really appreciate your help.
Thank you.
Hi Ravindra,
Nice to hear that you got SVN working! :)
To enable remote connections to Apache HTTP Server (this case to SVN) –> Open web server port (80) on iptables firewall:
1. Edit /etc/sysconfig/iptables file and add following line before COMMIT:
2. Restart Iptables Firewall:
Hi JR,
I am getting the below mentioned error when I restart Apache web server.
service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [Thu Jan 19 10:41:33 2012] [warn] module dav_svn_module is already loaded, skipping
[Thu Jan 19 10:41:33 2012] [warn] module authz_svn_module is already loaded, skipping
httpd: apr_sockaddr_info_get() failed for geovas
httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
testrepo – Revision 1: /
* branches/
* tags/
* trunk/
Powered by Subversion version 1.6.11 (r934486).
how to add directories and folders instead of branches, tags and trunk for different-2 users. so that the users can save their files into their particular folder.
Please help me out. I’m running short of time.
Thanks
Hi JR,
I have commented two lines in the subversion.conf file i.e. as shown below
#LoadModule dav_svn_module modules/mod_dav_svn.so
#LoadModule authz_svn_module modules/mod_authz_svn.so
And after that when I restart Apache web server, I’m getting the following:
Stopping httpd: [ OK ]
Starting httpd: httpd: apr_sockaddr_info_get() failed for geovas
httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
Please help me out JR.
Hi Ravindra,
Load module errors:
Just because you have loaded modules multiple times.
httpd: apr_sockaddr_info_get() failed for error:
Apache fails to match hostname via current hostname. Easiest way to solve this is setup your hostname to /etc/hosts file.
Then your SVN problem, so you have 2 different user, but are those users doing different projects? This branches/ tags/ trunk/ is SVN default setup and almost always all svn repos have such a structure…
Hi JR,
I’m getting the following error while restarting httpd.
Starting httpd: httpd: Syntax error on line 221 of /etc/httpd/conf/httpd.conf: Could not open configuration file /etc/httpd/conf.d/.conf: No such file or directory
Hi Ravindra,
So question is, what you have in /etc/httpd/conf/httpd.conf file line 221?
And what you have /etc/httpd/conf.d/ directory?
Apache try to open /etc/httpd/conf.d/.conf conf file. File with full name .conf.
Hi JR,
I follow your step but when I log in I got the following error:
Could not open the requested SVN filesystem
Could you please help me with this. I have been googling but no help.
Some background info:
The server is a virtual server and I access it from a remote machine. The OS is CentOS 6 and I use SVN version 1.6.11.
Hi Naka,
Are you using exactly this setup on your system?
Hi JR,
Yes I followed the set up listed above. However, in step 5, because i have the same problem with Parikshit Tiwari above, so I use the chcon commands in the comment box which you provided for her in your comment above, not the original one in your post.
Hope to hear from you soon.
Thank you,
Naka
Hi again Naka,
Could you post output of following commands:
Hi JR,
This is the output of the commands:
-Out put for “cat /etc/httpd/conf.d/subversion.conf”
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
#
# Example configuration to enable HTTP access for a directory
# containing Subversion repositories, “/var/www/svn”. Each repository
# must be both:
#
# a) readable and writable by the ‘apache’ user, and
#
# b) labelled with the ‘httpd_sys_content_t’ context if using
# SELinux
#
#
# To create a new repository “http://localhost/repos/stuff” using
# this configuration, run as root:
#
# # cd /var/www/svn
# # svnadmin create stuff
# # chown -R apache.apache stuff
# # chcon -R -t httpd_sys_content_t stuff
#
#
# DAV svn
# SVNParentPath /var/www/svn
#
# # Limit write permission to list of valid users.
#
# # Require SSL connection for password protection.
# # SSLRequireSSL
#
# AuthType Basic
# AuthName “Authorization Realm”
# AuthUserFile /path/to/passwdfile
# Require valid-user
#
#
DAV svn
SVNParentPath /home/naka/svn
AuthType Basic
AuthName “Subversion repos”
AuthUserFile /etc/svn-auth-users
#AuthUserFile /etc/httpd/conf/htpasswd.users
Require valid-user
-Output for “ls -laZ /var/www/”
drwxr-xr-x root root ? .
drwxr-xr-x root root ? ..
drwxr-xr-x root root ? cgi-bin
drwxr-xr-x root root ? error
drwxr-xr-x root root ? html
drwxr-xr-x root root ? icons
For the second command, I m not sure whether you want to use the directory /var/www or you want to use the parent directory of svn. So, in case you want /www/var, it’s the one above, in case you want the parent directory of svn, it’s the one below.
ls -laZ /home/naka
drwx—— naka naka ? .
drwxr-xr-x root root ? ..
-rw-r–r– naka naka ? .bash_logout
-rw-r–r– naka naka ? .bash_profile
-rw-r–r– naka naka ? .bashrc
-rw-r–r– naka naka ? .emacs
drwxr-xr-x root root ? svn
drwxr-xr-x root root ? svntest
-Output for ls -laZ /var/www/svn ( I put my repository at a different place other than /var/www/svn, so I substitute my own path for it. The command is changed to: “ls -laZ /home/naka/svn”)
drwxr-xr-x root root ? .
drwx—— naka naka ? ..
drwxr-xr-x. apache apache suste_u:object_r:httpd_sys_content_t svndb
drwxr-xr-x. apache apache system_u:object_r:httpd_sys_content_t testrepo
-Output for ls -laZ /var/www/svn/testrepo (again using my own path: ls -laZ /home/naka/svn/testrepo)
drwxr-xr-x. apache apache system_u:object_r:httpd_sys_content_t .
drwxr-xr-x root root ? ..
drwxr-xr-x. apache apache apache:object_r:httpd_sys_content_t conf
drwxr-sr-x. apache apache apache:object_r:httpd_sys_content_t db
-r–r–r–. apache apache apache:object_r:httpd_sys_content_t format
drwxr-xr-x. apache apache apache:object_r:httpd_sys_content_t hooks
drwxr-xr-x. apache apache apache:object_r:httpd_sys_content_t locks
-rw-r–r–. apache apache apache:object_r:httpd_sys_content_t README.txt
Hi JR,
I just realized that I did not set the correct access right for the parent directory of svn (I did not let anybody read except for the owner). I set it to 755 and now it works.
I cant believe this stuff takes me 3 days to solve.
Thank you very much for your time. I really appreciate it.
Hi Naka,
I was just answering your question… :) And it’s very good to hear that you got it working.
Normally this style problems are always permission problems. :) And yes home directory is tricky place to keep web server content…normally it’s better do example /svn or /data/svn dir, instead of using any user home dir :)
Actually Apache user dir guide would have solved your home dir problem also. :)
hi
i followed the whole tut, but when trying to import , i get the following error message :
svn: Can’t open file ‘/var/www/svn/csp/db/txn-current-lock’: Permission denied
can you tell me what i am doing wrong ?
Thanks
Hi
i followed the whole tutorial step by step, but when i try to import, i get the following error message :
svn: Can’t open file ‘/var/www/svn/csp/db/txn-current-lock’: Permission denied
any idea ?
thanks
Hi Germain,
You followed guide and used csp repo name? Did you set right permissions and modified right files based on your repo name?
And you did try to import over http protocol?
everywhere where you put testrepo, i put csp, so i only changed that name. , and yes, i did try to import over http
svn import -m ‘Initial import’ /tmp/svn-structure-template/ http://localhost/svn/csp/
this is the one giving the error.
Could you post output of following commands:
http://pastebin.com/izuGpvED
http://pastebin.com/STnxP6bk
thanks for the help !! appreciate it
I found the problem
i had in httpd.conf
user nobody
group nobody
changed it back to apache and it worked !
Excellent to hear that you got problem solved! It sounded like a permission problem, and that’s what it was then. ;)
Hi JR;
Very nice work!
Wondering if you could shed some light on the following 2 issues.
1. When executing the following command –
“chcon -R -t httpd_sys_rw_content_t /var/www/svn/testrepo”
It returns many lines like this one –
“chcon: failed to change context of /var/www/svn/smackdab to root:object_r:httpd_sys_rw_content_t: Invalid argument”
2. When issuing the follow from the browser –
“http://localhost/svn/testrepo”
I does *** NOT *** challange for user credentials. It just goes straight to the repository.
Any help much appreciated.
Max…
Hi JR;
Update;
I changed the to exactly match your example and I am now getting challanged for credentials but I cannot get in using the the username and password that I setup. The other problem still remains; “”chcon: failed to change context of /var/www/svn/smackdab to root:object_r:httpd_sys_rw_content_t: Invalid argument”.
// ————————————————–
Posting output of following commands;
cat /etc/httpd/conf.d/subversion.conf
ls -laZ /var/www/
ls -laZ /var/www/svn
ls -laZ /var/www/svn/testrepo
// ————————————————–
cat /etc/httpd/conf.d/subversion.conf
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
DAV svn
SVNParentPath /var/www/svn
AuthType Basic
AuthName “Subversion repositories”
AuthUserFile /etc/svn-auth-users
Require valid-user
// ————————————————–
ls -laZ /var/www/
drwxr-xr-x root root system_u:object_r:httpd_sys_content_t .
drwxr-xr-x root root system_u:object_r:var_t ..
drwxr-xr-x root root system_u:object_r:httpd_sys_script_exec_t cgi-bin
drwxr-xr-x root root system_u:object_r:httpd_sys_content_t error
drwxr-xr-x root root system_u:object_r:httpd_sys_content_t html
drwxr-xr-x root root system_u:object_r:httpd_sys_content_t icons
drwxr-xr-x root root root:object_r:httpd_sys_content_t svn
// ————————————————–
ls -laZ /var/www/svn
drwxr-xr-x root root root:object_r:httpd_sys_content_t .
drwxr-xr-x root root system_u:object_r:httpd_sys_content_t ..
drwxr-xr-x apache apache root:object_r:httpd_sys_content_t testrepo
// ————————————————–
ls -laZ /var/www/svn/testrepo
drwxr-xr-x apache apache root:object_r:httpd_sys_content_t .
drwxr-xr-x root root root:object_r:httpd_sys_content_t ..
drwxr-xr-x apache apache root:object_r:httpd_sys_content_t conf
drwxr-xr-x apache apache root:object_r:httpd_sys_content_t dav
drwxr-xr-x apache apache root:object_r:httpd_sys_content_t db
-rwxr-xr-x apache apache root:object_r:httpd_sys_content_t format
drwxr-xr-x apache apache root:object_r:httpd_sys_content_t hooks
drwxr-xr-x apache apache root:object_r:httpd_sys_content_t locks
-rwxr-xr-x apache apache root:object_r:httpd_sys_content_t README.txt
Any help much appreciated.
Max…
Hi JR;
Got the “credential” problem resolved. Though there is an issue of overwritting the user crendials when using “htpasswd -cm /etc/svn-auth-users testuser”. If I create user1 and then user2, user1 is no longer in the “svn-auth-users” file. To fix it I had to manually enter the info created by the command into the file .
All that remains is the – ”chcon: failed to change context of /var/www/svn/smackdab to root:object_r:httpd_sys_rw_content_t: Invalid argument”.
Any help is MUCH appreciated.
Max…
Hi max,
Try following commands instead:
Hi JR;
As root, I tried the commands you suggested, both failed. Should I be in a particular place in the file-system before issuing the commands?
INPUT
chcon -h system_u:object_r:httpd_sys_rw_content_t /var/www/svn/repotest
RESULT
chcon: failed to change context of /var/www/svn/repotest to system_u:object_r:httpd_sys_rw_content_t: Invalid argument
INPUT
# chcon -R -h apache:object_r:httpd_sys_rw_content_t /var/www/svn/repotest/*
RESULT
chcon: failed to change context of /var/www/svn/repotest/conf to apache:object_r:httpd_sys_rw_content_t: Invalid argument
chcon: failed to change context of /var/www/svn/repotest/conf/passwd to apache:object_r:httpd_sys_rw_content_t: Invalid argument
Thank you JR!
Interesting, could you post output of following commands:
You’re not running the htpasswd with the ‘-cm’ both times are you? If so, you’re overwritting your /etc/svn-auth-users file and that’s why user1 is not longer there.
I ran both of the chcon commands as my repoadm, not as root. Worked for me.
Great bit of work you provided here. Just wanted to add a few things that I found along the way. While these instructions are great for controlling who can modify your repository, if you need to further restrict access (i.e., read/execute) outside of your owner/group levels you need to change the permissions to world. I wanted to restrict everything down to just the owner and those that would be working in SVN. Therefore, the chown -R you performed was changed to repoadm.apache. I add repoadm to the apache and svnusers group and the apache user to the repoadm. I had to do a chmod -R on the /var/www/svn to give g+w and o-rx.
Note to those that are testing out their implementation. When testing with a user that should NOT have the abiltity to perform tasks and the login fails, do NOT then switch to an authorized user and sign in on the same instance. The login information is cached in that account’s /home directory under the .subversion directory. If you happen to do this, delete that .subversion directory. Don’t worry about losing it, because it will be recreated the next time you do an SVN command for that account again.
Great Work JR, thanks for the instructions.
Hi Will,
And thanks for sharing! Very nice idea to do this! :)
Using Firefox to browse to: http://localhost/svn/repos
And I get error:
Forbidden
You don’t have permission to access /svn/repos on this server.
Apache/2.2.22 (Fedora) Server at localhost Port 80
Thank JR.
Hi Kang,
Is your repo working normally, if you try to access http://localhost/svn/repos/your_repo_name ?
Hello!
I have tried to setup SVN on my fedora server with so many how tos…. I do everything as it is said in the tutorials. The problem I have is that I always get 404 Not Found, when I’m trying to see some results either via my domain or even via localhost on my server.
Do you have an idea what I could have done wrong?
Thanks in advance
MG
Apologies for the double post, but for some reason I didn’t do a reply, but a normal one. Delete the first one if you can/don’t mind.
MG,
Can you perform ‘svn ls file:///var/www/svn’ and get a return? If so, then it sounds like you don’t have apache setup correctly in your user accounts. While you may be logged in as yourself, when you perform actions against the http:// it is really apache that is serving up your request. Ensure that your apache user is associated with the group that owns your /var/www/svn and /var/www/svn/repo. Also, make sure that both of those locations have the same owner/group setups and the permissions are set to 755 for the svn and 775 for the repo level. This will further restrict unauthorized users from accessing your data.
Will
Hey Will
Thanks for the fast response. I rebooted the computer yesterday and I have several problems more now \o/. I will look at your suggestions when I’m back on the state I was…
MG,
No problem, happy to help if I can.
Will
Will,
Thanks a lot for your help. I found out my crap router is causing problems. I got a new one and followed the tutorial here step by step. It works fine now! I only have one issue… I can only login with testuser2. testuser and a self created user won’t work… have I missed to grant the users rights somewhere?
Thanks in advance
MG
MG,
Sounds like you’re running the htpasswd command string with the
-cm option each time. You only run the -c option of that when you are creating your initial user because it is creating the user authorization file. For each additional user you add, use htpasswd -m /etc/svn-auth-users testuser (replace the /etc/svn-auth-users portion with whatever path you have for your file). To check to see if that is the problem, cat the /etc/svn-auth-users file and see if the users have been added to that file. If not, it is more than likely the -cm option problem.
Hope that helps out, let me know.
Will
MG,
Can you perform ‘svn ls file:///var/www/svn’ and get a return? If so, then it sounds like you don’t have apache setup correctly in your user accounts. While you may be logged in as yourself, when you perform actions against the http:// it is really apache that is serving up your request. Ensure that your apache user is associated with the group that owns your /var/www/svn and /var/www/svn/repo. Also, make sure that both of those locations have the same owner/group setups and the permissions are set to 755 for the svn and 775 for the repo level. This will further restrict unauthorized users from accessing your data.
Will
hi there great tut.
i only have a question where is the configuration file wich one can set the auto-props.
cause there was no files in /etc/subversion and i create one conf and put like
enable-auto-props = yes
[auto-props]
* = svn:needs-lock = *
and gave me nothing no new files were marked with that propertie.
Could you please help me out ??? :)
Hi migueldesousa,
Thank you!
The subversion configuration area is for subversion clients, not the
server. Right place for auto-props is ~/.subversion/config configured per-user or /etc/subversion/config configured machine-wide. And user own configuration overrides /etc/subversion/config.
thanks,
So i should configure the client not the server.
Thanks :D i was like crazy searching how tha heck i could configure this :) Thank you very much
Hi, I have the same problem as in the first comment. The solutions given are not working for me. Do you have any other ideas?
# svn import -m 'Initial import' /tmp/svn-structure-template/ http://localhost/svn/testrepo/
Authentication realm: Subversion repositories
Password for 'root':
Authentication realm: Subversion repositories
Username: jp
Password for 'jp':
svn: Repository moved permanently to 'http://localhost/svn/testrepo/'; please relocate
Hi JD,
Could you post your subversion.conf file content?
Hi JR,
[code]# cat /etc/httpd/conf.d/subversion.conf
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
#
# Example configuration to enable HTTP access for a directory
# containing Subversion repositories, "/var/www/svn". Each repository
# must be both:
#
# a) readable and writable by the 'apache' user, and
#
# b) labelled with the 'httpd_sys_content_t' context if using
# SELinux
#
#
# To create a new repository "http://localhost/repos/stuff" using
# this configuration, run as root:
#
# # cd /var/www/svn
# # svnadmin create stuff
# # chown -R apache.apache stuff
# # chcon -R -t httpd_sys_content_t stuff
#
#
# DAV svn
# SVNParentPath /var/www/svn
#
# # Limit write permission to list of valid users.
#
# # Require SSL connection for password protection.
# # SSLRequireSSL
#
# AuthType Basic
# AuthName "Authorization Realm"
# AuthUserFile /path/to/passwdfile
# Require valid-user
#
#
DAV svn
SVNParentPath /var/www/svn
AuthType Basic
AuthName "Subversion repositories"
AuthUserFile /etc/svn-auth-users
Require valid-user
Do you have
and
on your subversion.conf?
Yep, but it’s gone in the comment
Okay :)
Could you next post output of following commands:
# ls -la /var/www/totaal 28
drwxr-xr-x 7 root root 4096 29 mrt 15:54 .
drwxr-xr-x. 16 root root 4096 22 mrt 15:12 ..
drwxr-xr-x 2 root root 4096 13 feb 15:31 cgi-bin
drwxr-xr-x 3 root root 4096 29 mrt 15:50 error
drwxr-xr-x 2 root root 4096 13 feb 15:31 html
drwxr-xr-x 3 root root 4096 29 mrt 15:50 icons
drwxr-xr-x 3 root root 4096 29 mrt 15:54 svn
# ls -la /var/www/svn
totaal 12
drwxr-xr-x 3 root root 4096 29 mrt 15:54 .
drwxr-xr-x 7 root root 4096 29 mrt 15:54 ..
drwxr-xr-x. 6 apache apache 4096 29 mrt 15:54 testrepo
ls -la /var/www/testrepo
ls: kan geen toegang krijgen tot /var/www/testrepo: Bestand of map bestaat niet
But I think you mean:
# ls -la /var/www/svn/testrepo/
totaal 32
drwxr-xr-x. 6 apache apache 4096 29 mrt 15:54 .
drwxr-xr-x 3 root root 4096 29 mrt 15:54 ..
drwxr-xr-x. 2 apache apache 4096 29 mrt 15:54 conf
drwxr-sr-x. 6 apache apache 4096 29 mrt 15:54 db
-r--r--r--. 1 apache apache 2 29 mrt 15:54 format
drwxr-xr-x. 2 apache apache 4096 29 mrt 15:54 hooks
drwxr-xr-x. 2 apache apache 4096 29 mrt 15:54 locks
-rw-r--r--. 1 apache apache 229 29 mrt 15:54 README.txt
Thanks, looks good…and you are totally right, I meant /var/www/svn/testrepo and I need also same output also with context parameter. :)
So could you also post output of following commands:
# ls -laZ /var/www/drwxr-xr-x root root ? .
drwxr-xr-x. root root system_u:object_r:var_t:s0 ..
drwxr-xr-x root root ? cgi-bin
drwxr-xr-x root root ? error
drwxr-xr-x root root ? html
drwxr-xr-x root root ? icons
drwxr-xr-x root root ? svn
# ls -laZ /var/www/svn
drwxr-xr-x root root ? .
drwxr-xr-x root root ? ..
drwxr-xr-x. apache apache apache:object_r:httpd_sys_rw_content_t testrepo
# ls -laZ /var/www/svn/testrepo
drwxr-xr-x. apache apache apache:object_r:httpd_sys_rw_content_t .
drwxr-xr-x root root ? ..
drwxr-xr-x. apache apache apache:object_r:httpd_sys_rw_content_t conf
drwxr-sr-x. apache apache apache:object_r:httpd_sys_rw_content_t db
-r--r--r--. apache apache apache:object_r:httpd_sys_rw_content_t format
drwxr-xr-x. apache apache apache:object_r:httpd_sys_rw_content_t hooks
drwxr-xr-x. apache apache apache:object_r:httpd_sys_rw_content_t locks
-rw-r--r--. apache apache apache:object_r:httpd_sys_rw_content_t README.txt
Some reason your ls -laZ /var/www/ command output looks little bit strange. You could try fix svn directory security context with following command:
Is it working then? If not, then please post ls -laZ /var/www/ output again…
When I try your command I get this:
# chcon -R -t httpd_sys_content_t /var/www/svn
chcon: can't apply partial context to unlabeled file `/var/www/svn'
I think this has something to do with SELinux?
Yes this is SELinux problem.
Then try following instead:
Is it working then? Or do get more some another error?
Ok, no error now but still not working :)
]# ls -laZ /var/www/
drwxr-xr-x root root ? .
drwxr-xr-x. root root system_u:object_r:var_t:s0 ..
drwxr-xr-x root root ? cgi-bin
drwxr-xr-x root root ? error
drwxr-xr-x root root ? html
drwxr-xr-x root root ? icons
-rw-r--r-- root root ? index.html
drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t svn
When I connect with my webbrowser (on a other system) to http://192.168.1.20/svn/testrepo/ I get this:
testrepo – Revision 0: /
Powered by Subversion version 1.6.17 (r1128011).
Actually it’s working then…you should get testrepo – Revision 0: / because you have imported nothing yet… :)
Try to run import:
Do you get any errors?
I already tried that:
# svn import -m 'Initial import' /tmp/svn-structure-template/ http://localhost/svn/testrepo/
Authentication realm: Subversion repositories
Password for 'root':
Authentication realm: Subversion repositories
Username: jp
Password for 'jp':
svn: Repository moved permanently to 'http://localhost/svn/testrepo/'; please relocate
Did you run it again after you changed /var/www/svn directory SELinux security context?
And did you run it on same machine where your svn server is running?
If you want run import command from remote system then you need to use your server ip address instead localhost.
Normally this error svn: Repository moved permanently to … please relocate refers to some error on subversion.conf. You could post it again inside code-block if you want to and you could of course create some another repo and test, if it’s working…
Yes I did it after your command. And on the local machine I get the same page (with Lynx).
I think the problem still is that “httpd_sys_content_t” thing.
@Will I know, but that’s stripped because I used the wrong code tag.
# cat /etc/httpd/conf.d/subversion.confLoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
# ...... blabla
DAV svn
SVNParentPath /var/www/svn
AuthType Basic
AuthName "Subversion repositories"
AuthUserFile /etc/svn-auth-users
Require valid-user
Ow inside the code tag it’s also gone :)
If it’s just like:
Then it’s okay… :)
<pre lang=”bash”>content</pre> should work… ;)
And when you see testrepo – Revision 0: /, it means that you can use your repo, but some reason import is not working…could you try following example on that remote machine:
Is it possible to commit?
# svn co http://localhost/svn/testrepo .
Authentication realm: Subversion repositories
Password for 'root':
Authentication realm: Subversion repositories
Username: jp
Password for 'jp':
svn: Repository moved permanently to 'http://localhost/svn/testrepo/'; please relocate
Hey guys, I may be off on this, but from the subversion.conf file, I don’t see any Location tags (i.e., ). Also, make sure that they are not set to .
Will
It removed the Location example that I provided before. The example should be “” Greater than followed by Location /svn Less than with a trailing Greater than Location Less than symbol.
Will
Yeah, now that I tried to type in the Location tags I see it goes away.
I believe I’m having a permissions error. When I go to http://localhost/svn/testrepo/ I am getting Could not open the requested SVN filesystem. Where should I look first?
Hi Jen,
Could you first post your subversion.conf, you can put it inside following tags:
<pre lang=”bash”>content</pre> :)
I tried SVNParentPath and it throws an error on httpd restart. No error with SVNPath.
JR, I have it working now. I made another change and went back to the configuration and was able to use SVNParentPath and it now works.
Thank You
Hi Jen,
Nice to hear that you got it working! :)
I believe that your configuration is okay :D This is some WP thing, it allows admin post any tags and filter all other poster tags. I have to take a look that later… :)
But yes, could you try following (on remote machine):
# svn co http://localhost/svn/testrepo .
Authentication realm: Subversion repositories
Password for 'root':
Authentication realm: Subversion repositories
Username: jp
Password for 'jp':
svn: Repository moved permanently to 'http://localhost/svn/testrepo/'; please relocate
[root@subversion-server testrepo]#
@JD
Looks like everything is okay, but it’s not still working…I just tested this on clean installed CentOS 6.2 and Fedora 16 and this guide is working normally for me…
Could you still post output of following commands:
I’m also using Fedora 16.
# ls -laZ / |grep var
drwxr-xr-x. root root system_u:object_r:var_t:s0 srv
drwxr-xr-x. root root system_u:object_r:var_t:s0 var
# ls -laZ /var |grep www
drwxr-xr-x root root ? www
Clean install the best option? :)
Thanks and actually problem might be with security context of /var/www directory, try to set httpd_sys_content_t also to /var/www dir, with following command:
Then try svn checkout, import, commit, etc? :)
First maybe svn repos clean install, before whole system clean install… :D
I modified your install instructions slightly and wanted to share them with you. These have been used over and over again without problem. The only real difference is that I created OS level accounts for each user and changed some permissions. The most important part was adding apache to the svnusers group because it’s really that account that is running the svn commands and not the actual user.
Note: I am running this in an Oracle VM. To gain access to the repo on my host machine’s browser I had to change the network adapter to Bridged. For my CentOS wired connection I had to remove the “Require IPv4 addressing for this connection to complete”. This will give you the IP address you need to use instead of trying the http://localhost
Create OS user accounts for each user (this is normal for my environment anyway)
repoadm is my svn repo administrator account
Created OS group account called svnusers
Add all accounts that will access the svn repo to svnusers group
Add apache account to the svnusers group
As root, install the mod_dav and subversion
yum install mod_dav_svn subversion
Update the subversion.conf file as you described
As root, create and modify the svn authorized user file
htpasswd -cm /etc/svn-auth-users repoadm (-cm is only used this one time)
htpasswd -m /etc/svn-auth-users testuser (-m to modify the svn-auth-users file)
Create the repo directory structure
mkdir /var/www/svn
chown -R repoadm.svnusers /var/www/svn
As repoadm, create SVN repository
cd /var/www/svn
svnadmin create repo
chown -R repoadm.svnusers repo
Run secure linux commands against the repo
chcon -R -t httpd_sys_content_t /var/www/svn/repo
chcon -R -t httpd_sys_rw_content_t /var/www/svn/repo
As root
Modify the repo permissions and restart apache service
cd /var/www/svn
chmod -R g+w repo
service httpd restart
Thanks again Will, excellent work! :)
If you want to, then you can post this guide to If !1 0 Forums and I can add link to it from this guide as an alternative installation method.
Hey JR,
Just wanted to let you know that I created my own post as you suggested. Here’s the site: http://forums.if-not-true-then-false.com/index.php/topic,70.0.html
Great tutorial, simple and nice ! Thanks!
i am not able to open multiple svn repository configured with ldap active directory authentication one repos is working file but another have same configuration but i am not able to browse others only one repos is going fine.
will anyone is help me out.