Trac Repositories

=Intro=

Trac is a nice enhanced wiki and ticket management system that hooks with a project's SVN as well. It's structure is is a lot like SVN. Each project has it's own trac interface.

=Connection=

The Trac Projects are viewed through your web browser. There might be user authentication.

=Creating a Trac Project=

The steps:
 * Create an SVN repository
 * Create a MySQL database/account for the Trac Environment
 * Create a Trac Environment & Bind Trac with SVN
 * Bind Trac+SVN to Apache

Step 1 - Create an SVN Repository
This can be found in the SVN Repositories Section.

Step 2 - Create a MySQL database/account for the Trac Environment
Simply, connect to MySQL and create a database for your new environment. Please note that i'm using the database name xushitrac as an example. Use your own. Also, change the username and password to something less obvious :) Keep the information handy for the next step.

create database xushitrac; grant all on xushitrac.* to admin@localhost identified by 'admin'; flush privileges;

Step 3 - Create a Trac Environment
Step 3 is to create the environment.. All environments are found in /trac/. To add one, for example, called xushitopia, create it with:

trac-admin /trac/xushitopia initenv

You will be presented with a few installation questions. Just follow them as shown.

Creating a new Trac environment at /trac/xushitopia

Trac will first ask a few questions about your environment in order to initalize and prepare the project database.

Please enter the name of your project. This name will be used in page titles and descriptions.

Project Name [My Project]>

Enter whatever for project name. For example Xushi Project.

Please specify the connection string for the database to use. By default, a local SQLite database is created in the environment directory. It is also possible to use an already existing PostgreSQL database (check the Trac documentation for the exact connection string syntax).

Database connection string [sqlite:db/trac.db]>

The syntax is as follows: mysql://username:password@localhost:3306/projectname. In our case, it's mysql://admin:admin@localhost:3306/xushitrac.

Please specify the type of version control system, By default, it will be svn.

If you don't want to use Trac with version control integration, choose the default here and don't specify a repository directory. in the next question.

Repository type [svn]>

Leave as default, just press Enter.

Please specify the absolute path to the version control repository, or leave it blank to use Trac without a repository. You can also set the repository location later.

Path to repository [/path/to/repos]>

Enter the path to the SVN repository you created in Step 1. Assuming it's called xushitopia, then enter /svn/xushitopia

Please enter location of Trac page templates. Default is the location of the site-wide templates installed with Trac.

Templates directory [/usr/share/trac/templates]>

Leave as default. Just press Enter.

Finally, you should see some output as so, Creating and Initializing Project Installing default wiki pages /usr/share/trac/wiki-default/TracRss => TracRss /usr/share/trac/wiki-default/WikiRestructuredTextLinks => WikiRestructuredTextLinks /usr/share/trac/wiki-default/WikiMacros => WikiMacros /usr/share/trac/wiki-default/TracRevisionLog => TracRevisionLog /usr/share/trac/wiki-default/TracSearch => TracSearch /usr/share/trac/wiki-default/InterMapTxt => InterMapTxt /usr/share/trac/wiki-default/InterWiki => InterWiki /usr/share/trac/wiki-default/TracImport => TracImport /usr/share/trac/wiki-default/TracLogging => TracLogging /usr/share/trac/wiki-default/InterTrac => InterTrac /usr/share/trac/wiki-default/TracCgi => TracCgi /usr/share/trac/wiki-default/WikiStart => WikiStart /usr/share/trac/wiki-default/WikiProcessors => WikiProcessors /usr/share/trac/wiki-default/TracIni => TracIni /usr/share/trac/wiki-default/WikiFormatting => WikiFormatting /usr/share/trac/wiki-default/TracStandalone => TracStandalone /usr/lib/python2.4/site-packages/trac/db/util.py:50: Warning: Data truncated for column 'text' at row 1 return self.cursor.execute(sql_escape_percent(sql), args) /usr/share/trac/wiki-default/TracReports => TracReports /usr/share/trac/wiki-default/TracAccessibility => TracAccessibility /usr/share/trac/wiki-default/TracPermissions => TracPermissions /usr/share/trac/wiki-default/TracNotification => TracNotification /usr/share/trac/wiki-default/WikiNewPage => WikiNewPage /usr/share/trac/wiki-default/TracUpgrade => TracUpgrade /usr/share/trac/wiki-default/TitleIndex => TitleIndex /usr/share/trac/wiki-default/RecentChanges => RecentChanges /usr/share/trac/wiki-default/TracTickets => TracTickets /usr/share/trac/wiki-default/CamelCase => CamelCase /usr/share/trac/wiki-default/TracTicketsCustomFields => TracTicketsCustomFields /usr/share/trac/wiki-default/TracRoadmap => TracRoadmap /usr/share/trac/wiki-default/TracQuery => TracQuery /usr/share/trac/wiki-default/TracLinks => TracLinks /usr/share/trac/wiki-default/TracGuide => TracGuide /usr/share/trac/wiki-default/WikiPageNames => WikiPageNames /usr/share/trac/wiki-default/TracBackup => TracBackup /usr/share/trac/wiki-default/TracInterfaceCustomization => TracInterfaceCustomization /usr/share/trac/wiki-default/TracSyntaxColoring => TracSyntaxColoring /usr/share/trac/wiki-default/TracBrowser => TracBrowser /usr/share/trac/wiki-default/TracEnvironment => TracEnvironment /usr/share/trac/wiki-default/TracSupport => TracSupport /usr/share/trac/wiki-default/WikiRestructuredText => WikiRestructuredText /usr/share/trac/wiki-default/TracUnicode => TracUnicode /usr/share/trac/wiki-default/TracPlugins => TracPlugins /usr/share/trac/wiki-default/SandBox => SandBox /usr/share/trac/wiki-default/TracFastCgi => TracFastCgi /usr/share/trac/wiki-default/TracTimeline => TracTimeline /usr/share/trac/wiki-default/TracInstall => TracInstall /usr/share/trac/wiki-default/WikiHtml => WikiHtml /usr/share/trac/wiki-default/TracWiki => TracWiki /usr/share/trac/wiki-default/TracChangeset => TracChangeset /usr/share/trac/wiki-default/TracAdmin => TracAdmin /usr/share/trac/wiki-default/WikiDeletePage => WikiDeletePage /usr/share/trac/wiki-default/TracModPython => TracModPython

