# subversion with apache2 how?

## Adamal

I am trying very hard to get subversion working with apache2 but I have no idea how to configure subversion.   I've configured apache with DAV but I am getting a 403 forbidden when trying to browse to the folder.

```
Forbidden

You don't have permission to access /svn/ on this server.

Apache/2.0.49 (Gentoo/Linux) DAV/2 mod_ssl/2.0.49 OpenSSL/0.9.7d PHP/4.3.6 Server at [ServerName] Port 80 
```

how do you setup subversion?

----------

## Adamal

Ok I've got it to work.  I now can display the root directory, now how to I create folders and such.  I've tried svn mkdir /var/...path to svn/newdirectory and I get the following error

```

root@ruggles svn # svn mkdir /var/www/localhost/htdocs/svn/project2

svn: '/var/www/localhost/htdocs/svn' is not a working copy

```

if I try it through the web this is what I get

```

root@ruggles svn # svn mkdir http://192.168.1.50/svn/project3

Log message unchanged or not specified

a)bort, c)ontinue, e)dit

c

svn: OPTIONS request failed on '/svn'

svn: OPTIONS of '/svn': 301 Moved Permanently (http://192.168.1.50)

```

Any help please!!!

----------

## Jesore

You first have to setup the repository.

```
svn create /path/to/repos
```

This generates the database. The whole directory has to be owned by the user that also runs apache. I'm a little afraid you got some parts about how subversion works wrong, it is not directory/file driven like CVS, all files are stored in a database (berkdb), so you can't create directories like you tried. After the initial DB creation, then your commands should work.

Jesore

----------

## Adamal

 *Jesore wrote:*   

> You first have to setup the repository.
> 
> ```
> svn create /path/to/repos
> ```
> ...

 

Originally you are correct I created the svn as a regular folder.  Here is what i have currently

in commonapache2.conf

```

<Location /svn/>

  DAV svn

  SVNPath /var/www/localhost/htdocs/svn/

  AuthType Basic

  AuthName "Subversion repository"

  AuthUserFile /var/lib/dav/svnusers

  Require valid-user

</Location>

<IfModule mod_dav_fs.c>

  # Location of the WebDAV lock database.

  DavLockDB /var/lib/dav/lockdb

</IfModule>

```

I have created the svn directory with the following commands

```

root@ruggles htdocs # svnadmin create /var/www/localhost/htdocs/svn

root@ruggles htdocs # chown -R apache:apache /var/www/localhost/htdocs/svn

```

now when I try to run the command 

```

root@ruggles htdocs # svn mkdir /var/www/localhost/htdocs/svn/project
```

I get the following error

```

svn: '/var/www/localhost/htdocs/svn' is not a working copy

```

----------

## lorenb

Looks like you are using the wrong syntax for svn mkdir

Try this:

```

svn mkdir -m "Making a new dir." http://localhost/svn/project

```

----------

## Adamal

 *lorenb wrote:*   

> Looks like you are using the wrong syntax for svn mkdir
> 
> Try this:
> 
> ```
> ...

 

Here is what I got from this one:

```
root@ruggles svn # svn mkdir -m "Making a new dir." http://localhost/svn/project1

svn: OPTIONS request failed on '/svn'

