[HOW TO] Setup a SVN server and use Zend Studio with it

Post Pic

What is our goal
Subversion is the best open source version control system available so far. Our goal is to have a working SVN server on a Linux CentOS 5.3 alongside using it from a Zend Studio for Eclipse. The tutorial will guide you through the steps of installing SVN on your server via the root [...]

What is our goal

Subversion is the best open source version control system available so far. Our goal is to have a working SVN server on a Linux CentOS 5.3 alongside using it from a Zend Studio for Eclipse. The tutorial will guide you through the steps of installing SVN on your server via the root account, configure it to be public available or under password protection, configure a client to use the server but also avoid security holes like this one.

Installation

[root@server1 ~]# yum install mod_dav_svn subversion

The first thing to do is to install the svn packages. If you don’t have Apache installed already, it’ll go ahead and install it as well as a dependecy.

When you install from yum, there’s a longer list than the two packages above that will automatically resolve themselves. Some other things will be installed automatically. Depending on your packages, your mileage may vary.

Configurating the services

Apache

[root@server1 ~] nano /etc/httpd/conf/httpd.conf
[root@server1 ~] service httpd start
[root@server1 ~] chkconfig httpd on

You will need to ensure Apache is set up correctly first. I’m assuming this is a clean installation, so be careful if you already have Apache installed when changing stuff aroud. I’m also going to explain setting this up with basic password protection. You can easily let this out, however, if you want to allow access to the repos to the public.

In /etc/httpd/conf/httpd.conf make sure to at least change the ServerName directive to point out to your server (not the SVN server)

SVN Apache Configuration

[root@server1 ~] cd /etc/httpd/conf.d/
[root@server1 ~] nano subversion.conf

LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

# Add the following lines of code to allow a basic authentication
# and point Apache to where the actual repository resides.
<Location /repos>
        DAV svn
        SVNPath /var/www/svn/repos
        AuthType Basic
        AuthName "Subversion repos"
        AuthUserFile /etc/svn-auth-conf
        Require valid-user
</Location>

The location is what Apache will send to the URL bar. For example: http://example.com/repos will send to the SVN path that you have specified. The examples are just that, so feel free to put things where you want. Make sure you save the file when you are finished editing.

Next we have to actually create the password file that you specified in the previous step. Initially you’ll use the -cm arguments. This creates the file and also encrypts the password with MD5. If you need to add users make sure you simply use the -m flag, and not the -c after the initial creation.

[root@server1 ~] htpasswd -cm /etc/svn-auth-conf yourusername
New password:
Re-type new password:
Adding password for user yourusername
[root@server1 ~] htpasswd -m /etc/svn-auth-conf anotherusername
New password:
Re-type new password:
Adding password for user anotherusername

Setup the repository

[root@server1 ~] cd /var/www/
[root@server1 ~] mkdir svn
[root@server1 ~] cd svn
[root@server1 ~] svnadmin create repos
[root@server1 ~] chown -R apache.apache repos
[root@server1 ~] service httpd restart

Last step here is to create the actual SVN directories.

You can now access your repository from a web browser: http://example.com/repos. You should get a popup box asking for your username and password. Type in your credentials and you should be displayed with a Revision 0:/ page. That’s it for setting up a repo.

Importing your first project from Zend Studio



The first thing you need to do is share your project.



Select SVN from the list.



Select that you wish to create a new repository location



Enter your credentials and URL here.



Click next.



Click finish.

Security issues

To make sure nobody can view your .svn files (which basically contain EVERYTHING from your project), make sure you edit http.conf and add the following piece of code somewhere where it will be runned all the time

<Directory ~ ".*\.svn">
	    Order allow,deny
	    Deny from all
	    Satisfy All
</Directory>

Conclusion

Thats it! Now, if you make changes to your files in your project, just press CTRL + ALT + C (or Team => Commit) .
When you want to retrieve the latest sources from SVN, press CTRL + ALT + U (or Team => Update) and wait for the update.

Enjoy you’r new SVN server!

  • Erkan BALABAN
    you can use virtualsvn server for windows. it is free and easy to use and install on windows.
  • Actually, I remember that I've gone through some (random google searches) but none actually got me to a working version on windows. So, I am sorry but i don't have an answer.
  • Murad Jamal
    is there a tutorial like this but on Windows OS ?
blog comments powered by Disqus

Popular tags

Partner Blogs

Latest tweets


Get Adobe Flash playerPlugin by wpburn.com wordpress themes
Web Analytics