2008年8月29日 のアーカイブ

ようやく環境を構築できました

2008年8月29日 金曜日

文字コードのエラーを回避するために、Trac-jaをインストールし直すことにしました。MacPortsのPortfileは、trac-0.10.4-ja-1のものしかなかったので、trac-0.10.5-ja-1用のものを作って(といっても、バージョンとチェックサムを修正しただけですが)、インストールしました。
portindexで、portfileの再登録を確認してから、インストールしました。
# portindex
Creating software index in /Users/username/localports
Adding port devel/trac-ja

Total number of ports parsed: 1
Ports successfully parsed: 1
Ports failed: 0

# sudo port install trac-ja
---> Fetching trac-ja
---> Verifying checksum(s) for trac-ja
---> Extracting trac-ja
---> Configuring trac-ja
---> Building trac-ja with target build
---> Staging trac-ja into destroot
---> Installing trac-ja 0.10.5-ja-1_1
See http://projects.edgewall.com/trac/wiki/TracInstall for information on setting up a new trac environment.
---> Activating trac-ja 0.10.5-ja-1_1
---> Cleaning trac-ja

うまくインストールできたようなので、引き続き、trac-adminを使ってTracのプロジェクトを作りました。

# trac-admin /Users/username/trac/tractest initenv
Creating a new Trac environment at /Users/username/trac/tractest

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]> tractest

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]> /Users/username/svn/tractest

Please enter location of Trac page templates.
Default is the location of the site-wide templates installed with Trac.

Templates directory [/opt/local/share/trac/templates]>

Creating and Initializing Project
Installing default wiki pages
/opt/local/share/trac/wiki-default/CamelCase => CamelCase
/opt/local/share/trac/wiki-default/InterMapTxt => InterMapTxt
/opt/local/share/trac/wiki-default/InterTrac => InterTrac
/opt/local/share/trac/wiki-default/InterWiki => InterWiki
/opt/local/share/trac/wiki-default/RecentChanges => RecentChanges
/opt/local/share/trac/wiki-default/SandBox => SandBox
/opt/local/share/trac/wiki-default/TitleIndex => TitleIndex
/opt/local/share/trac/wiki-default/TracAccessibility => TracAccessibility
/opt/local/share/trac/wiki-default/TracAdmin => TracAdmin
/opt/local/share/trac/wiki-default/TracBackup => TracBackup
/opt/local/share/trac/wiki-default/TracBrowser => TracBrowser
/opt/local/share/trac/wiki-default/TracCgi => TracCgi
/opt/local/share/trac/wiki-default/TracChangeset => TracChangeset
/opt/local/share/trac/wiki-default/TracEnvironment => TracEnvironment
/opt/local/share/trac/wiki-default/TracFastCgi => TracFastCgi
/opt/local/share/trac/wiki-default/TracGuide => TracGuide
/opt/local/share/trac/wiki-default/TracImport => TracImport
/opt/local/share/trac/wiki-default/TracIni => TracIni
/opt/local/share/trac/wiki-default/TracInstall => TracInstall
/opt/local/share/trac/wiki-default/TracInterfaceCustomization => TracInterfaceCustomization
/opt/local/share/trac/wiki-default/TracJa => TracJa
/opt/local/share/trac/wiki-default/TracLinks => TracLinks
/opt/local/share/trac/wiki-default/TracLogging => TracLogging
/opt/local/share/trac/wiki-default/TracModPython => TracModPython
/opt/local/share/trac/wiki-default/TracNotification => TracNotification
/opt/local/share/trac/wiki-default/TracPermissions => TracPermissions
/opt/local/share/trac/wiki-default/TracPlugins => TracPlugins
/opt/local/share/trac/wiki-default/TracQuery => TracQuery
/opt/local/share/trac/wiki-default/TracReports => TracReports
/opt/local/share/trac/wiki-default/TracRevisionLog => TracRevisionLog
/opt/local/share/trac/wiki-default/TracRoadmap => TracRoadmap
/opt/local/share/trac/wiki-default/TracRss => TracRss
/opt/local/share/trac/wiki-default/TracSearch => TracSearch
/opt/local/share/trac/wiki-default/TracStandalone => TracStandalone
/opt/local/share/trac/wiki-default/TracSupport => TracSupport
/opt/local/share/trac/wiki-default/TracSyntaxColoring => TracSyntaxColoring
/opt/local/share/trac/wiki-default/TracTermsJa => TracTermsJa
/opt/local/share/trac/wiki-default/TracTickets => TracTickets
/opt/local/share/trac/wiki-default/TracTicketsCustomFields => TracTicketsCustomFields
/opt/local/share/trac/wiki-default/TracTimeline => TracTimeline
/opt/local/share/trac/wiki-default/TracUnicode => TracUnicode
/opt/local/share/trac/wiki-default/TracUpgrade => TracUpgrade
/opt/local/share/trac/wiki-default/TracWiki => TracWiki
/opt/local/share/trac/wiki-default/WikiDeletePage => WikiDeletePage
/opt/local/share/trac/wiki-default/WikiFormatting => WikiFormatting
/opt/local/share/trac/wiki-default/WikiHtml => WikiHtml
/opt/local/share/trac/wiki-default/WikiMacros => WikiMacros
/opt/local/share/trac/wiki-default/WikiNewPage => WikiNewPage
/opt/local/share/trac/wiki-default/WikiPageNames => WikiPageNames
/opt/local/share/trac/wiki-default/WikiProcessors => WikiProcessors
/opt/local/share/trac/wiki-default/WikiRestructuredText => WikiRestructuredText
/opt/local/share/trac/wiki-default/WikiRestructuredTextLinks => WikiRestructuredTextLinks
/opt/local/share/trac/wiki-default/WikiStart => WikiStart

