Home > Linux/Unix, Open-Source > How-To Set Up SVN and Trac

How-To Set Up SVN and Trac


What are SVN and Trac?

SVN: is a free/open-source Version Control System. Subversion (SVN) manages files and directories over time. Files are placed into a central repository and every change every made to the files or directories are remembered.

Trac: is an enhanced wiki and issue tracking system for software development projects. It provides a Graphical front end to SVN where diffs in files can be obtained. It cannot update the SVN repository. It simply provides a Project Management interface, wiki, ticketing system, and SVN front end.

Installation

sudo apt-get install apache2
sudo apt-get install subversion
sudo apt-get install libapache2-svn
sudo apt-get install trac
sudo apt-get install libapache2-mod-fastcgi libapache2-mod-fcgid

Setting Up SVN and Trac

To make things simple and flexible in case you want to make some changes in the future, configurations will be set in individual files, i.e. as virtual sites, then they will be enabled/disabled when needed.

1-Creating SVN Repository:

cd /var
sudo mkdir MyProjects
cd MyProjects
sudo mkdir svn
cd svn
sudo svnadmin create SVN_Project_01
sudo chown -R www-data.www-data /var/MyProjects

2-Setting Up Trac

cd /var/MyProjects/
sudo mkdir trac
cd trac
sudo trac-admin Trac_Project_01 initenv
-->Project Name [My Project]>
-->Database connection string [sqlite:db/trac.db] (choose defaults)
-->Repository type [svn]>
-->Path to repository [/path/to/repos]> /var/MyProjects/svn/SVN_Project_01
sudo chown -R www-data.www-data /var/MyProjects
sudo trac-admin /var/MyProjects/trac/Trac_Project_01 permission add username MILESTONE_ADMIN REPORT_ADMIN ROADMAP_ADMIN TICKET_ADMIN TRAC_ADMIN

Setting Up Apache:

At this stage, we need to secure the web access to the repository so only authorized persons who can modify it, enable the SSL mode so connection is encrypted, and modify apache configurations accordingly:

Securing Web Access

  1. Enable the Authenticated Access by adding a username and password:

    sudo htpasswd -cb /etc/apache2/passwords username password
    
  2. Enabling the SSL Module:
    Refer to this blog: How-To Enable SSL on Apache2 Server

Trac Configurations

Note: You will need to download the Trac package and link to the cgi-bin/trac.cgi and cgi-bin/trac.fcgi in the configuration.
In my case, this the path to these files after extracting:

ls /usr/local/Trac-0.11.6/cgi-bin

Create the following files or you may create one of them:

Track through CGI
cd /etc/apache2/sites-available/
cat > svn.cgi
##SVN

<Location /MyProjects/svn/SVN_Project_01>
	DAV svn
	SVNPath /var/MyProjects/svn/SVN_Project_01

	AuthType Basic
	AuthName "Subversion Repository - SVN_Project_01"
	AuthUserFile /etc/apache2/.htpasswd

#	<LimitExcept GET PROPFIND OPTIONS REPORT>
		Require valid-user
		SSLRequireSSL
#	</LimitExcept>
</Location>


##Trac

ScriptAlias /MyProjects/trac /usr/local/Trac-0.11.6/cgi-bin/trac.cgi
<Location /MyProjects/trac>
	SetEnv TRAC_ENV_PARENT_DIR /var/MyProjects/trac
</Location>

<Location "/MyProjects/trac">
        SSLRequireSSL
        AuthType Basic
        AuthName "Trac Login for Projectname Website"
        AuthUserFile /etc/apache2/.htpasswd
        Require valid-user
</Location>


<Location "/MyProjects/trac/Trac_Project_01/login">
	SSLRequireSSL
	AuthType Basic
	AuthName "Trac Login for Projectname Website"
	AuthUserFile /etc/apache2/.htpasswd
	Require valid-user
</Location>
Track through FCGI
cd /etc/apache2/sites-available/
cat > svn.fcgi
##SVN

<Location /MyProjects/svn/SVN_Project_01>
	DAV svn
	SVNPath /var/MyProjects/svn/SVN_Project_01

	AuthType Basic
	AuthName "Subversion Repository - SVN_Project_01"
	AuthUserFile /etc/apache2/.htpasswd

#	<LimitExcept GET PROPFIND OPTIONS REPORT>
		Require valid-user
		SSLRequireSSL
