Subversion 環境をセットアップしようとして、いろいろとやっていたら、Tracと一緒に立てるのが良さそうな気がしてきたので、設定してみた。
CentOS 4 に入れるには、http://trac.edgewall.org/wiki/TracOnRhel4 にある通り。まず、/etc/sysconfig/rhn/sourcesに
# Name: RPMforge RPM Repository for Red Hat Enterprise 4 - i386 yum rpmforge http://apt.sw.be/redhat/el4/en/i386/dag/
を加えて、
# up2date --nosig -i trac # up2date -i mod_python
でインストール完了。あとは、セットアップだけど、その前にプラグインを入れておく。プラグインをインストールする前の準備として、setuptools を入れる。
# wget http://peak.telecommunity.com/dist/ez_setup.py # python ez_setup.py Downloading http://cheeseshop.python.org/packages/2.3/s/setuptools/setuptools-0.6c5-py2.3.egg Processing setuptools-0.6c5-py2.3.egg creating /usr/lib/python2.3/site-packages/setuptools-0.6c5-py2.3.egg Extracting setuptools-0.6c5-py2.3.egg to /usr/lib/python2.3/site-packages Adding setuptools 0.6c5 to easy-install.pth file Installing easy_install script to /usr/bin Installing easy_install-2.3 script to /usr/bin
で、次にTracWebAdminプラグインを入れる。
# wget http://trac.edgewall.org/attachment/wiki/WebAdmin/TracWebAdmin-0.1.2dev_r4240-py2.3.egg.zip?format=raw # mv TracWebAdmin-0.1.2dev_r4240-py2.3.egg* TracWebAdmin-0.1.2dev_r4240-py2.3.egg # easy_install TracWebAdmin-0.1.2dev_r4240-py2.3.egg
さらに、TracAccountManagerプラグインも便利なので入れる。
# easy_install http://trac-hacks.org/svn/accountmanagerplugin/0.10 Downloading http://trac-hacks.org/svn/accountmanagerplugin/0.10 Doing subversion checkout from http://trac-hacks.org/svn/accountmanagerplugin/0.10 to /tmp/easy_install-Qtnn12/0.10 Processing 0.10 Running setup.py -q bdist_egg --dist-dir /tmp/easy_install-Qtnn12/0.10/egg-dist-tmp-QE3koQ Adding TracAccountManager 0.1.3dev-r2171 to easy-install.pth file Installed /usr/lib/python2.3/site-packages/TracAccountManager-0.1.3dev_r2171-py2.3.egg Processing dependencies for TracAccountManager==0.1.3dev-r2171
としたのだけど、/usr/lib/python2.3/site-packages/TracAccountManager-0.1.3dev_r2171-py2.3.eggで展開されていないので(はて、なぜ?)、やり直す。
# mv /usr/lib/python2.3/site-packages/TracAccountManager-0.1.3dev_r2171-py2.3.egg /tmp # easy_install --always-unzip /tmp/TracAccountManager-0.1.3dev_r2171-py2.3.egg
これで、ひとまず、完了。
次に、プロジェクトを作る。プロジェクトの置く場所はどこでもいいと思うけど、今回は /projects 以下に作ることにした。作るプロジェクトは、sampleproject として、必要なディレクトリとsvnリポジトリを作成する。
# mkdir /projects/sampleproject # mkdir /projects/sampleproject/svn # mkdir /projects/sampleproject/trac # svnadmin create --fs-type fsfs /projects/sampleproject/svn/
次に、Tracを初期化。
# trac-admin /projects/sampleproject/trac/sampleproject initenv Creating a new Trac environment at /projects/sampleproject/trac/sampleproject 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]> Sample Project 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]> Please specify the type of version control system, By default, it will be svn. If you don't want to use Trac with version control integration, choose the default here and don't specify a repository directory. in the next question. Repository type [svn]> Please specify the absolute path to the version control repository, or leave it blank to use Trac without a repository. You can also set the repository location later. Path to repository [/path/to/repos]> /projects/sampleproject/svn 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]> Creating and Initializing Project Installing default wiki pages /usr/share/trac/wiki-default/WikiMacros => WikiMacros /usr/share/trac/wiki-default/TracIni => TracIni /usr/share/trac/wiki-default/TracGuide => TracGuide /usr/share/trac/wiki-default/TracSearch => TracSearch /usr/share/trac/wiki-default/WikiFormatting => WikiFormatting /usr/share/trac/wiki-default/WikiProcessors => WikiProcessors /usr/share/trac/wiki-default/TracSyntaxColoring => TracSyntaxColoring /usr/share/trac/wiki-default/TracInterfaceCustomization => TracInterfaceCustomization /usr/share/trac/wiki-default/TracFastCgi => TracFastCgi /usr/share/trac/wiki-default/WikiStart => WikiStart /usr/share/trac/wiki-default/TracReports => TracReports /usr/share/trac/wiki-default/WikiRestructuredTextLinks => WikiRestructuredTextLinks /usr/share/trac/wiki-default/InterMapTxt => InterMapTxt /usr/share/trac/wiki-default/TracPermissions => TracPermissions /usr/share/trac/wiki-default/TracStandalone => TracStandalone /usr/share/trac/wiki-default/TracLinks => TracLinks /usr/share/trac/wiki-default/RecentChanges => RecentChanges /usr/share/trac/wiki-default/TracAccessibility => TracAccessibility /usr/share/trac/wiki-default/WikiHtml => WikiHtml /usr/share/trac/wiki-default/TracSupport => TracSupport /usr/share/trac/wiki-default/TracImport => TracImport /usr/share/trac/wiki-default/WikiPageNames => WikiPageNames /usr/share/trac/wiki-default/InterTrac => InterTrac /usr/share/trac/wiki-default/TracAdmin => TracAdmin /usr/share/trac/wiki-default/TracInstall => TracInstall /usr/share/trac/wiki-default/TracQuery => TracQuery /usr/share/trac/wiki-default/TracRoadmap => TracRoadmap /usr/share/trac/wiki-default/TracChangeset => TracChangeset /usr/share/trac/wiki-default/WikiRestructuredText => WikiRestructuredText /usr/share/trac/wiki-default/SandBox => SandBox /usr/share/trac/wiki-default/InterWiki => InterWiki /usr/share/trac/wiki-default/TitleIndex => TitleIndex /usr/share/trac/wiki-default/TracModPython => TracModPython /usr/share/trac/wiki-default/TracTimeline => TracTimeline /usr/share/trac/wiki-default/TracRss => TracRss /usr/share/trac/wiki-default/TracTickets => TracTickets /usr/share/trac/wiki-default/WikiNewPage => WikiNewPage /usr/share/trac/wiki-default/TracBrowser => TracBrowser /usr/share/trac/wiki-default/TracBackup => TracBackup /usr/share/trac/wiki-default/TracRevisionLog => TracRevisionLog /usr/share/trac/wiki-default/TracWiki => TracWiki /usr/share/trac/wiki-default/TracLogging => TracLogging /usr/share/trac/wiki-default/TracPlugins => TracPlugins /usr/share/trac/wiki-default/TracCgi => TracCgi /usr/share/trac/wiki-default/TracEnvironment => TracEnvironment /usr/share/trac/wiki-default/TracNotification => TracNotification /usr/share/trac/wiki-default/TracUpgrade => TracUpgrade /usr/share/trac/wiki-default/CamelCase => CamelCase /usr/share/trac/wiki-default/WikiDeletePage => WikiDeletePage /usr/share/trac/wiki-default/TracUnicode => TracUnicode /usr/share/trac/wiki-default/TracTicketsCustomFields => TracTicketsCustomFields Indexing repository --------------------------------------------------------------------- Project environment for 'Sample Project' created. You may now configure the environment by editing the file: /projects/sampleproject/trac/sampleproject/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 /projects/sampleproject/trac/sampleproject Then point your browser to http://localhost:8000/sampleproject. 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://trac.edgewall.org/ Congratulations!
初期設定ができたところで、次はカスタマイズ。今回は、SubversionをApache経由でアクセスできるようにして、Trac も同様にApache経由でアクセスするための設定をする。まず、/etc/httpd/conf.d/trac.confに
<Location /sampleproject> SetHandler mod_python PythonHandler trac.web.modpython_frontend PythonOption TracEnv /projects/sampleproject/trac/sampleproject PythonOption TracUriRoot /sampleproject SetEnv PYTHON_EGG_CACHE /projects/sampleproject/trac/.python-eggs </Location>
を加える。次に、/etc/httpd/conf.d/subversion.confに
<Location /sampleproject/svn> DAV svn SVNPath /projects/sampleproject/svn AuthType Basic AuthName "Project repository" AuthUserFile /projects/sampleproject/sampleproject.htpasswd Require valid-user </Location>
を加える。そして、Tracの設定ファイル/projects/sampleproject/trac/sampleproject/conf/trac.iniをいじる。
[components] acct_mgr.admin.accountmanageradminpage = enabled acct_mgr.htfile.htpasswdstore = enabled acct_mgr.web_ui.accountmodule = enabled acct_mgr.web_ui.loginmodule = enabled acct_mgr.web_ui.registrationmodule = disabled trac.web.auth.loginmodule = disabled webadmin.* = enabled [account-manager] password_file = /projects/sampleproject/sampleproject.htpasswd password_format = htpasswd password_store = HtPasswdStore
を加える。今回は、BASIC認証を利用する。TRAC_ADMIN権限を持つユーザーが必要なので、adminユーザーを作成。
# /usr/bin/htpasswd -c /projects/sampleproject/sampleproject.htpasswd admin # chmod 400 /projects/sampleproject/sampleproject.htpasswd # trac-admin /projects/sampleproject/trac/sampleproject/ permission add admin TRAC_ADMIN
デフォルトでは、ログインしなくてもいろいろといじれるので、trac-admin の permission remove とかで削除するか、Trac が利用可能になったときに admin でログインして、権限を編集してください。
SELinux を使っているなら、
# chcon -R system_u:object_r:httpd_sys_script_rw_t /projects/sampleproject/
を実行する。
Apacheからアクセスできるように
# chown -R apache:apache /projects/sampleproject/
として、オーナーを変更する。そして、
# /etc/init.d/httpd restart
として、作業完了。あとは、http://localhost/sampleprojectにアクセスすれば、OKです。Subversion は、svn co http://localhost/sampleproject/svn でチェックアウトできるかと。
ざっと、使った感じでは、便利そう 🙂