trac 是一個(gè)用 Python 編寫(xiě)的相當(dāng)好的 Issue trace 工具。提供了如下的功能:
-
與 Web 服務(wù)器配合,使用 CGI 或 FastCGI 或 mod_python 配置
-
tracd:獨(dú)立服務(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 # 輸入項(xiàng)目名稱(chēng)
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]> # 使用默認(rèn)的 SQLite 數(shù)據(jù)庫(kù),直接回車(chē)即可
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 倉(cāng)庫(kù)的路徑
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]> # 使用默認(rèn)的 Trac page templates,直接回車(chē)即可
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!
請(qǐng)用您的項(xiàng)目名替換上面的 “myproject” 。
S2. 修改 trac 環(huán)境配置文件
當(dāng) trac 的環(huán)境創(chuàng)建以后,trac 環(huán)境的配置文件為存放在項(xiàng)目目錄 /home/trac/myproject 下的 conf/trac.ini。
可以顯示該文件查看默認(rèn)的參數(shù)值,并做適當(dāng)修改。
/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 # 建議將默認(rèn)字符集改為 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. 測(cè)試
可以運(yùn)行獨(dú)立的 tracd 進(jìn)行測(cè)試
tracd --port 8000 /home/trac/myproject
在瀏覽器的 URL 里輸入 http://localhost:8000 對(duì) trac 服務(wù)器進(jìn)行測(cè)試。
Standalone 方式只能由本機(jī)訪問(wèn)。測(cè)試完畢請(qǐng)殺掉 tracd 進(jìn)程。
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 ,配置了讀寫(xiě)權(quán)限
-
trac 環(huán)境的組是 www-data ,配置了讀寫(xiě)權(quán)限并設(shè)置了 sgid
-
Apache 默認(rèn)以 用戶(hù) www-data;組 www-data 運(yùn)行
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"> =====>
在本配置中,身份驗(yàn)證使用了與 Subversion 相同的認(rèn)證文件。
S3: 重新啟動(dòng) Apache
sudo a2enmod mod_python sudo /etc/init.d/apache2 restart
S4: 測(cè)試
-
-
測(cè)試 user1 — user4 的可登錄性
參考
trac 與 Apache 結(jié)合運(yùn)行時(shí),trac 的用戶(hù)身份認(rèn)證使用 Apache 的用戶(hù)認(rèn)證,即通過(guò) htpasswd 命令設(shè)置的,根據(jù)上面的 Apache 配置,用戶(hù)名和密碼存放在 /etc/apache2/dav_svn.passwd 文件中。
但是,當(dāng)用戶(hù)通過(guò)用戶(hù)認(rèn)證之后,他都可以進(jìn)行哪些操作是由 trac 所提供的 trac-admin 命令來(lái)設(shè)置的,使用這個(gè)命令可以為用戶(hù)或組分配權(quán)限。
使用如下命令可以列出已設(shè)置的許可權(quán)限和當(dāng)前有效的許可權(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
上面第一部分列出的是默認(rèn)的權(quán)限設(shè)置。即只對(duì)匿名用戶(hù)(非登錄用戶(hù))的權(quán)限進(jìn)行了設(shè)置。
Available actions 部分顯示了有效許可權(quán)限的列表。其中 TRAC_ADMIN 權(quán)限相當(dāng)于 Linux 中的 root 用戶(hù),擁有最高的權(quán)限。
參考
下面給出一個(gè) trac 權(quán)限設(shè)置的例子:
S1. 添加一個(gè) 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. 添加一個(gè) 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. 刪除默認(rèn)賦予 anonymous 用戶(hù)的 WIKI_CREATE 權(quán)限
sudo trac-admin /home/trac/myproject permission remove anonymous WIKI_CREATE
S4: 測(cè)試
-
-
測(cè)試 anonymous 的權(quán)限 (不能創(chuàng)建新的 Wiki 頁(yè))
-
以 user1 或 user2 登錄
-
測(cè)試 user1 或 user2 的權(quán)限 (具有一切權(quán)限)
-
以 user3 或 user4 登錄
-
測(cè)試 user3 或 user4 的權(quán)限
trac 有兩個(gè)默認(rèn)的用戶(hù),一個(gè)是 anonymous,表示匿名用戶(hù);另一個(gè)是 authenticated,表示所有已通過(guò)身份認(rèn)證的用戶(hù)??梢园言S可權(quán)限賦予這兩個(gè)用戶(hù),從而簡(jiǎn)化許可權(quán)限配置。
|