#	</LimitExcept>
</Location>



##Trac

ScriptAlias /MyProjects/trac /usr/local/Trac-0.11.6/cgi-bin/trac.fcgi
##fastcgi
#FastCgiConfig -initial-env TRAC_ENV=/var/MyProjects/trac/Trac_Project_01
#FastCgiConfig -initial-env TRAC_ENV_PARENT_DIR=/var/MyProjects/trac

##fcgi
DefaultInitEnv TRAC_ENV_PARENT_DIR /var/MyProjects/trac

#<Location "/MyProjects/trac">
	##fastcgi
	#SetEnv TRAC_ENV_PARENT_DIR "/var/MyProjects/trac"
	#SetEnv TRAC_ENV "/var/MyProjects/trac/Trac_Project_01"
	#AddHandler fastcgi-script .fcgi

	#AuthType Basic
        #AuthName "Trac Repository - Trac_Project_01"
        #AuthUserFile /etc/apache2/.htpasswd
	#Require valid-user
	#SSLRequireSSL
#</Location>

<Location "/MyProjects/trac/Trac_Project_01/login">
	SSLRequireSSL
	AuthType Basic
	AuthName "Trac Login for Projectname Website"
	AuthUserFile /etc/apache2/.htpasswd
	Require valid-user
</Location>

Track through FastCGI
cd /etc/apache2/sites-available/
cat > svn.fastcgi
##SVN

<Location /MyProjects/svn/SVN_Project_01>
	DAV svn
	SVNPath /var/MyProjects/svn/SVN_Project_01

	AuthType Basic
	AuthName "Subversion Repository - SVN_Project_01"
	AuthUserFile /etc/apache2/.htpasswd

#	<LimitExcept GET PROPFIND OPTIONS REPORT>
		Require valid-user
		SSLRequireSSL
#	</LimitExcept>
</Location>



##Trac

ScriptAlias /MyProjects/trac /usr/local/Trac-0.11.6/cgi-bin/trac.fcgi
#FastCgiConfig -initial-env TRAC_ENV=/var/MyProjects/trac/Trac_Project_01
FastCgiConfig -initial-env TRAC_ENV_PARENT_DIR=/var/MyProjects/trac

#DefaultInitEnv TRAC_ENV /var/MyProjects/trac/Trac_Project_01

<Location "/MyProjects/trac">
	#SetEnv TRAC_ENV_PARENT_DIR "/var/MyProjects/trac"
	#SetEnv TRAC_ENV "/var/MyProjects/trac/Trac_Project_01"
	AddHandler fastcgi-script .fcgi

	#AuthType Basic
        #AuthName "Subversion Repository - SVN_Project_01"
        #AuthUserFile /etc/apache2/.htpasswd
	#Require valid-user
	#SSLRequireSSL
</Location>

<Location "/MyProjects/trac/Trac_Project_01/login">
	SSLRequireSSL
	AuthType Basic
	AuthName "Trac Login for Projectname Website"
	AuthUserFile /etc/apache2/.htpasswd
	Require valid-user
</Location>
Track through Python
cd /etc/apache2/sites-available/
cat > svn.python
##SVN

<Location /MyProjects/svn/SVN_Project_01>
	DAV svn
	SVNPath /var/MyProjects/svn/SVN_Project_01
	
	AuthType Basic
	AuthName "Subversion Repository - SVN_Project_01"
	AuthUserFile /etc/apache2/.htpasswd
	
#	<LimitExcept GET PROPFIND OPTIONS REPORT>
		Require valid-user
		SSLRequireSSL
#	</LimitExcept>
</Location>


##Trac

<Location /MyProjects/trac>
	SetHandler mod_python
	PythonInterpreter main_interpreter
	PythonHandler trac.web.modpython_frontend
	PythonOption TracEnvParentDir /var/MyProjects/trac
	PythonOption TracUriRoot /MyProjects/trac
	
	#SSLRequireSSL
	#AuthType Basic
	#AuthName "Trac Login for Projectname Website"
	#AuthUserFile /etc/apache2/.htpasswd
	#Require valid-user
</Location>

<Location "/MyProjects/trac/Trac_Project_01/login">
	SSLRequireSSL
	AuthType Basic
	AuthName "Trac Login for Projectname Website"
	AuthUserFile /etc/apache2/.htpasswd
	Require valid-user
</Location>

