See the more detailed HowTo Guide for Trac version 0.12.2 on Ubuntu Server 10.04 LTS.
https://nsrc.org/trac/01-HOWTO-Trac-0.12.2-Ubuntu-10.04.html
In addition, steps have been greatly shortened with less explanation in this document. For a more comprehensive explanation of each step please read the aforementioned HOWTO document.
$ sudo mkdir -p /var/www/trac/sample-project
$ sudo chown -R www-data.www-data /var/www/trac/*
Now to add your trac site as a virtual site in Apache: $ sudo editor /etc/apache2/conf.d/python.conf In this file add the following: <Location /wiki> SetHandler mod_python PythonHandler trac.web.modpython_frontend PythonOption TracEnv /var/www/trac/sample-project PythonOption TracUriRoot /trac/sample-project SetEnv PYTHON_EGG_CACHE /var/www/trac/sample-project/python-eggs </Location> Now we enable the new virtual site: $ sudo /etc/init.d/apache2 reload Or, if you prefer: $ sudo service apache2 reload Using trac-admin to Initialize a New Trac Project ------------------------------------------------- Next, we must initialize the trac project using the trac-admin facility. This will generate the initial Trac sqlite database and configure a default trac.ini configuration file. You will be asked several questions with lots of explanatory text. Here are the answers for each prompt you will see. If it says "[ENTER]", then just press ENTER and continue: $ sudo trac-admin /var/www/trac/sample-project Trac [/var/www/trac/sample-project> initenv Project Name [My Project]> WHATEVER YOU WANT Database connection string [sqlite:db/trac.db]> [ENTER] Trac [/var/www/trac/sample-project> quit You may see text on your screen detailing items as your new trac project is created. Once this is done we have several more things to do to fix permissions again and enable the changes: $ sudo chown -R www-data:www-data /var/www/trac/sample-project/* Customing the trac.ini File --------------------------- To customize your Trac site you'll need to edit the Trac main configuration file for this particular project (we use vi, you can choose your favorite editor): $ sudo editor /var/www/trac/sample-project/conf/trac.ini trac.ini -------- There are many things you can change, add, or delete in the trac.ini file. For full details read the Trac project pages here: http://trac.edgewall.org/wiki/TracIni We will make minimal updates to get our project up and running, including with the Account Manager system. First, create the "[account-manager]" section like this at the top of the file. Leave in the first line of the file that says, "# -*- coding: utf-8 -*-": [account-manager] password_file = /var/www/trac/sample-project/.htpasswd account_changes_notify_addresses = user@domain password_format = htpasswd password_store = HtPasswdStore If you want (for example) to remove file size limits on uploads you can do: [attachment] max_size = -1 render_unsafe_content = false Now tell Trac about the Account Manager plug-in and how you want to use it. [components] acct_mgr.admin.accountmanageradminpage = enabled acct_mgr.api.accountmanager = enabled acct_mgr.db.sessionstore = enabled acct_mgr.htfile.htpasswdstore = enabled acct_mgr.web_ui.accountmodule = enabled acct_mgr.web_ui.loginmodule = enabled acct_mgr.web_ui.registrationmodule = enabled trac.web.auth.loginmodule = disabled NOTE! Once you are finished with the Trac project, or if your project is in use for a long period you should disable the ability to register accounts as Spammers will create accounts and update your pages over time. This is the following setting in the [Components] section: acct_mgr.web_ui.registrationmodule = enabled You should eventually change this to: acct_mgr.web_ui.registrationmodule = disabled This will remove the "Register" button from the login page. To specify your own logo to appear at the top of each Trac page create the logo image file and place it here: /var/www/trac/sample-project/htdocs "htdocs" = "site" and "common" in the trac.ini file. Below is a sample: [header_logo] alt = Sample Project height = 55 link = http://example.host/trac/sample-project/ src = site/project-logo.png width = 220 Finally, you can customize several items as they appear on your Trac project pages. Here is an example of this: [project] admin = admin_trac_url = . descr = Sample Trac Project footer = Sample Trac Project admin@example.host icon = common/favicon.ico name = Sample Trac Project url = http://example.host/trac/sample-project/ Note the "icon" setting. If your site has a favorite icon setting this is how you can specify that Trac use it instead of the default Trac icon. The "common" refers to the directory "htdocs". Setting Initial User Permissions for Your New Project ----------------------------------------------------- Now, from the command line you can use the trac-admin tool to set permissions. Here are some suggested sets of permissions For our purposes the default anonymous settings are too liberal. In some cases you may even wish to remove the "WIKI_VIEW" permissions from the anonymous permission set if you don't want your Trac project's wiki to be visible without first logging in. The following creates a more restricted anonymous user set of permissions (remember that "\" means the command should really be on a single line): $ trac-admin /var/www/trac/sample-project Trac [/var...> permission remove anonymous MILESTONE_VIEW REPORT_SQL_VIEW \ REPORT_VIEW ROADMAP_VIEW SEARCH_VIEW TICKET_VIEW TIMELINE_VIEW This leaves the anonymous user with BROWSER_VIEW, FILE_VIEW, LOG_VIEW, CHANGESET_VIEW and WIKI_VIEW permissions. If you do the above, then you need to give back a number of permissions to authenticated users. Here is one suggested way to do this (we, also grant the MILESTONE_MODIFY permission): Trac [/var...> permission add authenticated MILESTONE_VIEW MILESTONE_MODIFY \ REPORT_SQL_VIEW REPORT_VIEW ROADMAP_VIEW SEARCH_VIEW TICKET_VIEW \ TIMELINE_VIEW For a full discussion of what all these permissions mean you can view the online Trac pages discussing permissions at: http://trac.edgewall.org/wiki/TracPermissions This, also, discusses using the "Admin" option from within the Trac user interface for any user granted "TRAC_ADMIN" rights (TRAC_ADMIN = ALL PERMISSIONS). Now you can create a user who has "authenticated" privileges like this: Trac [/var...> permission add <username> authenticated And, a user who has "all" privileges like this: Trac [/var...> permission add admin TRAC_ADMIN Creating Initial Trac users --------------------------- Last, but not least, you must actually create the users "admin" and <username> and give them passwords using the htpasswd facility: $ sudo htpasswd -c /var/www/trac/sample-project/.htpasswd admim $ sudo htpasswd /var/www//trac/sample-project/.htpasswd <username> At this point you are done setting up trac. You can now look at the results of your work by going to: http://localhost/trac/sample-project By default you will see your trac project as an anonymous user. You can log in as "username" to see how things look as an authenticated user and then as "admin" to see things as a TRAC-ADMIN user. A much more complete discussion of these steps is available in the more detailed HOWTO located at: https://nsrc.org/trac/01-HOWTO-Trac-0.12.2-Ubuntu-10.04.html ------------------------------------------------------------------------------ Last update 24 May. 2011 by Hervey Allen for nsrc.org (hervey(at)nsrc(dot)org4 </pre>