|
This is work in progress. Come back later today to read complete version. (almost finished)
This tutorial show step by step configuration of a Subversion Server on FreeBSD. It is not a SVN for FreeBSD source files but a version server for your projects. What's the use? Well, if your project is large and you want to manage versions of your source files, bugs and features and you want a track of how your workers did their jobs every day, Subversion might be the answer.
Step 1. Install FreeBSD ------------------------------- Get the last IMAGE of FreeBSD from ftp.freebsd.org. You can use USB version which is easely to install. Install it, then cvsup to the stable version. You can do that using this tutorial: http://www.freebsdonline.com/content/view/460/476/
Step 2. Build Subversion from ports ------------------------------------------------- Execute the following commands:
cd /usr/ports/devel/subversion make install clean
Step 3. Install PHP and Apache (for use with websvn) ------------------------------------------------------------------------ cd /usr/ports/www/apache22 make install clean
Add the following lines to /usr/local/etc/apache22/httpd.conf (to load index.php and support PHP) (If you already have dir_module section, just add ther index.php) <IfModule dir_module> DirectoryIndex index.html index.php </IfModule>
AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
Then, compile php. cd /usr/ports/lang/php5 make install clean
Don't forget check APACHE MODULE before compiling, then compile and install, so your Apache would be able to run PHP scripts.
You must configure Apache to run PHP.
Step 4. Install and configure WebSVN -------------------------------------------------- cd /usr/ports/devel/websvn make install clean
Then copy /usr/local/www/websvn/include/distconfig.php to /usr/local/www/websvn/include/config.php
Add the following lines:
$config->setSVNCommandPath('/usr/local/bin'); $config->addRepository('The SVN SERVER', 'file:///home/svn/repositories/svntest/');
Then create /usr/local/etc/apache22/Includes/aliases.conf file with the following content:
Alias /websvn "/usr/local/www/websvn" <Directory "/usr/local/www/websvn"> Options Indexes FollowSymLinks RewriteEngine on AllowOverride All Order allow,deny Allow from all </Directory>
Step 5. Configure Subversion ---------------------------------------- We will first create a subversion repository where our revisions will be placed :
install -v -m 0755 -d /home/svn install -v -m 0755 -d /home/svn/repositories svnadmin create --fs-type fsfs /home/svn/repositories/svntest/ cd /home/svn/repositories/svntest/ mkdir branches tags trunk
Step 7. Start the svnserve server ---------------------------------------------- svnserve -d -r /home/svn/repositories/svntest
Step 8. Test commiting to the SVN server from local ------------------------------------------------------------------------ If you try to commit you might get an error regarding writting rights. In that case create a group for all your users and give chown to that group to your svn repository.
To test a svn server from localhost (from the same machine) do a checkout of your svn server, then modify a file and do a commit. .... put here example commands ....
To access a svn repository from localhost use file:/// in front of your svn path. ... put here example ....
Step 9. Configure svnserve ------------------------------------- Create /usr/local/etc/svnserve.conf file with the following content:
[general] password-db = userfile realm = example realm anon-access = read auth-access = write
[users] user = 12345
Here user is the username and 12345 is the password. With this settings authenticated users will have read/write privileges and anonymous users only read access.
Next, add the following lines in /etc/rc.conf:
apache22_enable="YES"
svnserve_enable="YES" svnserve_flags="-d --listen-port=3690 --listen-host 10.0.0.19" svnserve_data="/home/svn/repositories" svnserve_user="svn" svnserve_group="svn" Where 10.0.0.19 is your SVN server IP, and /home/svn/repositories is the directory for your SVN repository.
Then start the service with: /usr/local/etc/rc.d/svnserve start
Step 10. Using SVN remotely using SSH from other machine ---------------------------------------------------------------------------------- You can connect to a SVN server from your command line (in Linux / BSD / OSX / Unix) or you can use TortoiseSVN and use from Windows. For using TortoiseSVN to connect to the SVN server see step 12.
From command line you must first do a initial checkout with:
svn checkout svn+ssh://
This email address is being protected from spam bots, you need Javascript enabled to view it
/home/svn/repository/project
After issuing a svn checkout command note that the local copy of SVN is in a folder, you must after checkout to change directory to that folder.
And then commit to ssh with:
svn commit
Step 11. Configure SSHd with keys ----------------------------------------------- To be able to login on SVN server without password you must configure SSH server to accept authentication without username/password, based on keys.
A tutorial about configuring SSHd server to accept authentication on pair of private/public keys and not on username/password can be found here: http://www.freebsdonline.com/content/view/458/474/ - SSH Public key based authentication
Step 12. Using SVN from a Windows station with TortoiseSVN ------------------------------------------------------------------------------------ ... to add ...
Remove path to putty from TortoiseSVN config, otherwise you will not be able to connect. It will still use putty. When you will connect to SVN server from TortoiseSVN use instead of hostname of SVN server a setting name you've saved in your putty for that server IP/Hostname to connect to.
To connect to a SVN server from TortoiseSVN first do a checkout:
svn+ssh://
This email address is being protected from spam bots, you need Javascript enabled to view it
/home/svn/repository/project
where: - 192.168.0.10 is your SVN server - user is your username on that server - /home/svn/repository/project - is your path to the project in the SVN server
Step 13. Using SVN from OSX --------------------------------------- To use SVN from OSX install SCPlugin, which is similar to TortoiseSVN, well, it's much simpler with base functionality but we hope in time will mature to be similar to TortoiseSVN.
After installing SCPlugin following documentation available in the downloadable .dmg you must configure your SSHd service from your SVN server to accept connection from your OSX station based on public keys and not on username/password.
Note: SCPlugin will not work without configuring SSHd service from your SVN server to accept public keys authentication.
Other tips -------------- Best advice is to create all your svn users to be members of group svn and then:
chown -R svn:svn /home/svn/ chmod -R 775 /home/svn/repositiories
To add a user to svn group in FreeBSD use:
pw usermod george -G svn (will add user george to svn group)
or: pw groupmod svn -M svn, john, george, johny (will modify group svn and add users svn, john, george, johny to it. All other users from group svn will be removed).
Useful Subversion Commands ------------------------------------------ List files/dirs from repository: svn list file:///home/srv/svn/repositories/svntest/ Sync your working copy with files from repository: svn update Commit your file to repository: svn commit -m "comment 1 for file" Add a file or directory to your local project: svn add main.cc Get files from SVN server: svn checkout file:///home/svn/repositories/svntest/ Update your working copy with version number 2: svn update -r 2 Show last change commited to main.cc file: svn diff --revision PREV:COMMITTED main.cc Import a project to a SVN server: svn import file:///home/svn/repositories/svntest/branch -m "initial import" Copy a branch to a new one: svn copy file:///home/svn/repositories/svntest/branch file:///home/svn/repositories/svntest/proj2 -m "copy to a new branch"
|