Thursday, August 5, 2010

Subversion

Subversion server installation and Configuration:
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 directory where HTML suite will be saved
-include include only files matching pattern, e.g. **/*.c;**/*.h
-exclude exclude matching files, e.g. tests/**;docs/**
-tags show matching tags in lines of code chart, e.g. version-.*
-title Project title to be used in reports <br /> -viewvc <url> Integrate with ViewVC installation at <url> <br /> This option causes StatSVN to generate hyperlinks to ViewVC for source code file names listed by StatSVN. <br /> -trac <url> integrate with Trac at <url> <br /> -bugzilla <url> integrate with Bugzilla installation at <url> <br /> -username <svnusername> username to pass to svn <br /> -password <svnpassword> password to pass to svn <br /> -verbose print extra progress information <br /> -xdoc optional switch output to xdoc <br /> -xml optional switch output to xml <br /> -threads <int> how many threads for svn diff (default: 25) <br /> -concurrency-threshold <millisec> switch to concurrent svn diff if 1st call > threshold (default: 4000) <br /> -dump dump the Repository content on console <br /> -charset <charset> specify the charset to use for html/xdoc <br /> -tags-dir <directory> optional, specifies the director for tags (default '/tags/') <br /> <br />Apache configuration so that StatSVN reports are viewable: <br /> <br /> File: /etc/httpd/conf.d/statsvn.conf <br /> view source <br /> print? <br /> 1 Alias /StatSVN /opt/Builds/buildserver1/StatSVN/html <br /> 2 <Directory "/opt/Builds/buildserver1/StatSVN/html"> <br /> 3 Options Indexes FollowSymLinks <br /> 4 AuthType Basic <br /> 5 ... <br /> 6 </Directory> <br /> View with browser: http://cmserver.yourdomain.com/StatSVN/ <br /> <br /> 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. <br /> <br />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. <br />Virtual frame buffer configuration: <br /> <br /> * Install Xvfb: <br /> o yum update xorg-x11-server-Xorg <br /> o yum install xorg-x11-server-Xvfb <br /> * /usr/bin/Xvfb :2 -nolisten tcp -shmem & <br /> * export DISPLAY=:2.0 <br /> * Run statsvn.jar here <br /> * killall Xvfb <br /> <br />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. <br /> <br />Links: <br /> <br /> * StatSVN.org - home page <br /> * Sourceforge Page <br /> * statSVN example report <br /> <br />Trac Server Installation and Configuration: <br /> <br />Red Hat EL4: RPM installation (Red Hat Enterprise Linux 4 [Python 2.3], Trac 0.9.6 example) <br /> <br /> * http://dag.wieers.com: <br /> (Select: Home made + RPM repository + RPMforge) <br /> o trac-0.9.6-1.el4.rf.noarch.rpm <br /> o clearsilver-0.10.1-1.2.el4.rf.i386.rpm <br /> o clearsilver-devel-0.10.1-1.2.el4.rf.i386.rpm <br /> o python-clearsilver-0.10.1-1.2.el4.rf.i386.rpm <br /> o python-imaging-1.1.5-5.el4.i386.rpm <br /> o python-sqlite-1.0.1-1.2.el4.rf.i386.rpm <br /> o sqlite-2.8.16-1.2.el4.rf.i386.rpm <br /> o sqlite-devel-2.8.16-1.2.el4.rf.i386.rpm <br /> * http://rpm.pbone.net: <br /> o python-docutils-0.4-2.el4.noarch.rpm <br /> <br /> or configure YUM and import from the DAG YUM repository. See the YoLinux SysAdmin Tutorial: YUM <br /> <br /> yum install -y trac <br /> <br />Red Hat EL5: manual installation from source (Red Hat Enterprise Linux 5 [Python 2.4, sqlite], Trac 0.11.5 example) <br /> <br /> Note: <br /> <br /> * Clearsilver web templates depricated, now uses Genshi. Trac 0.11.5 required to support Subversion 1.6.X. <br /> * 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 <br /> * RHEL5 package prerequisites: python, python-setuptools, httpd <br /> <br /> Installation: <br /> <br /> * Download: http://trac.edgewall.org/wiki/TracDownload <br /> * tar xzf Trac-0.11.5.tar.gz <br /> * cd Trac-0.11.5/ <br /> * List commands: python ./setup.py --help <br /> * Install: python ./setup.py install <br /> o This installs the Python template package Genshi <br /> o Installs Trac to /usr/lib/python2.4/site-packages/Trac-0.11.5-py2.4.egg/ <br /> o Installs commands (trac-admin, tracd): /usr/bin <br /> [Potential Pitfall]: If the Trac install fails to download and install Genshi, one can manually install it: <br /> o Download from: http://genshi.edgewall.org/wiki/Download <br /> (or wget http://ftp.edgewall.com/pub/genshi/Genshi-0.5.1.tar.gz) <br /> o tar xzf Genshi-0.5.1.tar.gz <br /> o cd Genshi-0.5.1/ <br /> o python setup.py install <br /> Then attempt to install Trac again: python ./setup.py install <br /> * Install CGI: cp cgi-bin/trac.cgi cgi-bin/trac.fcgi /var/www/cgi-bin <br /> Note: <br /> o Set environment variable (Trac 0.11+) in /etc/httpd/conf.d/trac.conf: <br /> SetEnv PYTHON_EGG_CACHE /srv/trac/projectX/egg_cache <br /> o Create the directory /srv/trac/projectX/egg_cache as it must be present even if not used. <br /> * Create new project repository: <br /> <br /> # trac-admin /srv/trac/projectX initenv <br /> Project Name [My Project]> projectX <br /> Database connection string [sqlite:db/trac.db]> <br /> Path to repository [/path/to/repos]> /srv/svn/projectX <br /> <br /> <br />Ubuntu: apt-get install trac <br /> <br />Allow Trac CGI to be executed (Two methods. Pick one.): <br /> <br /> 1. Copy the CGI to the default CGI bin directory: cp /usr/share/trac/cgi-bin/trac.cgi /var/www/cgi-bin <br /> OR <br /> 2. Enable Apache to execute the CGI: <br /> <br /> view source <br /> print? <br /> 1 .. <br /> 2 ScriptAlias /trac /usr/share/trac/cgi-bin/trac.cgi <br /> 3 .. <br /> <br />Note:The CGI trac.fcgi is for use with Apache Python module mod_fastcgi to improve performance. <br /> <br />As root: [root]# trac-admin /srv/trac/projectX initenv <br /> <br /> Project Name [My Project]> projectX <br /> Database connection string [sqlite:db/trac.db]> <br /> Path to repository [/var/svn/test]> /srv/svn/projectX <br /> Templates directory [/usr/share/trac/templates]> <br /> <br /> <br /> Note: <br /> <br /> * The directory /srv/trac MUST exist. <br /> * The directory /srv/trac/projectX MUST not exist before execution of command. <br /> <br /> Trac repository directories: <br /> <br /> * SuSE: /srv/trac/ <br /> * Red Hat: /usr/share/trac/proj_trac/ <br /> <br />This command will initialize the Trac data repository and create a directory structure and default configuration files. <br /> <br />Allow paths and files to be accessible by Apache: [root]# chown -R apache:apache /srv/trac/projectX <br /> <br />SELinux: <br /> <br /> * chcon -R -t httpd_sys_content_t /usr/share/trac/ <br /> * chcon -R -t httpd_sys_content_t /srv/trac/ <br /> <br />Component Home pages: <br /> <br /> * Trac <br /> * Clearsilver <br /> * Docutils <br /> * Python Imaging <br /> * pySQLite <br /> * SQLite.org <br /> <br />Trac Configuration: <br /> <br />File: /srv/trac/projectX/conf/trac.ini <br />(Created using the "trac-admin" command above and not provided by the RPM package.) <br /> <br /> Specify project URL: <br /> <br /> .. <br /> ... <br /> <br /> [trac] <br /> ... <br /> repository_dir = /srv/svn/projectX - This ties Trac to Subversion <br /> <br /> ... <br /> ... <br /> <br /> [notification] <br /> Set email and SMTP information here <br /> <br /> ... <br /> ... <br /> <br /> [project] <br /> url = http://projectX.com <br /> <br /> <br /> For more trac.ini configuration information see Trac: trac.ini configuration <br /> <br />[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. <br /> <br />Apache Web Server configuration file for Trac integration: <br /> <br />Trac can be run using the stand-alone Trac daemon "tracd". This configuration shows the use of Apache with Trac. <br /> <br />File: /etc/httpd/conf.d/trac.conf <br /> <br /> * This example performs no authentication: <br /> view source <br /> print? <br /> 1 Alias /trac/ "/usr/share/trac/htdocs/" <br /> 2 <Location "/cgi-bin/trac.cgi"> <br /> 3 SetEnv TRAC_ENV "/srv/trac/projectX" <br /> 4 </Location> <br /> or Red Hat Dag.Wieers.com rpm installation example: <br /> view source <br /> print? <br /> 1 ScriptAlias /trac /usr/share/trac/cgi-bin/trac.cgi <br /> 2 <Location "/trac"> <br /> 3 SetEnv TRAC_ENV "/srv/trac/projectX" <br /> 4 </Location> <br /> <br /> * This example authenticates logins internally using Apache. User logins and passwords have no connection to user accounts. <br /> view source <br /> print? <br /> 01 Alias /trac/ "/usr/share/trac/htdocs/" <br /> 02 <Location "/cgi-bin/trac.cgi"> <br /> 03 SetEnv TRAC_ENV "/srv/trac/projectX" <br /> 04 </Location> <br /> 05 <br /> 06 # The following enables the "login" link in Trac. <br /> 07 # (Top right hand corner) <br /> 08 <br /> 09 <Location "/cgi-bin/trac.cgi/login"> <br /> 10 AuthType Basic <br /> 11 AuthName "Project X Trac" <br /> 12 AuthUserFile /etc/httpd/conf/userpw <br /> 13 require valid-user <br /> 14 </Location> <br /> For more on Apache user file authentication see: <br /> o YoLinux Apache Authentication: User File Authenticated Logins <br /> <br /> * This example authenticates logins internally using Trac and Digest authentication. User logins and passwords have no connection to user accounts. <br /> view source <br /> print? <br /> 01 Alias /trac/ "/usr/share/trac/htdocs/" <br /> 02 <Location "/cgi-bin/trac.cgi"> <br /> 03 SetEnv TRAC_ENV "/srv/trac/projectX" <br /> 04 </Location> <br /> 05 <br /> 06 # The following enables the "login" link in Trac. <br /> 07 # (Top right hand corner) <br /> 08 <br /> 09 <Location "/cgi-bin/trac.cgi/login"> <br /> 10 AuthType Digest <br /> 11 AuthName "Project X Trac" <br /> 12 AuthDigestDomain /trac <br /> 13 AuthDigestFile /etc/httpd/conf/digestpw <br /> 14 require valid-user <br /> 15 </Location> <br /> For more on digest authentication see: <br /> o Apache.org: Module mod_auth_digest <br /> o RFC 2617 <br /> <br /> * 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) <br /> view source <br /> print? <br /> 01 Alias /trac/ "/usr/share/trac/htdocs/" <br /> 02 <Location "/cgi-bin/trac.cgi"> <br /> 03 SetEnv TRAC_ENV "/srv/trac/projectX" <br /> 04 AuthType Basic <br /> 05 AuthName "Project X Trac" <br /> 06 PerlAuthenHandler Apache::AuthenNIS <br /> 07 PerlSerVar AllowAlternateAuth no <br /> 08 require valid-user <br /> 09 </Location> <br /> 10 <br /> 11 # The following enables the "login" link in Trac. <br /> 12 # (Top right hand corner) <br /> 13 <br /> 14 <Location "/cgi-bin/trac.cgi/login"> <br /> 15 AuthType Basic <br /> 16 AuthName "Project X Trac" <br /> 17 PerlAuthenHandler Apache::AuthenNIS <br /> 18 PerlSerVar AllowAlternateAuth no <br /> 19 require valid-user <br /> 20 </Location> <br /> Auth configuration prohibits anonymous use of Trac <br /> <br /> This example is for RHEL4 with Apache httpd 2.0. <br /> <br />Restart Apache: service httpd restart <br /> <br />Also see YoLinux Apache authentication tutorial: LDAP, NIS, File. <br /> <br />Trac Administration: <br /> <br />Issue Trac commands as root: <br /> <br /> * Command line: trac-admin --help <br /> OR <br /> * Enter into Trac Admin shell: trac-admin /srv/trac/projectX <br /> Then type "help" to see list of commands. <br /> Use the command "quit" to exit the shell. <br /> <br />Set Permissions: <br /> <br /> * Grant administration privileges to a user: <br /> <br /> trac-admin /srv/trac/projectX permission add userid TRAC_ADMIN <br /> <br /> <br /> These permissions are required if using web interface to manage "roadmaps". <br /> * Show permissions: <br /> <br /> trac-admin /srv/trac/projectX permission list user-id <br /> <br /> * Remove write for anonymous users: <br /> <br /> trac-admin /srv/trac/projectX permission remove anonymous TICKET_CREATE TICKET_MODIFY WIKI_CREATE WIKI_MODIFY <br /> <br /> * Set default for authenticated users: <br /> <br /> trac-admin /srv/trac/projectX permission add authenticated TICKET_CREATE TICKET_MODIFY TICKET_VIEW WIKI_CREATE WIKI_MODIFY <br /> <br />Add components to be managed by Trac: <br /> <br /> * Roadmap/Product Milestones: <br /> o trac-admin /srv/trac/projectX milestone add name-of-milestone YYYY-MM-DD <br /> o trac-admin /srv/trac/projectX milestone completed name-of-milestone YYYY-MM-DD <br /> (Where "YYYY-MM-DD" is the due date or completion date. i.e. 2006-11-17) <br /> The milestones can be created using the web interface. <br /> * Software Components: trac-admin /srv/trac/projectX component add name-of-component owner-id <br /> <br />Defaults for "New Ticket": <br /> <br /> * Type: defect, enhancement, task <br /> View using the command: trac-admin /srv/trac/projectX ticket_type list <br /> Use "add" or "delete" to change the default. <br /> * Priority: blocker, critical, major, minor, trivial <br /> View using the command: trac-admin /srv/trac/projectX priority list <br /> Use "add" or "delete" to change the default. <br /> * Severity: highest, high, normal, low, lowest <br /> View using the command: trac-admin /srv/trac/projectX severity list <br /> Use "add" or "delete" to change the default. <br /> <br />Trac-Admin commands: trac-admin /path/to/projenv [command [subcommand] [option ...]] <br /> <br /> Command Description <br /> about Shows information about trac-admin <br /> help Show documentation <br /> initenv Create and initialize a new environment interactively <br /> initenv <projectname> <db> <repospath> <templatepath> Create and initialize a new environment from arguments <br /> hotcopy <backupdir> Make a hot backup copy of an environment <br /> resync Re-synchronize trac with the repository <br /> upgrade Upgrade database to current version <br /> wiki list List wiki pages <br /> wiki remove <name> Remove wiki page <br /> wiki export <page> [file] Export wiki page to file or stdout <br /> wiki import <page> [file] Import wiki page from file or stdin <br /> wiki dump <directory> Export all wiki pages to files named by title <br /> wiki load <directory> Import all wiki pages from directory <br /> wiki upgrade Upgrade default wiki pages to current version <br /> permission list [user] List permission rules <br /> permission add <user> <action> [action] [...] Add a new permission rule <br /> permission remove <user> <action> [action] [...] Remove permission rule <br /> component list Show available components <br /> component add <name> <owner> Add a new component <br /> component rename <name> <newname> Rename a component <br /> component remove <name> Remove/uninstall component <br /> component chown <name> <owner> Change component ownership <br /> ticket_type list Show possible ticket types <br /> ticket_type add <value> Add a ticket type <br /> ticket_type change <value> <newvalue> Change a ticket type <br /> ticket_type remove <value> Remove a ticket type <br /> ticket_type order <value> up|down Move a ticket type up or down in the list <br /> priority list Show possible ticket priorities <br /> priority add <value> Add a priority value option <br /> priority change <value> <newvalue> Change a priority value <br /> priority remove <value> Remove priority value <br /> priority order <value> up|down Move a priority value up or down in the list <br /> severity list Show possible ticket severities <br /> severity add <value> Add a severity value option <br /> severity change <value> <newvalue> Change a severity value <br /> severity remove <value> Remove severity value <br /> severity order <value> up|down Move a severity value up or down in the list <br /> version list Show versions <br /> version add <name> [time] Add version <br /> version rename <name> <newname> Rename version <br /> version time <name> <time> Set version date (Format: "YYYY-MM-DD" or "now") <br /> version remove <name> Remove version <br /> milestone list Show milestones <br /> milestone add <name> [due] Add milestone <br /> milestone rename <name> <newname> Rename milestone <br /> milestone due <name> <due> Set milestone due date (Format: "YYYY-MM-DD" or "now") <br /> milestone completed <name> <completed> Set milestone completed date (Format: "YYYY-MM-DD" or "now") <br /> milestone remove <name> Remove milestone <br /> Invoking trac-admin without command starts interactive mode. <br /> <br />Use the command trac-admin /srv/trac/projectX wiki list to view Wiki entries. <br /> <br />Trac Page Formatting: <br /> <br /> Display Trac/Wiki Format Code HTML Code Equivalent <br /> A forced line <br /> break. A forced line[[br]]break. A forced line<br>break. <br /> Bold text '''Bold text''' <b> </b> <br /> Italic text ''Italic text'' <i> </i> <br /> Bold italic text '''''Bold italic text''''' <b><i> </i></b> <br /> Underline __Underline__ <u> </u> <br /> Monospace text {{{Monospace text}}} <br /> or <br /> `Monospace text` <tt> </tt> <br /> strike-through ~~strike-through~~ <del> </del> <br /> Textsuperscript ^superscript^ <sup> </sup> <br /> Textsubscript ,,subscript,, <sub> </sub> <br /> ''' !''' <br /> The "!" escapes the Trac Wiki parser. <br /> Heading <br /> = Heading = Same as HTML "h1" <br /> Subheading <br /> == Subheading == Same as HTML "h2" <br /> Smaller subheading <br /> ===Smaller subheading=== Same as HTML "h3" <br /> Text line 1 <br /> Text line 2 Text line 1[[BR]]Text line 2 HTML line break <br> <br /> <br /> * List item one <br /> * List item two <br /> o Nested item <br /> <br /> <br /> <br /> * List item one <br /> * List item two <br /> * Nested item <br /> <br /> Note: A blank space must be present before the "*". <br /> HTML unordered list: <br /> <ul> <br /> <li>List item one</li> <br /> <li>List item two <br /> <ul> <br /> <li>Nested item</li> <br /> </ul></li> <br /> </ul> <br /> <br /> 1. List item one <br /> 1. Nested item <br /> 2. List item two <br /> 1. Nested item <br /> <br /> <br /> <br /> 1. List item one <br /> i. Nested item <br /> 2. List item two <br /> a Nested item <br /> <br /> Note: A blank space must be present before the list item: "1" <br /> HTML ordered list: <br /> <ol> <br /> <li>List item one <br /> <ol type="lower-roman"> <br /> <li>Nested item</li> <br /> </li> <br /> <li>List item two <br /> <ol type="lower-alpha"> <br /> <li>Nested item</li> <br /> </ol></li> <br /> </ol> <br /> Cell 1 Cell 2 Cell 3 <br /> Cell 4 Cell 5 Cell 6 <br /> <br /> <br /> ||Cell 1||Cell 2||Cell 3|| <br /> ||Cell 4||Cell 5||Cell 6|| <br /> <br /> <table border> <br /> <tr><td>Cell 1</td><td></td>Cell 2</td><td></td>Cell 3</td></tr> <br /> <tr><td>Cell 4</td><td></td>Cell 5</td><td></td>Cell 6</td></tr> <br /> </table> <br /> [[Image(http://URL-goes-here/images/image-file.gif)]] <br /> <br /> (URLs ending in .png, .gif or .jpg are interpreted as image links. See "Creating Wiki links" below) <br /> <img src="http://URL-goes-here/images/image-file.gif> <br /> For more information on Trac Wiki formatting, see WikiFormatting <br /> <br />Creating Wiki links: <br /> <br /> * Web URL: [http://URL-goes-here Link text goes here] <br /> (Traditional HTML link) <br /> * Create a link to a Trac Milestone: <br /> o milestone:1.2 <br /> o milestone:"Release maui" <br /> * Create link to Subversion for given revision changeset: <br /> o [subversion-revision-number-goes-here] <br /> o r207, r209 <br /> o changeset:207 <br /> Prefix the Subversion revision number with the letter "r" to have Wiki formatting create a link to the Subversion revision logs. <br /> * Create link to Subversion revision logs: <br /> o r3:5 <br /> o [3:5] <br /> o log:branches/version6.2-beta#3:5 <br /> Where "version6.2-beta" is the name of the branch for which logs are to be reported. <br /> * Create link to Trac ticket: <br /> o #ticket-number-goes-here <br /> o #45 <br /> Note: To escape the "#" without making it a link, prefix with a "!". i.e. !#45 will not generate a link. <br /> o ticket:45 <br /> * Create link to a specific file: <br /> o source:trunk/dira/dirb/file.cpp <br /> o source:"trunk/dira/dirb/file with spaces.cpp" <br /> (Files with spaces in the name should be encapsulated in quotes.) <br /> * Create link to a specific revision of a file: source:trunk/dira/dirb/file.cpp#207 <br /> * Create link to a report: <br /> o {report-number-goes-here} <br /> o report:report-number-goes-here <br /> * Create link to Wiki page: CamelCaseStringGoesHere <br /> This becomes a link to an HTML page of the same name. <br /> * Link to a Trac Wiki attachment: attachment:presentation.ppt <br /> <br />Use the command trac-admin /srv/trac/projectX wiki list to view Wiki entries. <br /> <br />The Trac SQL Database: <br /> <br />One can access the Trac SQLite database directly: <br /> <br /> Sample session: (response not included) <br /> <br /> [prompt]$ cd /srv/trac/projectX/db <br /> [prompt]$ sqlite trac.db <br /> sqlite> .help <br /> sqlite> .tables <br /> sqlite> .schema ticket <br /> sqlite> SELECT * FROM ticket; <br /> sqlite> .exit <br /> <br />Backup and restore: <br /> <br /> Dump database: <br /> <br /> [prompt]$ cd /srv/trac/projectX/db <br /> [prompt]$ sqlite trac.db <br /> sqlite> .outfile /tmp/trac.sql <br /> sqlite> .dump <br /> sqlite> .exit <br /> <br /> Load database: <br /> <br /> [prompt]$ cd /srv/trac/projectX/db <br /> [prompt]$ rm trac.db <br /> [prompt]$ sqlite trac.db <br /> sqlite> .read /tmp/trac.sql <br /> sqlite> .exit <br /> [prompt]$ trac-admin trac resync <br /> <br />Trac database schema <br /> <br />Database migration: (from /usr/share/trac/proj_trac/projectX/db) <br /> <br /> * Upgrade: sqlite trac.db .dump | sqlite3 tracV3.db <br /> Typically this would have to be accompanied with a Trac database and environment upgrade: <br /> <br /> trac-admin /usr/share/trac/proj_trac/projectX upgrade <br /> <br /> <br /> and a Trac wiki manual upgrade: <br /> <br /> trac-admin /usr/share/trac/proj_trac/projectX wiki upgrade <br /> <br /> * Downgrade: sqlite3 trac.db .dump | sqlite tracV2.db <br /> Typically this would have to be accompanied with a Trac database table downgrade: <br /> <br /> sqlite3 trac.db "update system set value=20 where name='2'" <br /> <br />Rename database to "trac.db" to be usable. <br /> <br />Trac User Registration: <br /> <br />Trac can assign new tickets (bugs/enhancements) to developers registered in the system. It can also communicate via email. To register, a user must login to Trac and: <br /> <br /> * Select the "Settings" link at the top right hand side of the web page. <br /> * Enter your name and email address. <br /> <br />Trac Upgrades: <br /> <br />After an upgrade to Trac, the configuration and data files you employ must also be upgraded. The RPM upgrades miss this so perform manually: <br /> <br /> trac-admin /srv/trac/projectX upgrade <br /> <br />Upgrading OS from RHEL4 to RHEL5: <br />This OS upgrade will upgrade the version of the embedded database package sqlite. The following must be performed for any OS upgrade which will also upgrade the Trac database environment. <br /> <br /> * Prior to the OS upgrade, dump the database to a text file: <br /> o cd /srv/trac/projectX/db <br /> o sqlite trac.db .dump > trac.dump_sqlite <br /> * Upgrade the OS <br /> * Import the database using the newer version of sqlite <br /> o cd /srv/trac/projectX/db <br /> o cat trac.dump_sqlite | sqlite3 trac.db <br /> Note that Trac requires the database name trac.db <br /> * Upgrade the trac repository: trac-admin /srv/trac/projectX upgrade <br /> * Upgrade wiki: trac-admin /srv/trac/projectX wiki upgrade <br /> * Synchronize Trac with Subversion: trac-admin /srv/trac/projectX resync <br /> This step is required when Subversion is upgraded (i.e. 1.4.2 to 1.6.9) <br /> <br />Trac Links: <br /> <br /> * Trac home page <br /> <br />Also see /usr/share/doc/trac-... for local documentation. <br /> <br />Trac plugins: <br /> <br />Trac plugins are available to enhance Trac functionality. The plugins require some Python infrastructure for installation. Install the Python package "setuptools" which includes command "easy_install". The following is an example for Red Hat Enterprise 4 / CentOS 4. Use one of the following two methods to install the command "/usr/bin/easy_install": <br /> <br /> 1. Python script: <br /> * Download the Python script http://peak.telecommunity.com/dist/ez_setup.py <br /> * Run: python ez_setup.py <br /> This will download and run the script: setuptools-0.6c6-py2.3.egg which installs "easy_install". <br /> 2. Egg script: <br /> * Download: http://cheeseshop.python.org/packages/2.4/s/setuptools/setuptools-0.6c6-py2.4.egg <br /> * As root: chmod +x setuptools-0.6c6-py2.3.egg <br /> * Run: ./setuptools-0.6c6-py2.3.egg <br /> <br />Trac "webadmin" plugin installation: <br /> <br />This will no longer be required with Trac version 0.10 or later as it will be integrated into the Trac. <br /> <br />Installation: <br /> <br /> * Use Subversion to download latest webadmin plugin software: <br /> <br /> svn export http://svn.edgewall.com/repos/trac/sandbox/webadmin/ <br /> <br /> This will create the directory webadmin/ and its contents. <br /> * cd webadmin <br /> * Install Trac plugin: easyinstall . <br /> <br />If installing from an egg file: <br /> <br /> * mv TracWebAdmin-0.1.2dev_r4240-py2.3.egg.zip TracWebAdmin-0.1.2dev_r4240-py2.3.egg <br /> * easy_install TracWebAdmin-0.1.2dev_r4240-py2.3.egg <br /> <br />Direct Trac to employ the component "webadmin". Add to end of file: /srv/trac/ProjectX/conf/trac.ini <br /> <br /> ... <br /> .. <br /> <br /> <br /> [components] <br /> webadmin.* = enabled <br /> <br />Apache configuration modification. File: /etc/httpd/conf.d/trac.conf <br /> <br /> view source <br /> print? <br /> 1 <Location "/trac"> <br /> 2 SetEnv TRAC_ENV "/srv/trac/projectX" <br /> 3 SetEnv PYTHON_EGG_CACHE /srv/trac/projectX/egg_cache <br /> 4 <br /> 5 ... <br /> 6 .. <br /> 7 </Location> <br /> <br />Create cache directory: <br /> <br /> * mkdir /srv/trac/ProjectX/egg_cache <br /> * chown apache.apache /srv/trac/ProjectX/egg_cache <br /> <br />Restart apache: service httpd restart <br /> <br />Test to see if plugin has been installed: python -c "import webadmin" <br />The proper response is no output. Error response: "ImportError: No module named webadmin" <br /> <br />The final step is to add the Trac administrator privileges: <br /> <br /> trac-admin /srv/trac/ProjectX permission add user1 TRAC_ADMIN <br /> <br />Users who have been given "TRAC_ADMIN" privileges, will see an extra tab in the Trac toolbar interface labeled "Admin". Select this tab to access the "webadmin" interface to Trac. This interface will allow you to create components, associate components with roadmaps, etc. <br /> <br />Documentation: <br /> <br /> * EasyInstall <br /> * setuptools <br /> <br />Hosting Multiple Subversion and Trac repositories: <br /> <br />SVN Hosting and Multiple Subversion Repositories with Apache: <br /> <br />One can have multiple Subversion repositories on one server. It is encouraged for separate projects. Subversion increments the revision number for each check-in in the repository and it makes the most logical sense to track revisions for a logically grouped set of applications or even a single application. If you want, you can even have a separate repository which links other projects in separate repositories and servers to look logically as one. (See Subversion property svn:externals) <br /> <br />Create repository locations: <br /> <br /> * svnadmin create --fs-type fsfs /srv/svn/reposX <br /> * svnadmin create --fs-type fsfs /srv/svn/reposY <br /> * svnadmin create --fs-type fsfs /srv/svn/reposZ <br /> * ... <br /> <br />Each repository would have a separate "Location" defined in the Apache configuration: <br /> <br /> view source <br /> print? <br /> 01 LoadModule dav_svn_module modules/mod_dav_svn.so <br /> 02 LoadModule authz_svn_module modules/mod_authz_svn.so <br /> 03 <br /> 04 <Location /reposX> <br /> 05 DAV svn <br /> 06 SVNPath /srv/svn/reposX <br /> 07 ... <br /> 08 .. <br /> 09 </Location> <br /> 10 <Location /reposY> <br /> 11 DAV svn <br /> 12 SVNPath /srv/svn/reposY <br /> 13 ... <br /> 14 .. <br /> 15 </Location> <br /> 16 <Location /reposZ> <br /> 17 DAV svn <br /> 18 SVNPath /srv/svn/reposZ <br /> 19 ... <br /> 20 .. <br /> 21 </Location> <br /> All the following URLs would be available: <br /> <br /> * http://yourdomain/reposX/ <br /> * http://yourdomain/reposY/ <br /> * http://yourdomain/reposZ/ <br /> <br /> or specify the "SVNParentPath": <br /> view source <br /> print? <br /> 1 LoadModule dav_svn_module modules/mod_dav_svn.so <br /> 2 LoadModule authz_svn_module modules/mod_authz_svn.so <br /> 3 <br /> 4 <Location /svn> <br /> 5 DAV svn <br /> 6 SVNParentPath /srv/svn <br /> 7 ... <br /> 8 .. <br /> 9 </Location> <br /> All the following URLs would be available: <br /> <br /> * http://yourdomain/svn/reposX/ <br /> * http://yourdomain/svn/reposY/ <br /> * http://yourdomain/svn/reposZ/ <br /> <br />Multiple Trac repositories: <br />Define a Trac parent directory under which you may locate multiple instances of Trac: <br /> <br /> view source <br /> print? <br /> 01 ScriptAlias /trac /usr/share/trac/cgi-bin/trac.cgi <br /> 02 <br /> 03 <Location "/trac"> <br /> 04 SetEnv TRAC_ENV_PARENT_DIR "/srv/trac/trac_projects" <br /> 05 AuthType Basic <br /> 06 AuthName "Trac" <br /> 07 AuthUserFile /srv/passwd/trac.htpasswd <br /> 08 Require valid-user <br /> 09 </Location> <br /> 10 <br /> 11 <LocationMatch "/trac/[^/]+/login"> <br /> 12 AuthType Basic <br /> 13 AuthName "Trac" <br /> 14 AuthUserFile /srv/passwd/trac.htpasswd <br /> 15 Require valid-user <br /> 16 </LocationMatch> <br /> <br /> Note: <br /> <br /> * All trac repositories reside under /srv/trac/trac_projects <br /> i.e. /srv/trac/trac_projects/projectX, /srv/trac/trac_projects/projectY, etc <br /> Web URL: http://server-name/trac/projectX <br /> * This example uses file authentication as defined in /etc/httpd/conf.d/subversion.conf <br /> view source <br /> print? <br /> 1 AccessFileName /srv/passwd/trac.htpasswd <br /> 2 <br /> 3 <Directory /srv/passwd> <br /> 4 Options -Indexes -FollowSymLinks <br /> 5 AllowOverride None <br /> 6 </Directory> <br /> <br />Trac and multiple Subversion repositories and Multiple Trac instances: <br />If using Trac with Subversion, you will be required to create separate Trac instances. Trac can use InterTrac Links to refer to resources of other Trac instances or servers, from within the Wiki markup. Trac can also have a global "trac.ini" file used for multiple instances of Trac. Also see: <br /> <br /> * Trac and Multiple Subversion Repositories <br /> * Configure Apache for multiple Trac projects <br /> * Hosting Multiple Projects <br /> * Access to multiple projects using mod_authz_svn.so <br /> <br />Proposals such as MultiTrac are not available. <br /> <br />Subversion Read-Only Access: <br /> <br />Repositories and directory branches can be configured as read-only. <br /> <br />Apache configuration to use granular Subversion rules: /etc/httpd/conf.d/subversion.conf <br /> <br /> view source <br /> print? <br /> 1 <Location /svn> <br /> 2 DAV svn <br /> 3 SVNParentPath /srv/svn <br /> 4 AuthzSVNAccessFile /srv/config/svn_granular_rules <br /> 5 ... <br /> 6 ... <br /> 7 </Location> <br /> The inclusion of the "AuthzSVNAccessFile" Apache module directive, directs granular access control to the file "/srv/config/svn_granular_rules". <br /> <br />Granular directory level access rules: /srv/config/svn_granular_rules <br /> <br /> [projectX:/tags] <br /> * = r <br /> userx = rw <br /> [projectX:/] <br /> * = rw <br /> [projectY:/] <br /> * = rw <br /> <br /> <br /> Once granular access control has been assigned to this control file, all projects must have access assignments or none will be granted by default. <br /> <br />This rule set enforces read-only access to the "tags" branch except for "userx" who has read and write access to the "tags" branch. All other repositories under the "SVNParentPath" must be listed. The "*" refers to all users. <br /> <br />SE-Linux configuration: <br /> <br />Of course it is easiest to turn off Security Enhanced Linux features by: <br /> <br /> * editing the file /etc/selinux/config, setting "SELINUX=disabled" and reboot <br /> OR <br /> * use the command "setenforce 0". <br /> <br />If using SELinux, you must set the context of the content accessed by the server: <br /> <br /> chcon -R -h -u system_u -r object_r -t httpd_sys_content_t /srv/svn /srv/trac <br /> <br />For more on SELinux see the YoLinux SysAdmin Tutorial <br /> <br />Repository Home Page: <br /> <br />The final touch is to create a homepage for your repositories so that they are easy to find, especially if you are hosting multiple reporitories. The default homepage for most major Linux distributions (Red Hat, Fedora, CentOS, Ubuntu, Debian) is /var/www/html/index.html Create a home page here or create a redirect to the Trac Wiki home page and post links there. <br /> <br />Redirect to the Trac Wiki <br /> <br /> <br /> <META HTTP-EQUIV="Refresh" Content="0; URL=/trac/"> <br /> <br />Sample home page: <br /> <br /> view source <br /> print? <br /> 01 <html> <br /> 02 <head> <br /> 03 <title>Welcome to Project X
04
05
06

Welcome to Project X


07
13
14

No comments: