jqkyp 发表于 2017-1-14 09:51:54

老鸟rhel5/centos5服务器架设笔记:Trac+SVN+Apache架设进阶篇

  Trac+SVN+Apache架设进阶篇
  准备工作
 请先阅读《Trac的安装和配置》以及《SVN(subversion)的安装和配置》这2篇文章,按照这2篇文章的描述搭建你的Trac和SVN环境。
 注意,SVN必须采用用户登陆文件的认证方式,这是因为Trac不支持数据库认证方式,否则它们都使用数据库认证倒是一个不错的主意!
 
  步骤1、安装setuptools
 如果你的机器已经安装setuptools,此步可忽略,可以通过命令行补全功能看看你的机器是否已经安装setuptools
 #easy_install
 通常rhel5/centos5已经安装了easy_install-2.4,这样的话此步可忽略,接下去的步骤可用easy_install-2.4来安装
 如果没有安装easy_install或者easy_install-2.4的话,执行下面的安装步骤
 #wget http://peak.telecommunity.com/dist/ez_setup.py 
 #python ez_setup.py
 确保你的网络畅通,如果安装失败,多试几次
  步骤2、安裝WebAdmin管理界面
 #easy_install http://svn.edgewall.com/repos/trac/sandbox/webadmin/
  步骤3、安装AccountManager
 #easy_install http://trac-hacks.org/svn/accountmanagerplugin/0.10/
  步骤4、安装IniAdmin
 #easy_install http://trac-hacks.org/svn/iniadminplugin/0.11/
 笔者觉得这个插件有些问题,不能在Trac的插件列表中显示出来,也可能我才疏学浅,没有配置正确,这个插件用不到关系不大,不过等笔者研究好了,会第一时间贴出来的。
  步骤5、安装Gantt图
 #wget http://willbarton.com/files/TracGantt-0.3.2a-py${PYTHON_VERSION}.egg
 #easy_install TracGantt-0.3.2a-py${PYTHON_VERSION}.egg
  步骤6、Trac+SVN目录结构图
 我们看到Trac的目录结构是
 |-/trac
     |-projects    //Trac项目库父路径
          |-TelecomProjects  //具体项目库
          |-OtherProjects
        
 SVN的目录结构是
 |-/svn
     |-.htpasswd   //登陆用户文件
     |-svnaccess   //svn访问控制文件
     |-repos      //SVN项目库父路径
          |-TelecomRepositorys  //具体Repositorys
          |-OtherRepositorys
 上面只是笔者的目录结构图,你可根据需要调整更适合自己的或者更好的目录结构,比如
  |-/var
       |-trac
           |-.htpasswd
           |-svnaccess
           |-projects     //Trac项目库父路径
                |-TelecomProjects
                |-OtherProjects
           |-repos        //SVN Repository父路径
                |-TelecomRepositorys
                     |-OtherRepositorys
  步骤7、Trac project的插件配置
 把以下内容写入到/trac/projects/TelecomProjects/conf/trac.ini中  

[*]       
[*]webadmin.* = enabled       
[*]tracgantt.* = enabled       
[*]iniadmin.iniadmin.iniadminplugin = enabled      
[*]trac.web.auth.LoginModule = disabled      
[*]acct_mgr.* = enabled       
[*]      
[*]       
[*]password_format = htpasswd      
[*]password_file = /svn/.htpasswd       
[*]      
[*]      
[*]       
[*]due_assign = text      
[*]due_assign.label = Due to assign       
[*]due_assign.value = YYYY/MM/DD       
[*]      
[*]dependencies = text      
[*]dependencies.label = Dependencies      
[*]dependencies.value =       
[*]      
[*]due_close= text       
[*]due_close.label = Due to close       
[*]due_close.value = YYYY/MM/DD       
[*]      
[*]include_gantt = checkbox      
[*]include_gantt.label = Include in GanttChart       
[*]include_gantt.value =       
[*]      
[*]       
[*]# The format of dates entered by humans in the above ticket fields       
[*]date_format = %Y/%m/%d       
[*]      
[*]# Include the ticket summary in the gantt chart display       
[*]include_summary = true      
[*]      
[*]# Trim the included summary to the given number of characters       
[*]summary_length = 16      
[*]      
[*]# Use the creation date of a ticket as the "due assign" date if no       
[*]# assignment date is given       
[*]use_creation_date = true      
[*]      
[*]# Show on the gantt chart the date the ticket was opened, to contrast       
[*]# with the assignment date.       
[*]show_opened = true    

  注意:iniadmin.iniadmin.iniadminplugin = enabled这句话因为iniadmin这个插件没有正确被识别,所以并没有什么作用;
 trac.web.auth.LoginModule = disabled 这句话的意思是禁用trac的登陆模块功能,如果你禁用掉http的认证功能,那么就需要把这句话设置为trac.web.auth.LoginModule = enabled
  步骤8、与Apache集成
 在/etc/httpd/conf/httpd.conf中或者/etc/httpd/conf.d/subversion.conf中SVN的配置为如下内容 

