Trac
From Apis Networks Wiki
Installing Trac
- From Version Control in esprit choose the option to "Install Trac", this will decompress the pre-built binaries taking up roughly 59 MB of disk space. Trac and its dependencies will be installed under
/usr/local/. - Either create or import an existing Subversion repository
- Setup an initial Trac environment. This can be accomplished by running
trac-admin somepath initenv
Example
bash-2.05b$ trac-admin /home/msaladna/trac initenv Project Name [My Project]> My Happy Project Database connection string [sqlite:db/trac.db]> Path to repository [/var/svn/test]> /usr/local/svn Templates directory [/usr/local/share/trac/templates]> Creating and Initializing Project Configuring Project trac.repository_dir trac.database trac.templates_dir project.name Installing default wiki pages ... Indexing repository --------------------------------------------------------------------- Project environment for 'My Project' created. You may now configure the environment by editing the file: /home/msaladna/trac/conf/trac.ini If you'd like to take this new project environment for a test drive, try running the Trac standalone web server `tracd`: tracd --port 8000 /home/msaladna/trac ... Congratulations!
- Select a location for Trac to operate. Remember it's bound by the suexec rules, so be careful on the location! It's also a good idea to use a subdomain to house Trac like
http://trac.mydomain.com/. We will be assigningtrac.mydomain.comto/var/www/html/trac, but the subdomain location could be anywhere like/var/www/tracor/usr/local/trac. - Make a hard link (or a copy) of
/usr/local/share/trac/cgi-bin/trac.fcgito the Trac document root, e.g.:ln -f /usr/local/share/trac/cgi-bin/trac.fcgi /var/www/html/trac/
- You can alternatively go with the CGI version (
trac.cgi) of Trac, although FastCGI (trac.fcgi) is strongly recommended, just replace .fcgi with .cgi
- You can alternatively go with the CGI version (
- We will need to hardcode the Trac path into trac.fcgi as the Apache -> FastCGI environment variable pass-off doesn't work correctly with Trac.
- If you're using
trac.cgi(not recommended), create a file called.htaccessunder the Trac. Inside the file put:SetEnv TRAC_ENV "/home/msaladna/trac" - For FastCGI, edit trac.fcgi and add the following, right below the comments:
- If you're using
import os os.environ['TRAC_ENV'] = "trac path"
Example
# history and logs, available at http://projects.edgewall.com/trac/. # # Author: Jonas Borgström <jonas@edgewall.com> import os os.environ['TRAC_ENV'] = "/home/msaladna/trac" try:
- Make a symbolic link for
/usr/local/share/trac/htdocs/in the Trac document root and name the symbolic linkpublic(used later in thehtdocs_locationdirective).Examplecd /var/www/html/trac/ && ln -s ../../../../usr/local/share/trac/htdocs/ public
- Use a relative path when making the symbolic link, NOT absolute link.
- Correct: ln -s ../../
- Incorrect: ln -s /usr/local/
- Edit the
conf/trac.inifile under the Trac path created by thetrac-admin initenvcomand and addhtdocs_location = /publicafter[trac].
Example
log_level = DEBUG log_type = none [trac] htdocs_location = /public default_charset = iso-8859-15 ignore_auth_case = false permission_store = DefaultPermissionStore
- Finally add the following to the .htaccess file where
trac.fcgiresides.
DirectoryIndex trac.fcgi RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /trac.fcgi [L,QSA]
- Access the URL and Trac should be setup!
Implementing Simple Authentication
Simple authentication can be done through use of Apache's auth_mod.
- Create the password file outside of the document tree using the command
htpasswd -c DesiredPasswdFilename DesiredUserName, this is a human readable file which contains the username and a hashed password. Note:htpasswdis in /usr/sbin/, so in order to use it you must explicitly name the path:/usr/sbin/htpasswd - Apache must now be configured to allow access only to users who can be authenticated against the password file. Edit the
.htaccessfile wheretrac.fcgiresides and add the following statements
Example
AuthType Basic AuthName "Log in to access the trac system" AuthUserFile /home/virtual/<YOUR DOMAIN NAME>/home/trac/trac.passwd Require valid-user
- Permissions for the password file must now be altered:
chmod 755 PasswdFile - Extra users may be added to the password file by using
htpasswd PasswdFilename NewUser