Warning:

You should install the SVN bindings

- Project environment for 'Xushi Project' created.

You may now configure the environment by editing the file:

/trac/xushitopia/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 /trac/xushitopia

Then point your browser to http://localhost:8000/xushitopia. There you can also browse the documentation for your installed version of Trac, including information on further setup (such as deploying Trac to a real web server).

The latest documentation can also always be found on the project website:

http://trac.edgewall.org/

Congratulations!

This is successful. You can even test your new environment by running the trac daemon as said.

IMPORTANT: If anything failed by mistake, or if you aborted the installation, make sure to both empty the database and to delete the half-created environment from /trac/ before you start over again.

Step 4 - Bind TRAC+SVN to Apache
Unlike anything else we added to Apache, this is a bit tricky. Trac is python based, and not PHP based. There are 3 ways to let it work through Apache.


 * CGI
 * FastCGI
 * mod_python

The top two are crap. We'll be using mod_python. Now i've done all the hard work. All you need to do is just to attach Trac to a virtual host. Below is an example of a VirtualHost that works for me. Let's hope it works for you too :) It all depends on how you create virtual hosts.. If anything, just look at the way it's done, and try to implement it in your virtual host.

Edit /etc/httpd/conf/vhosts.conf and add the bottom vhost modifying it to your project. Do NOT change the DocumentRoot

 ServerName xushitopia.mysite.local
 * 1) if you want it to be accessed internally

DocumentRoot /usr/share/trac/htdocs/

 SetHandler mod_python PythonInterpreter main_interpreter PythonHandler trac.web.modpython_frontend PythonOption TracEnv /trac/xushitopia PythonOption TracUriRoot /   AuthType Basic AuthName "MyCompany Trac Server" AuthUserFile /trac/conf/trac.htpasswd Require valid-user  

 ServerName xushitopia.mysite.com
 * 1) if you want it to be accessed externally

DocumentRoot /usr/share/trac/htdocs/  SetHandler mod_python PythonInterpreter main_interpreter PythonHandler trac.web.modpython_frontend PythonOption TracEnv /trac/xushitopia PythonOption TracUriRoot /   AuthType Basic AuthName "MyCompany Trac Server" AuthUserFile /trac/conf/trac.htpasswd Require valid-user  

Please note to change any names and paths above if needed. Also, notice the /trac/conf/trac.htpasswd for passwords too.

Finally, restart apache /etc/init.d/httpd restart

Step 5 - Creating and Managing Users
TBA - Haven't finished this part yet.. sorry.

That's it. You should be done now.