Fedora12 下配置 SVN 服务器
assume the following dummy IP addresses and port of the server for the rest of the article: (replace these with your own IP, and port values)
external IP: 55.444.444.55
internal lan IP: 192.168.1.200
svn port: 8080
Most of the operations here will require that you have access to the root account, as always.
I like to use the yum extender and an http gui to manipulate apache’s settings, so those need to be installed:
> yum -y install yumex
This installs a gui for yum, which can be found, after a successful install on the desktop at:
Applications > Yum Extender
Using the yum extender, we can see what has already been installed or not, on the linux machine. So, we should make sure that the Apache server is installed, and also install the Apache configuration tool (the http gui):
httpd
system-config-httpd
We also need to install the Apache server module for the subversion server:
mod_dav_svn
Next, to install SVN subversion we can go back to the command line, and install it using yum:
> yum install subversion
With these installations complete we can begin to create the necessary directories and modifying the various configuration files.
As root, create the following directory:
> mkdir -p /var/www/svn/repository
change to that directory,
> cd /var/www/svn/repository
and create a test repository,
> svnadmin create test_svn
Notice: use svnadmin command maybe get an error: SQLite编译为3.6.20,但是运行于3.6.17。然后会发现repository目录下面并没有生成任何东西。此时需要在Yum Extender里面找到两个sqlite开头的包,然后升级这两个包就可以了。
Actually, these SVN directories can be placed anywhere, as long as you keep track of the correct path for the modifications that will need to be added later to the configuration files.
Next, change directory, and set the ownership so that Apache can access the SVN directories.
> cd /var/www
> chown -R apache.apache svn
Next, we modify Apache’s settings.
Before modifying Apache’s settings it would be a good idea to make a backup of the configuration file, in case the Apache server won’t restart, we can always restore the configuration file and try again.
> cd /etc/httpd/conf.d
> cp system-config-httpd.conf system-config-httpd.conf.backup
Start the httpd configuration gui:
> /usr/bin/system-config-httpd &
In this window set the server name to:
192.168.1.200
Add to Available Addresses :
listen to all addresses
port: 8080
Then to save these settings, hit OK. These changes will modify the file:
/etc/httpd/conf.d/system-config-httpd.conf
Restart the Apache server. There are operating system line commands for restarting the http daemon, but a GUI is just as easy, and we can keep the GUI open since we will need to restart Apache a few more times.
/usr/bin/system-config-services &
Scroll down, select the daemon labeled httpd, and hit restart. Hopefully Apache restarts successfully, if not, then you may need to reload the original configuration file and try again.
Next, we will need to modify subversion’s configuration files.
To modify subversion’s configuration files we need to edit the following:
/etc/httpd/conf.d/subversion.conf
This file was created with the installation of subversion.
The first two lines of the file should contain:
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
… if not, then those modules need to be installed.
First create a backup of the configuration file:
> cp subversion.conf subversion.conf.backup
Modify the Location section of the file to the following:
n
Notice here how the directory for the repository we created earlier using the svnadmin command is not listed above. The above settings only point to the root location of the repository, or rather its parent path.
Save these settings, and restart the Apache server.
At this point we can test the SVN server from another PC on the private LAN. We can use our favorite web browser on a windows, linux, or mac PC, and enter the following URL:
http://192.168.1.200:8080/svn/test_svn/
We should get a response page that looks like the following:
Revision 0: /
————————————————————–
Powered by Subversion version 1.4.4 (r25188).
If you can see this, then the SVN server is running.
Next, we need to add some password protection.
Here we add some password protection to the new SVN server.
For this, lets assume a username of trill, and a password of towel42.
Make the password directory:
> mkdir /etc/httpd/passwd
To create the initial password file, and add a user called “trill”:
> htpasswd -c /etc/httpd/passwd/svnpasswords trill
When the program asks, enter the password:
towel42
Other command line options to htpasswd will allow you to add or delete more users.
For example, to add another user, called “asmith”:
> htpasswd /etc/httpd/passwd/svnpasswords asmith
When the program asks, enter the password:
neo22
This will append the user “asmith” to the passwords file, with the above password.
Edit the subversion configuration file to turn on the SVN authorization. We found that commenting out the <LimitExcept lines allowed the SVN password authorization to work. So the final subversion configuration file:
/etc/httpd/conf.d/subversion.conf
… can look like this:
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/repository
</Location>
<Location /svn>
DAV svn
SVNParentPath /var/www/svn/repository
# Limit write permission to list of valid users.
#<LimitExcept GET PROPFIND OPTIONS REPORT>
# Require SSL connection for password protection.
# SSLRequireSSL
AuthType Basic
AuthName “Authorization Realm”
AuthUserFile /etc/httpd/passwd/svnpasswords
Require valid-user
#</LimitExcept>
</Location>
After having made these changes, restart the Apache server as above. Now, if we go back to the PC with the web browser, we can test the password authentication. Restart the web browser and enter into the URL:
http://192.168.1.200:8080/svn/test_svn/
We should see a window pop up, prompting for a user’s name and a corresponding password.
Enter trill for the user name, and towel42 for the password. This should let us see the svn server’s response page as before.