[*]<Location /svn>                  
[*]DAV svn                   
[*]SVNParentPath /svn/repos                   
[*]AuthzSVNAccessFile /svn/svnaccess                   
[*]AuthName "SVN Repositorys"                   
[*]AuthType Basic                     
[*]AuthUserFile /svn/.htpasswd                   
[*]Require valid-user                   
[*]</Location>   

  在/etc/httpd/conf/httpd.conf中或者/etc/httpd/conf.d/python.conf中Trac配置为如下内容

[*]<Location /trac>                  
[*]SetHandler mod_python                   
[*]PythonInterpreter main_interpreter                   
[*]PythonHandler trac.web.modpython_frontend                      
[*]PythonOption TracEnvParentDir /trac/projects                   
[*]AuthType Basic                   
[*]AuthName "Trac Projects"                   
[*]AuthUserFile /svn/.htpasswd                   
[*]Require valid-user                   
[*]</Location>  

  请注意到在上面的配置中Trac是不允许被匿名访问的,哪是因为笔者不想让Trac被匿名访问,并且不允许有开放注册功能,所以要想访问Trac必须先登陆(呵呵,这招是狠了点);如果你想让你的Trac被匿名访问并且开发注册功能的话,把上面一段改成 

[*]<Location /trac>                  
[*]SetHandler mod_python                   
[*]PythonInterpreter main_interpreter                   
[*]PythonHandler trac.web.modpython_frontend                      
[*]PythonOption TracEnvParentDir /trac/projects                       
[*]</Location>                  
[*]                       
[*]<LocationMatch "/trac/[^/]+/login">                  
[*]AuthType Basic                   
[*]AuthName "Trac"                   
[*]AuthUserFile /svn/.htpasswd                   
[*]Require valid-user                   
[*]</LocationMatch>  

  这样Trac就能被匿名访问,并能开放了注册功能,注意LocationMatch 后面的"/trac/[^/]+/login"是个字符串,当然也是个正则表达式,表示是匹配trac登陆字符串,比如匹配"/trac/TelecomProjects/login"。
 如果开放了匿名访问,那么要取消匿名使用者的部分写入权限,避免有人恶意捣乱,当然你也可以通过webadmin界面来设置权限。
 #trac-admin /trac/projects/TelecomProjects permission remove anonymous TICKET_CREATE TICKET_MODIFY WIKI_CREATE WIKI_MODIFY
 #trac-admin /trac/projects/TelecomProjects add authenticated TICKET_CREATE TICKET_MODIFY TICKET_VIEW WIKI_CREATE WIKI_MODIFY
  步骤9、访问Trac
 设置test1为管理员帐号
 #trac-admin /trac/projects/TelecomProjects/ permission add test1 TRAC_ADMIN
 重启httpd Server
 #service httpd restart
 用test1登陆trac
 http://localhost/trac
 是不是在menu bar上看到了Admin和Gantt Charts菜单了呢!开始你的Trac使用之旅吧!
  Good Luck!
  
       
  
页: [1]
查看完整版本: 老鸟rhel5/centos5服务器架设笔记:Trac+SVN+Apache架设进阶篇