|Version 10 (modified by 10 years ago) ( diff ),|
Trac stable0.11 does not work on Feisty because the stock Feisty mod_python is version 2.2, and mod_python 2.3 is required by Trac 0.11.
trac on Ubuntu 7.04 Server, with mod_python, multiple repositories and authentication
This guide shows all the steps to correctly install a trac system on a Ubuntu 7.04 Server. Please feel free to contact me (Luis) at any time with corrections or sugestions. This guide will be constantly updated but you see the original on the madlabs page.
This guide focuses on several things that I missed throughout the documentation, both official and unofficial:
- Everything configured from scratch with authentication, multiple repositories and mod_python
- Not losing time explaining the decisions here. This is specifically to have multiple repositories, authentication and mod_python on Ubuntu. I never fork() the guide to give other possibilities
- I think the guide is pretty complete. After following the instructions here, my next step was to update my subversion reposity with all my projects and continue on creating users and project environments. The esential is completely covered here
- And if you're using a fresh installation of Feisty Fawn and follow these instructions strictly, it will all be finished within 5 minutes!!!
Enjoy and comment!
- The first step is to install Apache.
$ sudo apt-get install apache2
apt-get configures everything you need and your webroot will be configured to
/var/www. Ubuntu (actually, Debian) divides apache websites (virtualhost) in a set of directories under
/etc/apache2/sites-availableand has two utilities to configure them:
a2dissite. We'll make use of these tools throughout this guide.
The idea with our subversion installation is to have a main directory and several repositories under it. We'll be setting
/svn as our subversion parent dir and then create
/svn/project2, etc as needed. This second step will configure subversion, set apache to use mod_dav_svn and enable Basic authentication.
- We start by apt-getting the packages
$ sudo apt-get install subversion libapache2-svn
- We'll now configure
mod_dav_svn. We start by editing
$ sudo vim /etc/apache2/mods-enabled/dav_svn.conf
This file probably has already a set of directives in it. I just show here the final version without the comments and changed to enable Basic authentication:
<Location /svn/> DAV svn SVNParentPath /svn #Provides dirctory listing of repositories SVNListParentPath On AuthType Basic AuthName "Subversion Repository" AuthUserFile /etc/apache2/dav_svn.passwd AuthzSVNAccessFile /etc/apache2/authz_svn.access Require valid-user </Location>
- The next step is to create a user for subversion.
$ sudo htpasswd -cm /etc/apache2/dav_svn.passwd luis New password: my_password Re-type new password: my_password
- Additionally we'll create the authorization file for our users
$ sudo vim /etc/apache2/authz_svn.access
- And add the following rule for our user. In this case, we'll be allowing him full access to the
[teste:/] luis = rw
- Finally we restart apache.
$ sudo apache2ctl restart
- Our next task is to create the subversion parent dir and a repository, and add a dummy project to it:
$ sudo mkdir /svn $ sudo svnadmin create /svn/teste $ sudo mkdir /tmp/teste $ sudo mkdir /tmp/teste/branches $ sudo mkdir /tmp/teste/tags $ sudo mkdir /tmp/teste/trunks $ sudo chmod -R 777 /svn $ sudo chown -R www-data:www-data /svn $ sudo svn import /tmp/teste http://localhost/svn/teste -m "initial import" --username luis $ sudo rm -rf /tmp/teste
We can now point a browser to http://localhost/svn/teste and an authentication pop-up should appear and, after that, our repository. You should also be able to navigate to http://localhost/svn/ and view a listing of all repositories. Now is a good time to read some more on the "Per-Directory Access Control" part of the subversion book. One part of the security involved in this installation only has to do with Subversion so some reading on Per-Directory Access Control might be useful at this time.
Let's now head for the installation of the trac system. For trac to work we'll be needing python and a number of other packages. Then we'll have to create a trac environment for each repository we want trac to serve.
- Let's start with apt-getting the needed packages
$ sudo apt-get install trac libapache2-svn libapache2-mod-python libapache2-mod-python-doc
- trac needs a directory to put the environments on where apache can read/write. We'll also add a symlink to this directory so it's easier to get there:
$ sudo mkdir /var/lib/trac $ sudo chown -R www-data:www-data /var/lib/trac $ sudo ln -s /var/lib/trac/ /trac
- Now we need another site for apache:
$ sudo vim /etc/apache2/sites-available/trac
- And add the following code to it:
<Location /trac> SetHandler mod_python PythonInterpreter main_interpreter PythonHandler trac.web.modpython_frontend PythonOption TracEnvParentDir /var/lib/trac PythonOption TracUriRoot /trac </Location> <LocationMatch "/trac/[^/]+/login"> AuthType Basic AuthName "Trac" AuthUserFile /etc/apache2/dav_svn.passwd Require valid-user </LocationMatch>
- Let's now enable this site:
$ sudo a2ensite trac Site trac installed; run /etc/init.d/apache2 reload to enable. $ sudo /etc/init.d/apache2 reload Reloading web server config... [ OK ]
- The final step is to initialize the trac environment for our project. The only thing I had to fill in here was the name of my project and the path to my subversion repository:
$ sudo trac-admin /trac/teste initenv Creating a new Trac environment at /trac/teste Trac will first ask a few questions about your environment in order to initialize 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]> O Teste Final 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]> 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]> 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]> /svn/teste 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]> Creating and Initializing Project Installing default wiki pages /usr/share/trac/wiki-default/TracTicketsCustomFields => TracTicketsCustomFields /usr/share/trac/wiki-default/WikiPageNames => WikiPageNames /usr/share/trac/wiki-default/TracUnicode => TracUnicode /usr/share/trac/wiki-default/TracChangeset => TracChangeset /usr/share/trac/wiki-default/TracTickets => TracTickets /usr/share/trac/wiki-default/WikiStart => WikiStart /usr/share/trac/wiki-default/WikiFormatting => WikiFormatting /usr/share/trac/wiki-default/TracQuery => TracQuery /usr/share/trac/wiki-default/InterMapTxt => InterMapTxt /usr/share/trac/wiki-default/InterWiki => InterWiki /usr/share/trac/wiki-default/TracAdmin => TracAdmin /usr/share/trac/wiki-default/TracLinks => TracLinks /usr/share/trac/wiki-default/TracModPython => TracModPython /usr/share/trac/wiki-default/TracEnvironment => TracEnvironment /usr/share/trac/wiki-default/WikiRestructuredText => WikiRestructuredText /usr/share/trac/wiki-default/TracInstall => TracInstall /usr/share/trac/wiki-default/WikiDeletePage => WikiDeletePage /usr/share/trac/wiki-default/CamelCase => CamelCase /usr/share/trac/wiki-default/TracAccessibility => TracAccessibility /usr/share/trac/wiki-default/TracTimeline => TracTimeline /usr/share/trac/wiki-default/TracReports => TracReports /usr/share/trac/wiki-default/TracWiki => TracWiki /usr/share/trac/wiki-default/TracRoadmap => TracRoadmap /usr/share/trac/wiki-default/WikiProcessors => WikiProcessors /usr/share/trac/wiki-default/TracSearch => TracSearch /usr/share/trac/wiki-default/WikiHtml => WikiHtml /usr/share/trac/wiki-default/TracIni => TracIni /usr/share/trac/wiki-default/WikiRestructuredTextLinks => WikiRestructuredTextLinks /usr/share/trac/wiki-default/RecentChanges => RecentChanges /usr/share/trac/wiki-default/TracNotification => TracNotification /usr/share/trac/wiki-default/TracBackup => TracBackup /usr/share/trac/wiki-default/TracPermissions => TracPermissions /usr/share/trac/wiki-default/TracBrowser => TracBrowser /usr/share/trac/wiki-default/SandBox => SandBox /usr/share/trac/wiki-default/InterTrac => InterTrac /usr/share/trac/wiki-default/WikiNewPage => WikiNewPage /usr/share/trac/wiki-default/TracInterfaceCustomization => TracInterfaceCustomization /usr/share/trac/wiki-default/TracSyntaxColoring => TracSyntaxColoring /usr/share/trac/wiki-default/TracPlugins => TracPlugins /usr/share/trac/wiki-default/TracUpgrade => TracUpgrade /usr/share/trac/wiki-default/TracSupport => TracSupport /usr/share/trac/wiki-default/WikiMacros => WikiMacros /usr/share/trac/wiki-default/TracImport => TracImport /usr/share/trac/wiki-default/TracLogging => TracLogging /usr/share/trac/wiki-default/TracGuide => TracGuide /usr/share/trac/wiki-default/TracRevisionLog => TracRevisionLog /usr/share/trac/wiki-default/TracFastCgi => TracFastCgi /usr/share/trac/wiki-default/TracCgi => TracCgi /usr/share/trac/wiki-default/TracRss => TracRss /usr/share/trac/wiki-default/TracStandalone => TracStandalone /usr/share/trac/wiki-default/TitleIndex => TitleIndex Indexing repository --------------------------------------------------------------------- Project environment for 'O Teste final' created. You may now configure the environment by editing the file: /var/lib/trac/teste/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 /var/lib/trac/teste Then point your browser to http://localhost:8000/teste. 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!
At this point we still have to reset the ownership of the repository to the www-data user so that the database file can be accessed. Also, it's always a good idea to restart apache, just in case…
$ sudo chown -R www-data:www-data /var/lib/trac $ sudo apache2ctl restart
- At this point we are still without any authentication. We'll start by removing permissions to the anonymous user, allowing him only to see the initial page. Then we'll also set our main user as the trac's root:
$ sudo trac-admin /trac/teste permission remove anonymous BROWSER_VIEW CHANGESET_VIEW FILE_VIEW LOG_VIEW MILESTONE_VIEW REPORT_SQL_VIEW REPORT_VIEW ROADMAP_VIEW SEARCH_VIEW TICKET_CREATE TICKET_MODIFY TICKET_VIEW TIMELINE_VIEW WIKI_CREATE WIKI_MODIFY $ sudo trac-admin /trac/teste permission add luis TRAC_ADMIN
- You can now check http://localhost/trac and you should see a list with all the projects for which you have a trac environment set. clicking on one of them will get you to a page where you could have a small description of your project but you won't see any ather links (important ones at least). Try to login to see the differences.