svn: OPTIONS of '/svn': 301 Moved Permanently (http://localhost)

```

----------

## lorenb

Oops, forgot to include the repository name, try this:

```

svn mkdir -m "Making a new dir." http://localhost/svn/svn/project1

```

----------

## lorenb

One other thing you could try, importing:

```

mkdir -p tmpdir/project1

cd tmpdir

svn import . http://localhost/svn/svn/ -m 'Initial layout' 

```

Then if it works, you can check it out:

```

rm -rf tmpdir

svn checkout http://localhost/svn/svn/project1

```

----------

## Adamal

 *lorenb wrote:*   

> One other thing you could try, importing:
> 
> ```
> 
> mkdir -p tmpdir/project1
> ...

 

No go here is what I got

```
root@ruggles tmpdir # svn import . http://localhost/svn/svn/ -m 'Initial layout'

Authentication realm: <http://localhost:80> Subversion repository

Password for 'root':

Authentication realm: <http://localhost:80> Subversion repository

Username: adam

Password for 'adam':

svn: PROPFIND request failed on '/svn'

svn: PROPFIND of '/svn': 301 Moved Permanently (http://localhost)

```

BTW thanks for your help so far.

----------

## lorenb

Hmm.  Strange.  How about changing your apache config and remove the trailing slash.  

```

SVNPath /var/www/localhost/htdocs/svn

```

Re-start apache and then try the import again.  If it's not that, I'm not really sure what the problem is.  

Check out Version Control with Subversion

----------

## Adamal

No go.

I am at a loss.  Is there any configuration help for Gentoo.  Since gentoo has a different Apache format the normal docs just don't work.

----------

## lorenb

Saw this in the Subversion FAQ:

 *Quote:*   

> 
> 
> I can see my repository in a web browser, but 'svn checkout' gives me an error about "301 Moved Permanently". What's wrong?
> 
> It means your httpd.conf is misconfigured. Usually this error happens when you've defined the Subversion virtual "location" to exist within two different scopes at the same time.
> ...

 

----------

## Adamal

 *lorenb wrote:*   

> Saw this in the Subversion FAQ:
> 
>  *Quote:*   
> 
> I can see my repository in a web browser, but 'svn checkout' gives me an error about "301 Moved Permanently". What's wrong?
> ...

 

That was it.  I moved my svn directy out of the /var/www/localhost/htdocs and it work great.  Thanks for your help, you have no idea how much I appreciate it.

----------

## gossi

I emerged subversion-1.0.4-r1  and configured it as it was written in the end of the ebuild:

 created the repository with 

```
ebuild /usr/portage/dev-util/subversion/subversion-1.0.4.ebuild config 
```

 created my userfile with 

```
htpasswd2 -m -c /var/svn/conf/svnusers USERNAME 
```

 added the values 

```
APACHE2_OPTS="-D SSL -D PHP4 -D DAV -D SVN" 
```

to /etc/conf.d/apache2

Seems I don't have to edit the apache2.conf because the ebuild created a file /etc/apache2/conf/modules.d/47_mod_dav_svn.conf 

```

<IfDefine SVN>

        <IfModule !mod_dav_svn.c>

                LoadModule dav_svn_module       extramodules/mod_dav_svn.so

        </IfModule>

        <Location /svn/repos>

                DAV svn

                SVNPath /var/svn/repos

                AuthType Basic

                AuthName "Subversion repository"

                AuthUserFile /var/svn/conf/svnusers

                Require valid-user

        </Location>

</IfDefine>

```

I checked the rights in the directory /var/svn - they are all set to apache.

Everything I do now results in the same problems:

```

sk@homebase var $ svn mkdir -m "Making a new dir." http://localhost/svn/asdf/project1

Authentication realm: <http://localhost:80> Subversion repository

Password for 'sk': 

svn: OPTIONS request failed on '/svn/asdf'

svn: OPTIONS of '/svn/asdf': 500 Internal Server Error (http://localhost)

```

I checked the apache logs:

```

==> /var/log/apache2/access_log <==

127.0.0.1 - - [17/Jun/2004:09:02:13 +0200] "OPTIONS /svn/asdf HTTP/1.1" 401 552 "-" "SVN/1.0.4 (r9844) neon/0.24.6"

127.0.0.1 - sk [17/Jun/2004:09:02:17 +0200] "OPTIONS /svn/asdf HTTP/1.1" 500 234 "-" "SVN/1.0.4 (r9844) neon/0.24.6"

==> /var/log/apache2/error_log <==

[Thu Jun 17 09:02:17 2004] [error] [client 127.0.0.1] (20014)Error string not specified yet: Can't open file '/var/svn/repos/asdf/format': No such file or directory

[Thu Jun 17 09:02:17 2004] [error] [client 127.0.0.1] Could not fetch resource information.  [500, #0]

[Thu Jun 17 09:02:17 2004] [error] [client 127.0.0.1] Could not open the requested SVN filesystem  [500, #2]

[Thu Jun 17 09:02:17 2004] [error] [client 127.0.0.1] (84)Invalid or incomplete multibyte or wide character: Could not open the requested SVN filesystem  [500, #2]

```

There is a /var/svn/repos/format file but no /var/svn/repos/asdf/format.

----------

## Adamal

make sure you add the following to the apache2.conf

```
LoadModule dav_module                    modules/mod_dav.so

LoadModule dav_svn_module                /usr/lib/apache2-extramodules/mod_dav_svn.so

```

also remember to run svnadmin create <reponame>

----------

## gossi

Adding these lines is not nessecary with the ebuild: It installs 2 files in the apache2/conf/modules.d which are included in the apache2.conf. These files contain the lines you wrote.

Running the ebuild with the config command calls svnadmin and creates the repository in /var/svn/repos and even changes the access rights for the files to apache....

Using a webbrowser with http://homebase/svn/repos results in "Could not open the requested SVN filesystem" - it seems that the modules are loaded in apache...

----------

## Adamal

 *Quote:*   

> Using a webbrowser with http://homebase/svn/repos results in "Could not open the requested SVN filesystem" - it seems that the modules are loaded in apache...

 

If thats the error you got then you never ran 

```
svnadmin create
```

 with the name of the repository.  You must have just tried to create the directory repos using mkdir.

----------

## gossi

Hm. It's working now... thanks   :Smile: 

----------

## Adamal

 *gossi wrote:*   

> Hm. It's working now... thanks  

 

Glad I could help.  Took me a while to figure out all the ins and outs too.

----------

## o5gmmob8

Hi guys,

This may sound like a dumb question, but can I view, edit, and create files/directories across the web with a webdav and svn enabled apache, and will be simple as going to https://server/path_to_repository?

Walter

----------

