Subversion logo
Subversion server configuration options:
* svnserve: This is a simple stand-alone server which comes with the Subversion release.
* svn+ssh: This is a simple stand-alone server which uses ssh security,
* Apache httpd server with Subversion:
o allows more integration
o allows web server viewing straight from the repository
o ability to mount repository as a network share (WEBDAV capability offered through Apache)
This tutorial covers the Apache-Subversion installation and configuration.
Subversion download options:
* Use the version of Subversion which comes with your release of Linux:
o Red Hat Enterprise Linux 5/CentOS 5 (Apache 2.2, Python 2.4, ...) - Subversion 1.4
o Red Hat Enterprise Linux 4/CentOS 4 (Apache 2.0, Python 2.3, ...) - Subversion 1.1
* Install or upgrade to the DAG RPM Subversion packages with slightly newer but compatible versions.
* Use the latest CollabNet bundled release of Apache, Subversion and ViewVC. Unfortuanetly this is a stripped down version of Apache without support for Perl modules, PHP, etc. This release is what is required to run a Subversion server and the ViewVC web front-end only. It even includes stripped down python support. I could not get this version to work with Apache authentication Perl modules or with Trac.
* Use the Summersoft RPMs. Great for the latest releases of Subversion which will work with the OS release of Apache, Python, etc. Problems arise when trying to put the latest release of Subversion with dependencies on very current versions of framework applications onto an older version of the OS (i.e. installing SVN 1.6.9 on RHEL4). Great for use SVN 1.6.9 with a current OS (i.e. RHEL5)
* Download source and compile. Requires downloads of source and compilation of dependencies as well.
Subversion.Apache.org Subversion downloads page [source]
This tutorial focuses on the version of Subversion which is released with the OS (RHEL4/5 and CentOS 4/5) or compatible DAG upgrades.
Red Hat Enterprise 5 with SVN 1.6.9: (Summersoft RPM upgrade. Default is SVN 1.4)
Download: http://summersoft.fay.ar.us/pub/subversion/1.6.9/rhel5/i386/ (32 bit i386. 64 bit also available)
* mod_dav_svn-1.6.9-1.i386.rpm
* neon-0.28.4-1.i386.rpm (neon-devel-0.28.4-1.i386.rpm)
* sqlite-3.5.9-2.i386.rpm (sqlite-devel-3.5.9-2.i386.rpm)
* subversion-1.6.9-1.i386.rpm (subversion-devel-1.6.9-1.i386.rpm)
* subversion-perl-1.6.9-1.i386.rpm
* subversion-python-1.6.9-1.i386.rpm
* subversion-tools-1.6.9-1.i386.rpm (May require dependency Perl module File::Path RPM package. eg: perl-File-Path-2.03-1.n0i.3.fc8.noarch.rpm. File::Path may also be included with Perl in which case ignore the dependency: rpm -ivh --force subversion-tools-1.6.9-1.i386.rpm)
Installation:
* rpm -Uvh sqlite-3.5.9-2.i386.rpm sqlite-devel-3.5.9-2.i386.rpm
* rpm -ivh neon-0.28.4-1.i386.rpm neon-devel-0.28.4-1.i386.rpm
* rpm -ivh subversion-1.6.9-1.i386.rpm subversion-devel-1.6.9-1.i386.rpm subversion-python-1.6.9-1.i386.rpm subversion-perl-1.6.9-1.i386.rpm mod_dav_svn-1.6.9-1.i386.rpm
Note:
* The "devel" RPMs provide C language include files and libraries for open source development and are not required unless you plan to build an application which requires the "devel" RPMs.
* May be required to remove existing SNV installation to avoid conflicts: rpm -e subversion subversion-devel
Red Hat Enterprise 4 with SVN 1.1.4: (RHEL4 default)
Install from RPM (RHEL4): rpm -ivh subversion-1.1.4-2.ent.i386.rpm
Red Hat Enterprise 4 with SVN 1.4.2: (Dag Wieers upgrade RPMs)
http://dag.wieers.com/rpm/packages/subversion/
Upgrade: rpm -Uvh subversion-tools-1.4.2-1.i386.rpm subversion-python-1.4.2-1.i386.rpm subversion-perl-1.4.2-1.i386.rpm subversion-1.4.2-1.i386.rpm mod_dav_svn-1.4.2-1.i386.rpm apr-0.9.12-1.i386.rpm apr-devel-0.9.12-1.i386.rpm apr-util-0.9.12-1.i386.rpm
Installation of Subversion 1.4.6 using RPMs from DAG on Red Hat Enterprise Linux 5 (or CentOS 5) is almost exactly the same.
Ubuntu: apt-get install subversion enscript libapache2-mod-python python-docutils db4.3-util libapache2-svn subversion-tools
Subversion Repository Creation:
There are two database options available for the Subversion repository creation.
* FSFS:
* Berkeley DB:
Discussion of differences and merits of FSFS vs Berkeley DB.
Create a Subversion repository using the FSFS database format: (as root)
* mkdir /srv/svn/repos
* svnadmin create --fs-type fsfs /srv/svn/repos
* chown apache:apache -R /srv/svn/repos
(The Apache web server running as user "apache" is the process owner which will be interfacing with the Subversion repository.)
* SELinux security attribute assignment: (Red Hat EL4+, Fedora 3+)
restorecon -R /srv/svn/repos
or
chcon -R -h -t httpd_sys_content_t /srv/svn/repos"
Options:
o -h: affect symbolic links instead of any referenced file
o -t: set type TYPE in the target security context
o -R: change files and directories recursively
(Required for SELinux systems so that apache can write to this area or turn off SELinux. For more info see the YoLinux SysAdmin/SELinux tutorial)
This will create the default database files, configuration files and directory structure required to support Subversion. The choice of repository type is stored in /srv/svn/repository-name/db/fstype. In this case if you "cat" the file it will show "fsfs".
Apache Web Server Configuration for Subversion:
Subversion can be configured to use a local file system (NOT a network filesystem!!!), it's own server (svnserve) or use Apache and the webdav interface. This configuration shows the Subversion installation configured with Apache on Red Hat Enterprise 4 (RHEL4).
Apache configuration file: /etc/httpd/conf.d/subversion.conf
* This example performs no authentication:
view source
print?
01 # Required for Apache interface
02 LoadModule dav_svn_module modules/mod_dav_svn.so
03
04 # Required for "per-directory" access control
05 LoadModule authz_svn_module modules/mod_authz_svn.so
06
07 # URL path in web browser after "http://yourdomain.com/": /svn
08
09 DAV svn
10 # Local path on server filesystem: /srv/svn/repos
11 SVNPath /srv/svn/repos
12
* This example authenticates to a local Apache user password file: User logins and passwords have no connection to user accounts.
view source
print?
01 LoadModule dav_svn_module modules/mod_dav_svn.so
02 LoadModule authz_svn_module modules/mod_authz_svn.so
03
04 DAV svn
05 SVNPath /srv/svn/repos
06 AuthType Basic
07 AuthName "Subversion Repository"
08 AuthUserFile /etc/httpd/conf/userpw
09 require valid-user
10
Remove the line "require valid-user" to allow read-only access for unauthenticated users.
For more on Apache user file authentication see:
o YoLinux Apache Authentication: User File Authenticated Logins
* This example authenticates logins with the NIS server. This requires the installation of perl modules Apache-AuthenNIS. See the YoLinux Apache NIS authentication tutorial (See this tutorial if running Apache httpd 2.2)
view source
print?
01 LoadModule dav_svn_module modules/mod_dav_svn.so
02 LoadModule authz_svn_module modules/mod_authz_svn.so
03
04 DAV svn
05 SVNPath /srv/svn/repos
06 AuthType Basic
07 AuthName "Subversion Repository"
08 PerlAuthenHandler Apache::AuthenNIS
09 PerlSerVar AllowAlternateAuth no
10 require valid-user
11
This example is for RHEL4 with Apache httpd 2.0.
See Subversion manual: authentication options for more information.
YoLinux.com Apache authentication tutorial - password file, NIS, LDAP, ...
Allow the web server to control content: chown -R apache:apache /srv/svn
Restart Apache: service httpd restart
Importing Directory of Files Into Subversion:
Subversion Repository on Server File system:
* /srv/svn/repos
Import directory of files into Subversion:
* Local directory to import into Subversion:
o projectX/trunk/...source code goes here...
o projectX/branches
o projectX/tags
* svn import -m "Initial Import" local-directory-projectX http://server-name/svn/projectX
The import will create the new subdirectory branch "projectX" in the repository.
Alternate directory creation method: (repository exists but the directories need to be generated)
* svn mkdir -m"Initial creation of trunk directory" http://svn-server/svn/projectX/trunk
* svn mkdir -m"Initial creation of branches directory" http://svn-server/svn/projectX/branches
* svn mkdir -m"Initial creation of tags directory" http://svn-server/svn/projectX/tags
Browser view of a typical repository directory schema:
* http://svn-server/svn/projectX/trunk: For the "HEAD"
* http://svn-server/svn/projectX/branches: For branches or "forks" in the code.
* http://svn-server/svn/projectX/tags: For tags identifying snapshots of milestones or significant releases.
Explanation of Subversion directories:
* /trunk : Contains the current development branch. New projects should be started here.
* /branches : A branch is just a special copy of the source tree within Subversion that started with a specific revision of the code. A branch is created by using "svn copy" of the trunk to a branch i.e. /branch/name_of_branch_1.0.
* /branches/personal : Personal branches are for doing some work which you don't want to have interfere with the main trunk until it is working or better defined.
* /tags : This is a ethod of bookmarking or taking a "snapshot" of some work in progress.
* /releases : This is similar to "tags" except that this version of the code makes it to production. Names used here should match product release names. i.e. version_1.1
Avoiding false diffs due to "^M" in a cross platform environment:
The Microsoft development tools love to add a "^M" at the end of the line of every file they edit. This breaks UNIX shell script and causes many file difference tools to show a difference in a line of code. This can be avoided in a cross platform environment by telling Subversion that certain files (or all files) that no "^M"'s should be appended at the end of a line. The trigger in fact removes the "^M" when the file is checked in. It can also be removed using the command dos2unix.
Import files to support no "^M" carriage returns at the end of lines:
(This sets file properties and creates a check-in trigger.)
* Remove "^M" from files: find local-directory -name "*.cpp" -exec dos2unix {} \;
* Upload directory of files into Subversion:
svn import -m "Initial Import" local-directory http://server-name/svn/projectX
* Checkout files from repository: svn co http://server-name/svn/projectX/trunk
This creates your local working directory under Subversion control.
* Set file properties such that "^M" are removed during check-in if added:
find ./ -name "*.cpp" -exec svn propset svn:eol-style LF {} \;
* Apply property changes to repository: svn ci -m "Apply LF properties" local-directory
Note that the "propset" command must be used for new files added to the Subversion repository if they are to have these properties.
Users can also set this option in the file: $HOME/.subversion/config
..
...
[auto-props]
README = svn:eol-style=native
INSTALL = svn:eol-style=native
*.c = svn:eol-style=LF
*.cpp = svn:eol-style=LF
*.h = svn:eol-style=LF
*.dsp = svn:eol-style=CRLF
*.dsw = svn:eol-style=CRLF
*.sh = svn:eol-style=native;svn:executable
*.txt = svn:eol-style=LF
*.png = svn:mime-type=image/png
*.jpg = svn:mime-type=image/jpeg
Makefile = svn:eol-style=LF
*.html = svn:eol-style=LF
*.css = svn:eol-style=LF
*.java = svn:eol-style=LF
*.xml = svn:eol-style=LF
*.m4 = svn:eol-style=LF
*.pdf = svn:mime-type=application/pdf
...
..
Subversion Repository Transfer:
Data repository dump:
* Dump first entry to current:
svnadmin dump /srv/svn/repos --revision 0:HEAD > repos.dump
* Dump revision 625 to current:
svnadmin dump /srv/svn/repos --revision 625:HEAD --incremental > repos-625.dump
Data repository load:
* First load: svnadmin load /srv/svn/repos < repos.dump
* Incremental load: svnadmin load /srv/svn/repos < repos-625.dump
For more complex transfers with path translation, see the YoLinux Subversion repository data transfer tutorials.
Subversion Repository Backups:
The following is a cron job to dump the repository to an ascii file as a backup:
File: /etc/cron.daily/CmSvnDump.sh
view source
print?
1 #!/bin/bash
2 #
3 cd /mnt/backup/cm
4 /etc/init.d/httpd stop
5 umask 002
6 /usr/bin/svnadmin dump /srv/svn/projectX --revision 0:HEAD > CmSvnDump-`date +%m%d%y`.dump
7 /etc/init.d/httpd start
SELinux requirement: chcon -u system_u -t bin_t CmSvnDump.sh
Subversion XSLT:
The best presentation interface is "Insurrection" detailed below. For a quick and easy improvement to the Subversion web interface, use the XSLT file which comes with the "subversion-tools RPM".
Create path links:
* ln -s /usr/lib/subversion/tools/xslt/svnindex.xsl /var/www/html/
* ln -s /usr/lib/subversion/tools/xslt/svnindex.css /var/www/html/
or for the 64 bit Summersoft RPM releases:
* ln -s /usr/lib64/subversion/tools/xslt/svnindex.xsl /var/www/html/
* ln -s /usr/lib64/subversion/tools/xslt/svnindex.css /var/www/html/
Add the "SVNIndexXSLT" directive to the file /etc/http/conf.d/subversion.conf
view source
print?
1 LoadModule dav_svn_module modules/mod_dav_svn.so
2
3 DAV svn
4 SVNPath /srv/svn/repos
5
6 SVNIndexXSLT "/svnindex.xsl"
7
The XSLT reference can also be a full URL: SVNIndexXSLT "http://yourdomain/path/svnindex.xsl"
[Potential Pitfall]: Some browsers (like Konquerer), do not process XSLT. This will prohibit them from traversing directories which are rendered with XSLT. This is unfortunate as Konquerer has syntax highlighting for rendering many of the popular programming languages.
Subversion Links:
* Online O'Reily Subversion book
* Subversion Repository Administration (O'Reily Chapter 5)
* Subversion Server configuration (O'Reily Chapter 6)
* WANdisco: Subversion MultiSite
* ViewVC: Web front-end
o ViewVC (installation below)
o ViewVC RPMs
Web Interface Front-ends to Subversion:
While Subversion has a native web interface it does not allow one to view anything but the "HEAD" or latest versions of the files stored. The following web front-ends to Subversion will allow one to view previous file revisions and even perform file comparisons between revisions. Insurrection seems to have a more elegant interface and structure but is more difficult to install and configure.
* ViewVC
* Insurrection
ViewVC:
ViewVC is a Python based web interface to Subversion available in an installable RPM package or can be installed from source.
Install RPM: rpm -ivh viewvc-1.0.5-1.el4.rf.noarch.rpm
Install from source:
* Download from http://www.viewvc.org/download.html
* tar xzf viewvc-1.1.2.tar.gz
* cd viewvc-1.1.2/
* ./viewvc-install
Installation path [/usr/local/viewvc-1.1.2]: /opt/viewvc
* cp /opt/viewvc/bin/cgi/viewvc.cgi /var/www/cgi-bin
* cp /opt/viewvc/bin/cgi/query.cgi /var/www/cgi-bin
* Edit /opt/viewvc/viewvc.conf
(See example below)
Apache configuration file: /etc/httpd/conf.d/viewvc.conf
view source
print?
01 ScriptAlias /viewvc /var/www/cgi-bin/viewvc.cgi
02 ScriptAlias /query /var/www/cgi-bin/query.cgi
03 Alias /viewvc-static /var/www/viewvc
04 #
05
06 Allow from all
07
08
09
10 AuthType Basic
11 AuthName "Authorization Realm"
12 PerlAuthenHandler Apache::AuthenNIS
13 PerlSetVar AllowAlternateAuth no
14 Require valid-user
15
16
17
18 AuthType Basic
19 AuthName "Authorization Realm"
20 PerlAuthenHandler Apache::AuthenNIS
21 PerlSetVar AllowAlternateAuth no
22 Require valid-user
23
File:
* RPM install: /etc/viewvc/viewvc.conf
* Installed from source: /opt/viewvc/viewvc.conf
[general]
svn_roots = projectX: /srv/svn/projectX,projectY: /srv/svn/projectY
default_root = projectX
Try it out: http://localhost/viewvc/
Links:
* ViewVC.org - home page
* Dag.Wieers.com: Red Hat/Fedora RPMs
* RPM.pbone.net: OpenSuSE, Red Hat, Fedora, Mandriva RPMs
Insurrection Installation and Configuration:
Insurrection is a HTML, CSS and XSLT (and some perl) web presentation layer for Subversion. It creates a more functional and feature rich web interface to Subversion. It does not support Opera or browsers without XSLT support. Supports IE/Mozilla and Firefox.
Installation:
* Download using Subversion: svn export http://svn.code-host.net/svn/Insurrection/trunk/
This will download Insurrection to a local directory called "trunk".
OR
* insurrection-100906.tar.gz
Installation:
* Move to web directory: mv trunk /var/www/Insurrection
* Edit files:
o insurrection.conf: Place this file in /etc/httpd/conf.d/
This Apache configuration files needs to be edited to suit your installation. This example is set to replace your /etc/httpd/conf.d/subversion.conf file. Do not duplicate functionality in both.
o insurrection.js: Edit SVN_URL per your Subversion repository.
o insurrection.pl:
Edit and set variables:
+ SVN_REPOSITORIES_URL
+ SVN_AUTH
+ SVN_BASE
* Add a logo image file to your insurrection directory: /var/www/Insurrection/cm.megacorp.com.gif
Note: This is required as the logic checks for the existence of this file to function properly. If using a port other than web port 80, (i.e. port 222) then specify the port: /var/www/Insurrection/cm.megacorp.com:222.gif
* Edit the file /var/www/Insurrection/.htaccess for the gif logo path. May have to edit the SVN_URL location in insurrection.js. Comment out lines referencing ls.cgi in RewriteCond and RewriteRule.
Note that Insurrection's default configuration is set to use a virtual host or a dedicated server for Subversion. This is due to "DocumentRoot" being set to "/". If using a different Apache "DocumentRoot" configuration, edit the directory prefixes in insurrection.xsl.
Links:
* Home page: http://insurrection.tigris.org
* Info
StatSVN: Subversion repository statistics and analytics
StatSVN is a metrics-analysis tool which will provide web reporting and charting of lines of code (LOC), developer activity, file count, file size and project statistics based on Subversion repository activity.
Note that StatSVN requires Java. See the YoLinux.com Java installation tutorial.
Note that StatSVN version 0.4.1 is the last version which does not require an X-Window frame bufffer (thus easy to use with a cron or batch script).
Install and Configure:
* Download the compressed compiled Java file statsvn-0.4.1.zip from sourceforge.
wget http://prdownloads.sourceforge.net/statsvn/statsvn-0.4.1.zip
* Decompress and extract contents of zip file: unzip statsvn-0.4.1.zip
* Install Java program: mv statsvn-0.4.1/statsvn.jar /opt/bin/statsvn.jar
Configuring StatSVN as a cron job:
Create the following cron job script: /etc/cron.daily/StatSVN.sh
view source
print?
01 #!/bin/bash
02 #
03 # Generate the StatSVN web pages
04 #
05 if [ -d /usr/java/latest ]
06 then
07 export PATH=/usr/java/latest/bin:$PATH
08 export JAVA_HOME=/usr/java/latest
09 export CLASSPATH=/usr/java/latest/lib/tools.jar:./
10 else
11 exit
12 fi
13
14 # Update local Subversion repository
15 # Uncomment this line if this script is to update the local working Subversion repository.
16 # svn update /opt/Cabie/BUILDS/buildserver1/trunk
17
18 # Generate Subversion log file
19 svn log -v --xml /opt/Cabie/BUILDS/buildserver1/trunk > \
20 /opt/Cabie/BUILDS/buildserver1/StatSVN/logfile.log
21
22 # Create web content here:
23 cd /opt/Cabie/BUILDS/buildserver1/StatSVN
24
25 # Generate web content
26 java -jar /opt/bin/statsvn.jar -viewvc http://cmserver.yourdomain.com/viewvc/ProjectX/trunk/application1/ \
27 -output-dir /opt/Cabie/BUILDS/buildserver1/StatSVN/html \
28 /opt/Cabie/BUILDS/buildserver1/StatSVN/logfile.log \
29 /opt/Cabie/BUILDS/buildserver1/ProjectX/trunk/application1/
30
Specify the correct directory paths for your configuration:
* Subversion local checkout directory: /opt/Cabie/BUILDS/buildserver1/trunk
(Our is located on our Cabie build server. See the YoLinux Cabie tutorial.)
* Path for Subversion metrics-analysis web pages created by StatSVN which is also accessible to the Apache web server: /opt/Cabie/BUILDS/buildserver1/StatSVN
* Temporary log file: /opt/Cabie/BUILDS/buildserver1/StatSVN/logfile.log
(Can also use /etc/logfile.log)
* If using SELinux, you will be required to change the security context of this script file so that cron can execute it. This method copies an existing cron script context of an existing cron script:
chcon --reference=/etc/cron.daily/makewhatis.cron /etc/cron.daily/StatSVN.sh
Note in this installation, our Cabie build server updates the local repository after every check-in. If your repositry is not updated automatically, uncomment the line in the script to do so.
[Potential Pitfall]: Cron jobs execute as root. You may have to specify an alternative login and password which has access to the Subversion repository. e.g.
svn log -v --xml --username userX --password supersecret /opt/Cabie/BUILDS/...
Create a local specific non-system account Subversion login for the cron job.
See Concurrent file and LDAP Apache authentication.
Avoid interactive dialog during the cron job by setting the following Subversion configuration parameter setting in /root/.subversion/servers (Cron jobs run as user root)
[global]
store-plaintext-passwords = no
This will avoid the following interactive message: Store password unencrypted (yes/no)?
Command Line Options:
statsvn.jar command line options: (Usage: java -jar statsvn.jar [options]
Option Description
-version print the version information and exit
-output-dir
-include
-exclude
-tags
-title
-viewvc
This option causes StatSVN to generate hyperlinks to ViewVC for source code file names listed by StatSVN.
-trac
-bugzilla
-username
-password
-verbose print extra progress information
-xdoc optional switch output to xdoc
-xml optional switch output to xml
-threads
-concurrency-threshold
-dump dump the Repository content on console
-charset
-tags-dir
Apache configuration so that StatSVN reports are viewable:
File: /etc/httpd/conf.d/statsvn.conf
view source
print?
1 Alias /StatSVN /opt/Builds/buildserver1/StatSVN/html
2
3 Options Indexes FollowSymLinks
4 AuthType Basic
5 ...
6
View with browser: http://cmserver.yourdomain.com/StatSVN/
In this example the web content will be in /opt/Cabie/BUILDS/buildserver1/StatSVN/html. Apache must be configured to view this directory. See the YoLinux Apache Web server configuration tutorials.
StatSVN version 5.0 and above require X-Windows to support Java Swing classes used by statsvn.jar. If running via a cron or batch job, one will have to set up a virtual frame buffer. I never got this to work successfully so I just used StatSVN 0.4.1 instead.
Virtual frame buffer configuration:
* Install Xvfb:
o yum update xorg-x11-server-Xorg
o yum install xorg-x11-server-Xvfb
* /usr/bin/Xvfb :2 -nolisten tcp -shmem &
* export DISPLAY=:2.0
* Run statsvn.jar here
* killall Xvfb
Note that it would be preferable to start Xvfb with an init script so that it starts and stops when the system boots and shuts down. See the YoLinux.com init process tutorial.
Links:
* StatSVN.org - home page
* Sourceforge Page
* statSVN example report
Trac Server Installation and Configuration:
Red Hat EL4: RPM installation (Red Hat Enterprise Linux 4 [Python 2.3], Trac 0.9.6 example)
* http://dag.wieers.com:
(Select: Home made + RPM repository + RPMforge)
o trac-0.9.6-1.el4.rf.noarch.rpm
o clearsilver-0.10.1-1.2.el4.rf.i386.rpm
o clearsilver-devel-0.10.1-1.2.el4.rf.i386.rpm
o python-clearsilver-0.10.1-1.2.el4.rf.i386.rpm
o python-imaging-1.1.5-5.el4.i386.rpm
o python-sqlite-1.0.1-1.2.el4.rf.i386.rpm
o sqlite-2.8.16-1.2.el4.rf.i386.rpm
o sqlite-devel-2.8.16-1.2.el4.rf.i386.rpm
* http://rpm.pbone.net:
o python-docutils-0.4-2.el4.noarch.rpm
or configure YUM and import from the DAG YUM repository. See the YoLinux SysAdmin Tutorial: YUM
yum install -y trac
Red Hat EL5: manual installation from source (Red Hat Enterprise Linux 5 [Python 2.4, sqlite], Trac 0.11.5 example)
Note:
* Clearsilver web templates depricated, now uses Genshi. Trac 0.11.5 required to support Subversion 1.6.X.
* If upgrading, remove old version. See: /usr/lib/python2.3/site-packages/trac/, /usr/share/trac/, /srv/trac/ProjectX/egg_cache/, /usr/bin/trac-admin and tracd
* RHEL5 package prerequisites: python, python-setuptools, httpd
Installation:
* Download: http://trac.edgewall.org/wiki/TracDownload
* tar xzf Trac-0.11.5.tar.gz
* cd Trac-0.11.5/
* List commands: python ./setup.py --help
* Install: python ./setup.py install
o This installs the Python template package Genshi
o Installs Trac to /usr/lib/python2.4/site-packages/Trac-0.11.5-py2.4.egg/
o Installs commands (trac-admin, tracd): /usr/bin
[Potential Pitfall]: If the Trac install fails to download and install Genshi, one can manually install it:
o Download from: http://genshi.edgewall.org/wiki/Download
(or wget http://ftp.edgewall.com/pub/genshi/Genshi-0.5.1.tar.gz)
o tar xzf Genshi-0.5.1.tar.gz
o cd Genshi-0.5.1/
o python setup.py install
Then attempt to install Trac again: python ./setup.py install
* Install CGI: cp cgi-bin/trac.cgi cgi-bin/trac.fcgi /var/www/cgi-bin
Note:
o Set environment variable (Trac 0.11+) in /etc/httpd/conf.d/trac.conf:
SetEnv PYTHON_EGG_CACHE /srv/trac/projectX/egg_cache
o Create the directory /srv/trac/projectX/egg_cache as it must be present even if not used.
* Create new project repository:
# trac-admin /srv/trac/projectX initenv
Project Name [My Project]> projectX
Database connection string [sqlite:db/trac.db]>
Path to repository [/path/to/repos]> /srv/svn/projectX
Ubuntu: apt-get install trac
Allow Trac CGI to be executed (Two methods. Pick one.):
1. Copy the CGI to the default CGI bin directory: cp /usr/share/trac/cgi-bin/trac.cgi /var/www/cgi-bin
OR
2. Enable Apache to execute the CGI:
view source
print?
1 ..
2 ScriptAlias /trac /usr/share/trac/cgi-bin/trac.cgi
3 ..
Note:The CGI trac.fcgi is for use with Apache Python module mod_fastcgi to improve performance.
As root: [root]# trac-admin /srv/trac/projectX initenv
Project Name [My Project]> projectX
Database connection string [sqlite:db/trac.db]>
Path to repository [/var/svn/test]> /srv/svn/projectX
Templates directory [/usr/share/trac/templates]>
Note:
* The directory /srv/trac MUST exist.
* The directory /srv/trac/projectX MUST not exist before execution of command.
Trac repository directories:
* SuSE: /srv/trac/
* Red Hat: /usr/share/trac/proj_trac/
This command will initialize the Trac data repository and create a directory structure and default configuration files.
Allow paths and files to be accessible by Apache: [root]# chown -R apache:apache /srv/trac/projectX
SELinux:
* chcon -R -t httpd_sys_content_t /usr/share/trac/
* chcon -R -t httpd_sys_content_t /srv/trac/
Component Home pages:
* Trac
* Clearsilver
* Docutils
* Python Imaging
* pySQLite
* SQLite.org
Trac Configuration:
File: /srv/trac/projectX/conf/trac.ini
(Created using the "trac-admin" command above and not provided by the RPM package.)
Specify project URL:
..
...
[trac]
...
repository_dir = /srv/svn/projectX - This ties Trac to Subversion
...
...
[notification]
Set email and SMTP information here
...
...
[project]
url = http://projectX.com
For more trac.ini configuration information see Trac: trac.ini configuration
[Potential Pitfall]: Once Trac is configured and used (i.e. it has tickets, etc), it can not be pointed to a different Subversion repository. If you point "repository_dir" to a new Subversion repository, you will not have a Trac database which is in sync with Subversion and Trac will fail. The name of the directory path and the "repository_dir" can be renamed with matching names, but the actual Subversion repository must remain the same.
Apache Web Server configuration file for Trac integration:
Trac can be run using the stand-alone Trac daemon "tracd". This configuration shows the use of Apache with Trac.
File: /etc/httpd/conf.d/trac.conf
* This example performs no authentication:
view source
print?
1 Alias /trac/ "/usr/share/trac/htdocs/"
2
3 SetEnv TRAC_ENV "/srv/trac/projectX"
4
or Red Hat Dag.Wieers.com rpm installation example:
view source
print?
1 ScriptAlias /trac /usr/share/trac/cgi-bin/trac.cgi
2
3 SetEnv TRAC_ENV "/srv/trac/projectX"
4
* This example authenticates logins internally using Apache. User logins and passwords have no connection to user accounts.
view source
print?
01 Alias /trac/ "/usr/share/trac/htdocs/"
02
03 SetEnv TRAC_ENV "/srv/trac/projectX"
04
05
06 # The following enables the "login" link in Trac.
07 # (Top right hand corner)
08
09
10 AuthType Basic
11 AuthName "Project X Trac"
12 AuthUserFile /etc/httpd/conf/userpw
13 require valid-user
14
For more on Apache user file authentication see:
o YoLinux Apache Authentication: User File Authenticated Logins
* This example authenticates logins internally using Trac and Digest authentication. User logins and passwords have no connection to user accounts.
view source
print?
01 Alias /trac/ "/usr/share/trac/htdocs/"
02
03 SetEnv TRAC_ENV "/srv/trac/projectX"
04
05
06 # The following enables the "login" link in Trac.
07 # (Top right hand corner)
08
09
10 AuthType Digest
11 AuthName "Project X Trac"
12 AuthDigestDomain /trac
13 AuthDigestFile /etc/httpd/conf/digestpw
14 require valid-user
15
For more on digest authentication see:
o Apache.org: Module mod_auth_digest
o RFC 2617
* This example authenticates user account logins with the NIS server. This requires the installation of perl modules Apache-AuthenNIS. See the YoLinux Apache NIS authentication tutorial (See this tutorial if running Apache httpd 2.2)
view source
print?
01 Alias /trac/ "/usr/share/trac/htdocs/"
02
03 SetEnv TRAC_ENV "/srv/trac/projectX"
04 AuthType Basic
05 AuthName "Project X Trac"
06 PerlAuthenHandler Apache::AuthenNIS
07 PerlSerVar AllowAlternateAuth no
08 require valid-user
09
10
11 # The following enables the "login" link in Trac.
12 # (Top right hand corner)
13
14
15 AuthType Basic
16 AuthName "Project X Trac"
17 PerlAuthenHandler Apache::AuthenNIS
18 PerlSerVar AllowAlternateAuth no
19 require valid-user
20
Auth configuration prohibits anonymous use of Trac
This example is for RHEL4 with Apache httpd 2.0.
Restart Apache: service httpd restart
Also see YoLinux Apache authentication tutorial: LDAP, NIS, File.
Trac Administration:
Issue Trac commands as root:
* Command line: trac-admin --help
OR
* Enter into Trac Admin shell: trac-admin /srv/trac/projectX
Then type "help" to see list of commands.
Use the command "quit" to exit the shell.
Set Permissions:
* Grant administration privileges to a user:
trac-admin /srv/trac/projectX permission add userid TRAC_ADMIN
These permissions are required if using web interface to manage "roadmaps".
* Show permissions:
trac-admin /srv/trac/projectX permission list user-id
* Remove write for anonymous users:
trac-admin /srv/trac/projectX permission remove anonymous TICKET_CREATE TICKET_MODIFY WIKI_CREATE WIKI_MODIFY
* Set default for authenticated users:
trac-admin /srv/trac/projectX permission add authenticated TICKET_CREATE TICKET_MODIFY TICKET_VIEW WIKI_CREATE WIKI_MODIFY
Add components to be managed by Trac:
* Roadmap/Product Milestones:
o trac-admin /srv/trac/projectX milestone add name-of-milestone YYYY-MM-DD
o trac-admin /srv/trac/projectX milestone completed name-of-milestone YYYY-MM-DD
(Where "YYYY-MM-DD" is the due date or completion date. i.e. 2006-11-17)
The milestones can be created using the web interface.
* Software Components: trac-admin /srv/trac/projectX component add name-of-component owner-id
Defaults for "New Ticket":
* Type: defect, enhancement, task
View using the command: trac-admin /srv/trac/projectX ticket_type list
Use "add" or "delete" to change the default.
* Priority: blocker, critical, major, minor, trivial
View using the command: trac-admin /srv/trac/projectX priority list
Use "add" or "delete" to change the default.
* Severity: highest, high, normal, low, lowest
View using the command: trac-admin /srv/trac/projectX severity list
Use "add" or "delete" to change the default.
Trac-Admin commands: trac-admin /path/to/projenv [command [subcommand] [option ...]]
Command Description
about Shows information about trac-admin
help Show documentation
initenv Create and initialize a new environment interactively
initenv
hotcopy
resync Re-synchronize trac with the repository
upgrade Upgrade database to current version
wiki list List wiki pages
wiki remove
wiki export
wiki import
wiki dump
wiki load
wiki upgrade Upgrade default wiki pages to current version
permission list [user] List permission rules
permission add
permission remove
component list Show available components
component add
component rename
component remove
component chown
ticket_type list Show possible ticket types
ticket_type add
ticket_type change
ticket_type remove
ticket_type order
priority list Show possible ticket priorities
priority add
priority change
priority remove
priority order
severity list Show possible ticket severities
severity add
severity change
severity remove
severity order
version list Show versions
version add
version rename
version time
No comments:
Post a Comment