trac 是一個用 Python 編寫的相當好的 Issue trace 工具。提供了如下的功能:
-
增強的 Wiki
-
Issue Trace
-
Bugs 報告
-
項目任務(wù)
-
性能要求
-
Timeline 功能
-
Subversion 倉庫瀏覽
-
更改源碼
-
與 Web 服務(wù)器配合,使用 CGI 或 FastCGI 或 mod_python 配置
-
tracd:獨立服務(wù)器
sudo apt-get install trac python-docutils libapache2-mod-python python2.4-clearsilver sqlite3 python2.4-pysqlite2
S1. 創(chuàng)建環(huán)境
sudo mkdir /home/trac sudo trac-admin /home/trac/myproject initenv Creating a new Trac environment at /home/trac/myproject
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]> myproject # 輸入項目名稱
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]> # 使用默認的 SQLite 數(shù)據(jù)庫,直接回車即可
Please specify the absolute path to the project Subversion repository. Repository must be local, and trac-admin requires read+write permission to initialize the Trac database.
Path to repository [/var/svn/test]> /home/svn/repository1 # 輸入 Subversion 倉庫的路徑
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]> # 使用默認的 Trac page templates,直接回車即可
Creating and Initializing Project Configuring Project trac.repository_dir trac.database trac.templates_dir project.name Installing default wiki pages /usr/share/trac/wiki-default/TracReports => TracReports /usr/share/trac/wiki-default/TracModPython => TracModPython /usr/share/trac/wiki-default/TracNotification => TracNotification /usr/share/trac/wiki-default/RecentChanges => RecentChanges /usr/share/trac/wiki-default/TracRoadmap => TracRoadmap /usr/share/trac/wiki-default/WikiDeletePage => WikiDeletePage /usr/share/trac/wiki-default/TracChangeset => TracChangeset /usr/share/trac/wiki-default/TracEnvironment => TracEnvironment /usr/share/trac/wiki-default/TracFastCgi => TracFastCgi /usr/share/trac/wiki-default/WikiMacros => WikiMacros /usr/share/trac/wiki-default/TracLogging => TracLogging /usr/share/trac/wiki-default/TracAccessibility => TracAccessibility /usr/share/trac/wiki-default/TracTicketsCustomFields => TracTicketsCustomFields /usr/share/trac/wiki-default/WikiHtml => WikiHtml /usr/share/trac/wiki-default/WikiStart => WikiStart /usr/share/trac/wiki-default/WikiPageNames => WikiPageNames /usr/share/trac/wiki-default/WikiRestructuredText => WikiRestructuredText /usr/share/trac/wiki-default/CamelCase => CamelCase /usr/share/trac/wiki-default/TracTickets => TracTickets /usr/share/trac/wiki-default/TracSupport => TracSupport /usr/share/trac/wiki-default/TracStandalone => TracStandalone /usr/share/trac/wiki-default/TracInterfaceCustomization => TracInterfaceCustomization /usr/share/trac/wiki-default/TracAdmin => TracAdmin /usr/share/trac/wiki-default/SandBox => SandBox /usr/share/trac/wiki-default/TracGuide => TracGuide /usr/share/trac/wiki-default/TracLinks => TracLinks /usr/share/trac/wiki-default/TracQuery => TracQuery /usr/share/trac/wiki-default/TracUnicode => TracUnicode /usr/share/trac/wiki-default/TracUpgrade => TracUpgrade /usr/share/trac/wiki-default/WikiNewPage => WikiNewPage /usr/share/trac/wiki-default/TitleIndex => TitleIndex /usr/share/trac/wiki-default/TracWiki => TracWiki /usr/share/trac/wiki-default/TracBackup => TracBackup /usr/share/trac/wiki-default/TracPermissions => TracPermissions /usr/share/trac/wiki-default/TracImport => TracImport /usr/share/trac/wiki-default/TracInstall => TracInstall /usr/share/trac/wiki-default/TracPlugins => TracPlugins /usr/share/trac/wiki-default/TracSyntaxColoring => TracSyntaxColoring /usr/share/trac/wiki-default/TracTimeline => TracTimeline /usr/share/trac/wiki-default/WikiRestructuredTextLinks => WikiRestructuredTextLinks /usr/share/trac/wiki-default/TracBrowser => TracBrowser /usr/share/trac/wiki-default/TracCgi => TracCgi /usr/share/trac/wiki-default/TracIni => TracIni /usr/share/trac/wiki-default/TracRss => TracRss /usr/share/trac/wiki-default/WikiFormatting => WikiFormatting /usr/share/trac/wiki-default/TracSearch => TracSearch /usr/share/trac/wiki-default/WikiProcessors => WikiProcessors Indexing repository
--------------------------------------------------------------------- Project environment for ‘myproject‘ created.
You may now configure the environment by editing the file:
/home/trac/myproject/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/trac/myproject
Then point your browser to http://localhost:8000/myproject. 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://projects./trac/
Congratulations!
請用您的項目名替換上面的 “myproject” 。
S2. 修改 trac 環(huán)境配置文件
當 trac 的環(huán)境創(chuàng)建以后,trac 環(huán)境的配置文件為存放在項目目錄 /home/trac/myproject 下的 conf/trac.ini。
可以顯示該文件查看默認的參數(shù)值,并做適當修改。
/home/trac/myproject/conf/trac.ini
[wiki] ignore_missing_pages = false
[header_logo] src = common/trac_banner.png alt = Trac height = 73 link = http://trac./ width = 236
[logging] log_file = trac.log log_level = DEBUG log_type = file # 建議改為 file ,生成 trac.log 的日志文件
[trac] default_charset = utf-8 # 建議將默認字符集改為 utf-8 ignore_auth_case = false permission_store = DefaultPermissionStore check_auth_ip = true database = sqlite:db/trac.db templates_dir = /usr/share/trac/templates default_handler = WikiModule metanav = login,logout,settings,help,about mainnav = wiki,timeline,roadmap,browser,tickets,newticket,search repository_dir = /home/svn/repository1
[notification] always_notify_owner = false smtp_always_cc = smtp_password = smtp_enabled = false smtp_replyto = trac@localhost smtp_port = 25 always_notify_reporter = false smtp_server = localhost smtp_from = trac@localhost smtp_user =
[project] url = http:/// footer = Visit the Trac open source project at<br /><a href="http://trac./">http://trac./</a> name = myproject descr = My example project icon = common/trac.ico
[mimeviewer] php_path = php enscript_path = enscript tab_width = 8 max_preview_size = 262144
[attachment] render_unsafe_content = false max_size = 262144
[timeline] changeset_show_files = 0 ticket_show_details = false default_daysback = 30
[ticket] default_version = default_component = component1 default_type = defect restrict_owner = false default_milestone = default_priority = major
[browser] hide_properties = svk:merge
參考
S3. 測試
可以運行獨立的 tracd 進行測試
tracd --port 8000 /home/trac/myproject
在瀏覽器的 URL 里輸入 http://localhost:8000 對 trac 服務(wù)器進行測試。
Standalone 方式只能由本機訪問。測試完畢請殺掉 tracd 進程。
S1. 修改 trac 環(huán)境的權(quán)限以便與 Apache 結(jié)合
sudo find /home/trac/myproject -type f -exec chmod 0664 {} \; sudo find /home/trac/myproject -type d -exec chmod 2775 {} \; sudo chown -R root.www-data /home/trac/myproject
-
trac 環(huán)境的屬主是 root ,配置了讀寫權(quán)限
-
trac 環(huán)境的組是 www-data ,配置了讀寫權(quán)限并設(shè)置了 sgid
-
Apache 默認以 用戶 www-data;組 www-data 運行
S2. 創(chuàng)建 /etc/apache2/conf.d/trac,添加如下的配置行
/etc/apache2/conf.d/trac
<Location /trac> SetHandler mod_python PythonHandler trac.web.modpython_frontend PythonOption TracEnv /home/trac/myproject PythonOption TracUriRoot "/trac" </Location> <Location "/trac/login"> AuthType Basic AuthName "Trac" AuthUserFile /etc/apache2/dav_svn.passwd Require valid-user </Location>
<===== The login URL is per project, so that should be: <LocationMatch "/[^/]+/login"> #... </LocationMatch> Or if you‘ll be following the separate paths as mentioned above: <LocationMatch "/trac/[^/]+/login"> =====>
在本配置中,身份驗證使用了與 Subversion 相同的認證文件。
S3: 重新啟動 Apache
sudo a2enmod mod_python sudo /etc/init.d/apache2 restart
S4: 測試
-
-
測試 user1 — user4 的可登錄性
參考
trac 與 Apache 結(jié)合運行時,trac 的用戶身份認證使用 Apache 的用戶認證,即通過 htpasswd 命令設(shè)置的,根據(jù)上面的 Apache 配置,用戶名和密碼存放在 /etc/apache2/dav_svn.passwd 文件中。
但是,當用戶通過用戶認證之后,他都可以進行哪些操作是由 trac 所提供的 trac-admin 命令來設(shè)置的,使用這個命令可以為用戶或組分配權(quán)限。
使用如下命令可以列出已設(shè)置的許可權(quán)限和當前有效的許可權(quán)限。
sudo trac-admin /home/trac/myproject permission list User Action -------------------------- anonymous BROWSER_VIEW anonymous CHANGESET_VIEW anonymous FILE_VIEW anonymous LOG_VIEW anonymous MILESTONE_VIEW anonymous REPORT_SQL_VIEW anonymous REPORT_VIEW anonymous ROADMAP_VIEW anonymous SEARCH_VIEW anonymous TICKET_CREATE anonymous TICKET_MODIFY anonymous TICKET_VIEW anonymous TIMELINE_VIEW anonymous WIKI_CREATE anonymous WIKI_MODIFY anonymous WIKI_VIEW Available actions: BROWSER_VIEW, CHANGESET_VIEW, CONFIG_VIEW, FILE_VIEW, LOG_VIEW, MILESTONE_ADMIN, MILESTONE_CREATE, MILESTONE_DELETE, MILESTONE_MODIFY, MILESTONE_VIEW, REPORT_ADMIN, REPORT_CREATE, REPORT_DELETE, REPORT_MODIFY, REPORT_SQL_VIEW, REPORT_VIEW, ROADMAP_ADMIN, ROADMAP_VIEW, SEARCH_VIEW, TICKET_ADMIN, TICKET_APPEND, TICKET_CHGPROP, TICKET_CREATE, TICKET_MODIFY, TICKET_VIEW, TIMELINE_VIEW, TRAC_ADMIN, WIKI_ADMIN, WIKI_CREATE, WIKI_DELETE, WIKI_MODIFY, WIKI_VIEW
上面第一部分列出的是默認的權(quán)限設(shè)置。即只對匿名用戶(非登錄用戶)的權(quán)限進行了設(shè)置。
Available actions 部分顯示了有效許可權(quán)限的列表。其中 TRAC_ADMIN 權(quán)限相當于 Linux 中的 root 用戶,擁有最高的權(quán)限。
參考
下面給出一個 trac 權(quán)限設(shè)置的例子:
S1. 添加一個 admin 組并賦予 TRAC_ADMIN 權(quán)限,然后將 user1 和 user2 添加到 admin 組
sudo trac-admin /home/trac/myproject permission add admin TRAC_ADMIN sudo trac-admin /home/trac/myproject permission add user1 admin sudo trac-admin /home/trac/myproject permission add user2 admin
S2. 添加一個 developer 組并賦予 WIKI_ADMIN、REPORT_ADMIN、TICKET_MODIFY 權(quán)限,然后將 user3 和 user4 添加到 developer 組
sudo trac-admin /home/trac/myproject permission add developer WIKI_ADMIN sudo trac-admin /home/trac/myproject permission add developer REPORT_ADMIN sudo trac-admin /home/trac/myproject permission add developer TICKET_MODIFY sudo trac-admin /home/trac/myproject permission add user3 developer sudo trac-admin /home/trac/myproject permission add user4 developer
S3. 刪除默認賦予 anonymous 用戶的 WIKI_CREATE 權(quán)限
sudo trac-admin /home/trac/myproject permission remove anonymous WIKI_CREATE
S4: 測試
-
-
測試 anonymous 的權(quán)限 (不能創(chuàng)建新的 Wiki 頁)
-
以 user1 或 user2 登錄
-
測試 user1 或 user2 的權(quán)限 (具有一切權(quán)限)
-
以 user3 或 user4 登錄
-
測試 user3 或 user4 的權(quán)限
trac 有兩個默認的用戶,一個是 anonymous,表示匿名用戶;另一個是 authenticated,表示所有已通過身份認證的用戶??梢园言S可權(quán)限賦予這兩個用戶,從而簡化許可權(quán)限配置。
|