Warning:

You should install the SVN bindings

---------------------------------------------------------------------
Project environment for 'tractest' created.

You may now configure the environment by editing the file:

/Users/username/trac/tractest/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 /Users/username/trac/tractest

Then point your browser to http://localhost:8000/tractest.
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!

Warningがでてますが、tracdでTracを起動してみます。

# tracd --port 8000 /Users/username/trac/tractest

で、WebブラウザでTracのURI(http://localhost:8000/tractest)にアクセス。
すると…、Tracのページにはなるものの、エラーが表示されてしまいました。

Oops…
Trac detected an internal error:

If you think this really should work and you can reproduce it, you should consider reporting this problem to the Trac team.

Go to http://trac.edgewall.org/ and create a new ticket where you describe the problem, how to reproduce it. Don't forget to include the Python traceback found below.

TracGuide — The Trac User and Administration Guide
Python Traceback

Traceback (most recent call last):
File "/opt/local/lib/python2.5/site-packages/trac/web/main.py", line 406, in dispatch_request
dispatcher.dispatch(req)
File "/opt/local/lib/python2.5/site-packages/trac/web/main.py", line 191, in dispatch
chosen_handler = self._pre_process_request(req, chosen_handler)
File "/opt/local/lib/python2.5/site-packages/trac/web/main.py", line 263, in _pre_process_request
chosen_handler = f.pre_process_request(req, chosen_handler)
File "/opt/local/lib/python2.5/site-packages/trac/versioncontrol/api.py", line 73, in pre_process_request
self.get_repository(req.authname).sync()
File "/opt/local/lib/python2.5/site-packages/trac/versioncontrol/api.py", line 94, in get_repository
((self.repository_type,)*2))
TracError: Unsupported version control system "svn". Check that the Python bindings for "svn" are correctly installed.

エラーの通り、Python bindingsがうまく動いていないようなので、Trac-jaとsubversion-python25bindingsをアンインストールして再インストールしました。

# sudo port uninstall trac-ja
Password:
---> Deactivating trac-ja 0.10.5-ja-1_1
---> Uninstalling trac-ja 0.10.5-ja-1_1

# sudo port uninstall subversion-python25bindings
---> Deactivating subversion-python25bindings 1.5.0_1
---> Uninstalling subversion-python25bindings 1.5.0_1

# sudo port install subversion-python25bindings
---> Fetching subversion-python25bindings
---> Attempting to fetch subversion-1.5.1.tar.bz2 from http://subversion.tigris.org//downloads
---> Verifying checksum(s) for subversion-python25bindings
---> Extracting subversion-python25bindings
---> Configuring subversion-python25bindings
---> Building subversion-python25bindings with target swig-py
---> Staging subversion-python25bindings into destroot
---> Installing subversion-python25bindings 1.5.1_0
---> Activating subversion-python25bindings 1.5.1_0
---> Cleaning subversion-python25bindings

# sudo port clean trac-ja
Password:
---> Cleaning trac-ja

# sudo port install trac-ja
---> Fetching trac-ja
---> Verifying checksum(s) for trac-ja
---> Extracting trac-ja
---> Configuring trac-ja
---> Building trac-ja with target build
---> Staging trac-ja into destroot
---> Installing trac-ja 0.10.5-ja-1_1
See http://projects.edgewall.com/trac/wiki/TracInstall for information on setting up a new trac environment.
---> Activating trac-ja 0.10.5-ja-1_1
---> Cleaning trac-ja

再びTrac-jaのプロジェクトを設定して、tracdでサーバを起動して、
# tracd --port 8000 /Users/username/trac/tractest

WebブラウザでTracのURI(http://localhost:8000/tractest/)へアクセス。今度はうまく動きました。

tracdでの起動が確認できたので、mod_pythonで動作させるための設定をします。

Apache2を停止して、httpd.confに以下を追記しました。


SetHandler mod_python
PythonInterpreter main_interpreter
pythonHandler trac.web.modpython_frontend
PythonOption TracUriRoot /tractest
PythonOption TracEnv /Users/username/trac/tractest

Apache2を再起動して、Trac-jaのURIにアクセスします。(Apache2はMac OS X標準のApacheと共存させるためにポートを8080にしてあります)

http://localhost:8080/tractest/

すると、エラーが出てしまいました。

Internal Server Error

500 Internal Server Error (The user root requires read _and_ write permission to the database file /Users/username/trac/tractest/db/trac.db and the directory it is located in.)

TracGuide — The Trac User and Administration Guide

どうやらtrac.dbのパーミッションがおかしいようなので、このファイルを含むディレクトリのユーザをwwwに変更します。
# sudo chown -R www trac
Password:

Apache2を再起動して、TracのURIにアクセス。

http://localhost:8080/tractest/

今度はきちんとTracのトップページが表示されました。なお、パーミッションの変更を行ったので、スタンドアローンのtracdで起動した場合(http://localhost:8000/tractest/)はエラーが出るようになります。

お昼過ぎころまでにはここまでの作業を終えることができたので、部屋の片付けをして夕方から渋谷にでかけました。約束の時間まで家で使う小物とかを探して、ちょっとした報告会に顔を出したのですが、割り当てられた作業(?)を消化するのに精一杯でした。会場の都合で場所を移動してお茶をしながら続きの話をしていた時、気がつくと外はどしゃ降りの雨。渋谷駅に着くまでに裾も靴も水浸しになってしまいました。