Ubuntu搭建trac平台步骤


Ubuntu搭建trac平台步骤:


注:如果不用mysql模式,mysql相关均可不装


# apt-get install apache2


# apt-get install libapache2-mod-python


# apt-get install libapache2-mod-authnz-external 


# a2enmod authnz_ldap


# apt-get install mysql-server-5.5  (设置root密码,如:123456)


# apt-get install python-mysqldb


# apt-get install python-setuptools


# easy_install Genshi==0.6


# easy_install Babel==0.9.6


# easy_install Trac==0.12.2


# mysql -u root -p123456


mysql> create database trac;


mysql> grant all on trac.* to tracadmin@'localhost' identified by '123456';


mysql>  flush privileges;


mysql> quit



# mkdir -p /var/www/ming   (创建trac项目ming,多个trac得建多个目录,并做initenv操作)


# trac-admin /var/www/ming initenv  


ming


mysql://tracadmin:123456@127.0.0.1/trac   (或 sqlite:db/trac.db,用mysql多个trac得建多个数据库,sqlite可用1个数据库)


# chown -R www-data:www-data /var/www/ming  (一定要记得修改权限)



#  vi /etc/apache2/http.conf   (要建多个trac,上面操作后把里面内容复制一份即可)


按a或i进入编辑模式



<Location /ming>

       SetHandler mod_python

       PythonInterpreter main_interpreter

       PythonHandler trac.web.modpython_frontend

       PythonOption  TracEnv /var/www/ming

       PythonOption  TracUriRoot /

       SetEnv  PYTHON_EGG_CACHE /tmp

</Location>


<Location /ming/login>   (将该下所有登录控制写到上面/框架里可实现必须登录才能打开trac页面)

       AuthType Basic

       AuthName "Trac"

       AuthBasicProvider "ldap"

       AuthLDAPURL  "ldap://10.0.0.3:3268/DC=ming,dc=com?sAMAccountName?sub?(objectClass=user)"   (只允许某个ou人员登录,ldap://10.0.0.3:3268/ou=aa,dc=ming,dc=com?sAMAccoutName?sub?,后面为require valid-user)

       AuthLDAPBindDN  yang@ming.com

       AuthLDAPBindPassword "123456"

       authzldapauthoritative Off

       require valid-user (valid-user为所有用户,ldap-user为单个用户,多个用户中间空格隔开,ldap-group为某个ou)

</Location>


其它不变


按Esc键退出编辑模式


:wq (保存并退出)


# service apache2 restart



Ubuntu 16.04上配置(16.04上不认httpd.conf):


# vi /etc/apache2/sites-available/wiki.conf


<VirtualHost *:80>


<Location /ming>

   SetHandler mod_python

   PythonInterpreter main_interpreter

   PythonHandler trac.web.modpython_frontend

   PythonOption TracEnv /srv/trac/projects/ming

#   PythonOption TracUriRoot /ASIC

</Location>


<Location /ming/login>

        AuthType Basic

        AuthName "ming"

        AuthBasicProvider "ldap"

        AuthLDAPURL "ldap://10.0.0.98:3268/Dc=spreadtrum,dc=com?sAMAccountName?sub?(objectClass=user)"

        AuthLDAPBindDN       trac@spreadtrum.com

        AuthLDAPBindPassword "123@abAB$0"

        ##require valid-user CN=Users,dc=spreadtrum,dc=com

        require valid-user

</Location>



ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined


</VirtualHost>


:wq


# cd /etc/apache2/site-enabled/

# ln -s /etc/apache2/site-available/wiki.conf .





WSGI模块搭建trac:


# apt-get install libapache2-mod-wsgi


# vi /var/www/trac.wsgi


import sys

sys.stdout = sys.stderr


import os

os.environ[ 'TRAC_ENV_PARENT_DIR' ] = '/srv/trac_root'

os.environ[ 'PYTHON_EGG_CACHE' ] = '/tmp'


import trac.web.main


application=trac.web.main.dispatch_request


:wq


# vi /etc/apache2/sites-available/ming


WSGIScriptAlias / /srv/trac_root/ming2.wsgi

    <Directory /srv/trac_root/ming>

    WSGIApplicationGroup %{GLOBAL}

    Order deny,allow

    Allow from all

    </Directory>


<Location /ming/login>   (将该下所有登录控制写到上面/框架里可实现必须登录才能打开trac页面)

       AuthType Basic

       AuthName "Trac"

       AuthBasicProvider "ldap"

       AuthLDAPURL  "ldap://10.0.0.3:3268/DC=ming,dc=com?sAMAccountName?sub?(objectClass=user)"   (只允许某个ou人员登录,ldap://10.0.0.3:3268/ou=aa,dc=ming,dc=com?sAMAccoutName?sub?,后面为require valid-user)

       AuthLDAPBindDN  yang@ming.com

       AuthLDAPBindPassword "123456"

       authzldapauthoritative Off

       require valid-user (valid-user为所有用户,ldap-user为单个用户,多个用户中间空格隔开,ldap-group为某个ou)

</Location>

:wq


# cd /etc/apache2/sites-enabled

# ln -s ../sites-available/ming .

# service apache2 restart



注:


如果报错:TimeoutError:Unable to get database connection within 0 seconds. (TracError 


(<babel.support.LazyProxy object at 0x7fe1d6e089b0>,))


是trac.ini的权限没设置好


# chown www-data:www-data /var/www/ming/conf/trac.ini即可



给某个账号管理员权限(可以是域账号)

# trac-admin /var/www/ming permission add zhi.yang TRAC_ADMIN

(会多出删除页面、删除附件等按钮)


删除管理员权限

# trac-admin /var/www/ming permission remove zhi.yang TRAC_ADMIN


查看所有账号的权限:

# trac-admin /var/www/ming permission list



trac删除附件(上面给过管理员权限,就不需要命令了):


# trac-admin /var/www/ming  attachment remove wiki:WikiStart aa.rar


新建wiki页面:


编辑原有页面,在自己想放的位置输入"[wiki:aa]",(aa为页面名),点击保存,aa即会显示会链接,然后点击链接即会让新建页面

本文转自linux博客51CTO博客,原文链接http://blog.51cto.com/yangzhiming/1614325如需转载请自行联系原作者


yangzhimingg

上一篇:ECS使用体验


下一篇:ECS使用有感