After that, you will need to enable ONLY one of them:

sudo a2ensite svn.cgi

Or

sudo a2ensite svn.fcgi

Or

sudo a2ensite svn.fastcgi

Or

sudo a2ensite svn.python

Finally, reload apache server:

sudo /etc/init.d/apache2 reload

Try to open these links:
https://localhost/MyProjects/svn/SVN_Project_01
https://localhost/MyProjects/trac

Next

You will need to configure your prefered IDE with the created SVN repository if it supports the synchronization with SVN repositories. In my case as a Java/Java EE Developer, I’ ll refer to the most known open IDEs which are: NetBeans and Eclipse. SVN is just a little part of them to control versioning!

Hence, this would help you get a well managed and organized development environment!

___________________

References

https://help.ubuntu.com/community/UbuntuTracHowto
http://wiki.kartbuilding.net/index.php/Trac_and_SVN
http://trac.edgewall.org/wiki/TracGuide

About these ads
  1. antonio
    February 11, 2010 at 4:27 am

    hello…

    the directory ” trac “doesnt exist and the comand dont work
    I have to install all the steps and only 2 , have a problem in this

    cd /etc/apache2/sites-available/
    cat > svn.fastcgi

    and
    you have a error.. in
    sudo trac-admin /var/MyProjects/trac/Trac_Project_01 permission add username MILESTONE_ADMIN REPORT_ADMIN ROADMAP_ADMIN TICKET_ADMIN TRAC_ADMIN

    this is my screen
    when reload apache
    Syntax error on line 21 of /etc/apache2/sites-enabled/svn.fastcgi:
    Invalid command ‘FastCgiConfig’, perhaps misspelled or defined by a module not included in the server configuration
    …fail!

    I appreciate your help…
    Ubuntu 9.10…

    Bye…

    • Husain Al-Khamis
      February 12, 2010 at 5:22 am

      @Antonio
      There have been some missing important parts in the post. Post has been updated. You will need to do the following:
      1) sudo apt-get install libapache2-mod-fastcgi libapache2-mod-fcgid
      2) Repeat steps 1 and 2 under “Setting Up SVN and Trac” part
      3) Regarding

      sudo trac-admin /var/MyProjects/trac/Trac_Project_01 permission add username MILESTONE_ADMIN REPORT_ADMIN ROADMAP_ADMIN TICKET_ADMIN TRAC_ADMIN

      change the “username” to one you wanna use. BTW, this step is not important and you can skip it or you can do it through the Trac interface when it is up. So, forget this step for now!

      Waiting your reply!
      Husain

  2. Tobi
    April 20, 2010 at 11:43 am

    Hi,

    thank you for that tutorial!
    As I see you have commented out the tags for SVN access, have you also tried to limit write access to svn to ssl-only connections and readaccess to normal http-connection?
    In my case this did not work an if I use SSLRequireSSL within . All Access to the SVN required SSL than.
    Do you have another idea how to confire that anoymous users have ro-access to the svn via http and https and authenticated users have rw-access only via https?

    Greetings!

    • Husain Al-Khamis
      April 20, 2010 at 11:50 pm

      You are welcome, Tobi!

      Well, as you notice, I installed “Trac” through which I can view the SVN repositories, and of course anyone can do so either using HTTP or HTTPS..

      What you are asking for is really interesting! Honestly, I don’t have the answer and I really look forward to it now. I’m sure there is a way of achieving this and eagerly would like to help. However, I’m in a position that won’t allow me to find out how to do this now.

      As part of my curiosity, I quickly tried to google some websites that could help in this matter, and I find this link might be helpful:
      http://wiki.archlinux.org/index.php/Subversion_Setup

      So, Good luck dude!

      • Tobi
        April 23, 2010 at 3:22 pm

        Thank you for your help!
        I thought about it a bit and think possible solutions could be doing it with two virtual hosts and limit the Acces to nen non-ssl one with

        Order Deny,Allow
        Deny from all

        and the ssl one without it.

        Other solution could be
        doing something like this in the
        RewriteCond %{SERVER_PORT} !443
        RewriteRule ^(.*)?$ https://%{SERVER_NAME}$1 [L,R]

        But with
        RewriteCond %{REQUEST_METHOD}

        I will try and tell about it.

        Greetings!

  3. Husain Al-Khamis
    May 17, 2010 at 9:19 pm

    Hey Tobi,

    Thanks a lot for for sharing your solution, and I apologize for taking such a long time to reply. I had to arrange for a travel for a graduate study.

    You know the study will take my time now but I’ll try to be committed to my blog!
    Once I mimic my home server environment, I’ll try your ideas.
    Thanks again for the comment!

    Take care and good luck.
    Regards..

  4. Kranthi Banoth
    September 25, 2012 at 4:56 am

    Hi Hussain,

    Trac Configurations

    Note: You will need to download the Trac package and link to the cgi-bin/trac.cgi and cgi-bin/trac.fcgi in the configuration.
    =======================================================================

    Thank you for the great document.

    Could you please let me know the steps to download Trac pakage and how to link to the cgi-bin/trac.cgi and trac.fcgi?

    This might be a silly question for you, but I am new to both Linux OS and also Trac and SVN. Please respond ASAP, as I am in a workstop situation.

    Thanks,
    Kranthi Banoth

    • Kranthi Banoth
      September 25, 2012 at 5:29 am

      Thanks Hussain, I have extracted the .cgi and .fcgi files from the Trac project.

      I am getting error after I enabling svn.fastcgi and restarting the apache service as below:

      root@CITSVNTRAC01:/etc/apache2/sites-available# /etc/init.d/apache2 restart
      Syntax error on line 4 of /etc/apache2/sites-enabled/svn.fastcgi:
      Invalid command ‘DAV’, perhaps misspelled or defined by a module not included in the server configuration
      Action ‘configtest’ failed.
      The Apache error log may have more information.
      …fail!

      Could you please help me out in this? I am very much impressed by your document. It includes all the easy understandable steps. Thanks again for a great document.

      Regards….
      Kranthi Banoth

      • Kranthi Banoth
        September 25, 2012 at 7:29 am

        I was able to restart the apache after reinstalling “libapache2-svn” pakage. Now, when I access the link https://localhost/MyProjects/svn/SVN_Project_01, it is asking me username and password. When I provide secure web admin username and password, it says as below:

        Internal Server Error.

        Please help me out in this.

        Regards,
        Kranthi

  5. Husain AlKhamis
    September 25, 2012 at 10:14 pm

    @Kranthi
    Just follow the post exactly as it’s and I’m sure you will be fine.
    Don’t be in a hurry or frustrated.

    I’m in a situation I can’t help investigate your problem right now.

    This post took me some time to understand and figure out how to do it.
    Just follow it exactly step by step.

    Do your best and good luck

    • Kranthi Banoth
      September 26, 2012 at 1:39 am

      @Hussain
      Thank you for the reply…
      I have followed all the steps and I am sure that I have configured each and every step fine and also SVN and Trac are running fine. The only thing is when I am accessing SVN through https link, it is asking me username and password. Please let me know, what is the username and password that needs to be provided for accessing the https link for SVN.

      Regards,
      Kranthi Banoth

      • Kranthi Banoth
        September 26, 2012 at 9:06 am

        @Hussain
        The path for the password file and password file configured for secure web might be different in the cgi scritps files configured by you. As per your steps password file and path for password file is as below:
        /etc/apache2/passwords
        But, in the cgi files the paths are mentioned as below:
        AuthUserFile /etc/apache2/.htpasswd

        Is this correct, or do we need to change paths of passwd file in cgi files.

        Thank you in advance for your valuable reply.

        Regards,
        Kranthi Banoth

  6. Husain AlKhamis
    September 29, 2012 at 7:01 am

    @Kranthi
    Most probably you are right! The reason why it is working for me because I’m having both files with the same access credentials!!

    So, yeah try to make them all same.

    Also, make sure you enabled the SSl Module.

    BR
    Husain

    • Kranthi Banoth
      October 1, 2012 at 2:31 am

      @Hussain,
      Thank you Hussain. I have named both the password files with same names. Now I am able to access both SVN and Trac through secure https link. Only once issue I have is, when I issue the below command:
      sudo trac-admin Trac_Project_01 initenv

      It did not ask me for the Repository type and the Path to Repository. This is the reason, I am not able to see the SVN repos in Trac. Is there any other way to add SVN repositories to trac? If yes, please let me know, how to add SVN repos to Trac, so that I can handle repo’s through Trac.

      Thanks in advance,
      Kranthi Banoth

  1. February 3, 2010 at 7:31 pm
  2. November 10, 2011 at 7:49 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: