Subversion (svn) integration with Apache? - apache

I am running a website on my server with Apache, and I have also setup SVN with Apache.
The problem arises when I make changes in httpd.conf to setup SVN and restart Apache. It starts to serve files as SVN, but it stops my website. Then every user can see my source code.
I want to make my server as development server and production server. How can I run Apache for SVN and host my website?

First install dav svn:
apt-get install libapache2-svn
root#example:/var# mkdir svn
root#example:/var# cd svn
root#example:/var/svn# svnadmin create repo
a2enmod dav_svn
Change permissions for Apache:
chown -R root.www-data /var/svn
chmod -R g+rw /var/svn
Add the repository to a virtual host
<Location /svn/myrepo>
DAV svn
SVNPath /var/svn/repo
AuthType Basic
AuthName "My Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
</Location>
htpasswd2 /etc/apache2/dav_svn.passw user

Related

Apache 2.4 mod_dav_svn configuration file

I am trying to Setup Server dictated configurations on my Subversion repository which is served by an Apache 2.4 server.
Based on the information I found one has to alter the SVN configuration file on the server but which one is used by the mod_dav_svn module of the Apache Server?
I already tried different ones (Admin, Public) but none worked.
Does anybody know which configuration file is used by this module?
Thanks,
Thomas
As I know the SVN config file is the user and not to the server. The only things you have to do is give apache user write permission on svn repo and config the apache.
Here is a example of apache config file, repo available at http://mysserver/SVN_REPO1
LoadModule dav_svn_module modules/mod_dav_svn.so
<IfModule mod_dav_svn.c>
Alias /SVN_REPO "/PATH_TO/SVN_REPO"
<Location /SVN_REPO1>
DAV svn
SVNPath "/PATH_TO/SVN_REPO"
SVNPathAuthz Off # More faster but don't check permission permission in all parenth path ( - security)
AuthzSVNAccessFile "/path_to_/authz"
require valid-user
Satisfy Any
Options MultiViews
Require all granted
</Location>

Access to /svn is forbidden

I set up SVN on Ubuntu using the tutorial How to set up a Subversion (SVN) server on GNU/Linux - Ubuntu, but when I try access the repository from other machine using CMD it says Access to /SVN is forbidden.
I changed the permission of the folder and tried other methods to resolve the issue like configuration of the Apache server, but that did not solve my problem.
How can I fix this problem?
Apache can read and write the repository, but its user (www-data) needs to be given ownership of it:
sudo chown -R www-data:www-data /var/svn/repositories/your_repo
To be able to authenticate users who access the repository a password file is needed:
sudo htpasswd -c /etc/subversion/passwd your_user_name
Enter a password for the user your_user_name. For additional users repeat the command without the -c option to make sure the existing file is appended to rather than replaced.
Then edit the Apache configuration file:
sudo gedit /etc/apache2/apache2.conf
Add the following to the end of the file:
#svn users
<Location /svn>
DAV svn
SVNParentPath /var/svn/repositories/
SVNListParentPath On
AuthType Basic
AuthName "Test"
AuthUserFile /etc/subversion/passwd
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
</Location>
Save the configuration file and restart Apache:
sudo /etc/init.d/apache2 restart
The test repository can now be accessed via:
http://localhost/svn/your_repo
Make sure you have your virtual host set up like this for Apache:
<VirtualHost *:80>
DocumentRoot /home/svn/html
ServerName svn.domainname
ErrorLog logs/svn.domain.com-error_log
CustomLog logs/svn.domain.com-access_log common
<Directory "/home/svn/html">
Order allow,deny
Allow from all
AllowOverride all
</Directory>
<Location /repos>
DAV svn
SVNParentPath /home/svn/repos
Require valid-user
SVNListParentPath on
AuthType Basic
AuthName "Your Super SVN"
AuthUserFile /home/svn/svn-passwords-file-to-be-used-only-when-AuthType-is-used
AuthzSVNAccessFile /home/svn/svn-repos-acl-file-but-optional
</Location>
</VirtualHost>
And make sure Apache can access the repos folder mentioned in SVNParentPath. This issue is mostly because of permissions. Try chmod -R 0777 repos-folder and try again.
This might help someone if they are troubleshooting a setup that had previously been working. Today the new guy at our company inadvertently introduced a typo in the file used by AuthzSVNAccessFile and that caused all of us to experience the dreaded E175013

SVN Repo gives 404 not Found

I have installed svn, version 1.6.17 (r1128011) on to Ubuntu 12-04
I made my repo here:
$ sudo mkdir /home/2nd-disk/svn
Set up my /etc/apache2/mods-enabled/dav_svn.conf
<Location /svn>
DAV svn
SVNParentPath /home/2nd-disk/svn
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
</Location>
Created an account:
sudo htpasswd -cm /etc/apache2/dav_svn.passwd myusername
Created a test repo
$ cd /home/2nd-disk/svn
$ sudo svnadmin create test_repo
Ran a chown:
$ sudo chown -R www-data:www-data /home/2nd-disk/svn
Insured a2enmod & dav_svn are loaded and restarted apache2:
$ sudo a2enmod dav_svn && sudo service apache2 restart
Considering dependency dav for dav_svn:
Module dav already enabled
Module dav_svn already enabled
* Restarting web server apache2
... waiting
I then try to browse to http://mydomain.com/svn/test_repo and I get a 404 not found.
The same happens with http://mydomain.com/svn/test_repo
Going to http://mydomain.com shows the default 'It Works!' apache page.
Do I need to change virtual hosts here? I followed this tutorial below to the T and so assumed not:
http://rbgeek.wordpress.com/2012/05/01/svn-server-on-ubuntu-12-04-lts-with-web-access/
I have this problem sovled just now .
prep. I set up my /etc/apache2/http.conf
LoadModule dav_module /usr/lib/apache2/mod_dav.so
LoadModule dav_svn_module /usr/lib/apache2/mod_dav_svn.so
LoadModule authz_svn_module /usr/lib/apache2/mod_authz_svn.so
It works for a period without 404 while I then try to browse to http://mydomain.com/svn/test_repo .But after I reboot my Linux, I get a 404 not found.
Try to add the lines to /etc/apache2/conf.d.subversion.conf
LoadModule dav_module /usr/lib/apache2/mod_dav.so
LoadModule dav_svn_module /usr/lib/apache2/mod_dav_svn.so
LoadModule authz_svn_module /usr/lib/apache2/mod_authz_svn.so
My SVN works well now! I wish these recommendations can help you.
add the reference to your vhost instead of dav_svn.conf:
<Location /svn>
DAV svn
SVNPath /var/local/svn
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /etc/apache2/dav_svn.passwd
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
</Location>
good tutorial is here: http://wiki.ubuntuusers.de/Subversion
don't forget to restart apache to apply changes:
sudo /etc/init.d/apache2 restart

SVN Server on CentOS 5.8 [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am tring to setup a subversion server on CentOS 5.8 (CentOS release 5.8 (Final)). I have only a little experience with CentOS. I only have worked with SuSE and Ubuntu so far.
The problem I have is, when I try to access my SVN repository via http://domain.tld/svn I get "Forbidden, You don't have permission to access /svn/ on this server.".
These are the steps for my setup:
yum install mod_dav_svn subversion
Content of /etc/httpd/conf.d/subversion.conf
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
</Location>
Create related paths
mkdir -p /var/www/svn && cd /var/www/svn
svnadmin create repos
chown -R apache:apache repos
service httpd restart
I cant figure out, whats wrong...
Other sources on CentOS 5.7 suggested this as an additional step:
chcon -R -t httpd_sys_content_t /var/www/svn/repos
chcon -R -t httpd_sys_rw_content_t /var/www/svn/repos
When I execute this, I get chcon: can't apply partial context to unlabeled file /var/www/svn/repos
So I looked around and found a User that said, I should use
chcon -h system_u:object_r:httpd_sys_content_t /var/www/svn/repos
chcon -R -h apache:object_r:httpd_sys_content_t /var/www/svn/repos/*
instead of
chcon -R -t httpd_sys_content_t /var/www/svn/repos
so I added also 2 lines for httpd_sys_rw_content_t:
chcon -h system_u:object_r:httpd_sys_content_t /var/www/svn/repos
chcon -R -h apache:object_r:httpd_sys_content_t /var/www/svn/repos/*
chcon -h system_u:object_r:httpd_sys_rw_content_t /var/www/svn/repos
chcon -R -h apache:object_r:httpd_sys_rw_content_t /var/www/svn/repos/*
Problem still remains...
service httpd restart
Problem still remains...
EDIT
I also have added authentication rules to the subversion.conf:
<LimitExcept GET PROPFIND OPTIONS REPORT>
AuthzSVNAccessFile /etc/subversion/svn-access
# Require SSL connection for password protection.
# SSLRequireSSL
AuthType Basic
AuthName "Authorization Realm"
AuthUserFile /etc/subversion/svn-passwd
Require valid-user
</LimitExcept>
These configuration rules are copied from a previous running installation under SuSE. The files have valid content. Problem still remains...
EDIT
I have removed the <LimitExcept GET PROPFIND OPTIONS REPORT> and </LimitExcept> lines, so that the authentication always applies. When I now access svn from the browser, I get an HTTP-Basic-Auth windows. After I have entered existing and correct credentials, the "Forbidden" message comes up again. Problem still remains...
EDIT
I finally got it running. I have set the repository path via SVNPath /var/www/svn/repos instead of SVNParentPath /var/www/svn. Now everything is fine...
You have to instruct Apache to perform authentication (so that Subversion will have a user to use with the rules
In you location add something like this to you <Location> directive:
SSLRequireSSL
AuthType Basic
AuthPAM_Enabled on
AuthName "Subversion"
AuthUserFile /etc/shadow
Require valid-user
This example uses PAM but there are many other possibilities: refer to the Apache httpd manual
Try this:
<Location /svn>
DAV svn
SVNPath /var/www/svn
</Location>

Configuring SVN server on Apache on Ubuntu 12.04

I'm trying to access an existing Subversion server over HTTP. My dav_svn.conf file looks like:
<Location /svn>
DAV svn
SVNParentPath /home/svn/repos
SVNListParentPath on
AuthType Basic
AuthName "Restricted Access"
AuthUserFile /home/svn/passwdfile
Require valid-user
AuthzSVNAccessFile /home/svn/accessfile
</Location>
But when I'm trying to access "some-site/svn", I'm getting the following error:
The requested URL /svn/ was not found on this server.
The Apache error log shows "file does not exist: /var/www/svn"
How do I resolve this?
Run this:
a2enmod dav_svn
service apache2 restart
as super user (root), e.g. sudo a2enmod dav_svn && sudo service apache2 restart.
This assumes that you are using the proper method (Debian+Ubuntu) of editing the two files: /etc/apache2/mods-available/dav_svn.{conf,load}, not some homebrew method.