TracOnUbuntu - The Trac Project - Tracをみながら、TracをUbuntuにインストール。
0. Apache2とSubversionはすでにインストールしてあるので省略。
1. Synapticパッケージマネージャで、trac, trac-ja-resource を選択して、インストール。
2. 環境ディレクトリを作る
sudo mkdir /var/lib/trac
sudo chown www-data:www-data /var/lib/trac
3. Apache2の設定
まず、trac設定を作る。YourProjectNameHereはプロジェクト名に変える。
sudo nano /etc/apache2/sites-available/trac
ServerAdmin webmaster@localhost
ServerName trac.example.com
DocumentRoot /usr/share/trac/cgi-bin/
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride All
Order allow,deny
allow from all
Alias /trac "/usr/share/trac/htdocs"
SetEnv TRAC_ENV "/var/lib/trac/YourProjectNameHere"
ErrorLog /var/log/apache2/error.trac.log
次に、AddHandlerのコメントアウトを外す。・・・とあるが、その行が見つからないのでパス。
sudo nano /etc/apache2/apache2.conf
# To use CGI scripts outside /cgi-bin/:
#
AddHandler cgi-script .cgi
バーチャルホストを切り替え、Apache2再起動。
sudo a2dissite default
sudo a2ensite trac
sudo /etc/init.d/apache2 reload
実行結果。
$ sudo a2dissite default
Site default disabled; run /etc/init.d/apache2 reload to fully disable.
$ sudo a2ensite trac
Site trac installed; run /etc/init.d/apache2 reload to enable.
$ sudo /etc/init.d/apache2 reload
* Reloading web server config apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[ OK ]
$
あと、パスワードでログインを保護するために、こんな設定をする。
AuthUserFileは、Apacheの一般的な設定です。
AuthType Basic
AuthName "Trac"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
4. 環境作成
/var/lib/svn/YourProjectNameHere (YourProjectNameHereはプロジェクト名に変える) にSubversionリポジトリを作る。
sudo mkdir /var/lib/svn
sudo mkdir /var/lib/svn/YourProjectNameHere
sudo mkdir /tmp/YourProjectNameHere
sudo mkdir /tmp/YourProjectNameHere/branches
sudo mkdir /tmp/YourProjectNameHere/tags
sudo mkdir /tmp/YourProjectNameHere/trunk
sudo svnadmin create /var/lib/svn/YourProjectNameHere
sudo svn import /tmp/YourProjectNameHere file:///var/lib/svn/YourProjectNameHere -m "initial import"
sudo rm -rf /tmp/YourProjectNameHere
(YourProjectNameHereはプロジェクト名に変える)
sudo chown -R www-data /var/lib/svn/YourProjectNameHere
sudo chown -R www-data /usr/share/trac
sudo apache2 -k restart
警告がでた。
apache2: bad user name ${APACHE_RUN_USER}
www-dataというユーザがないんじゃないの?
原文もこの辺から文字量が多くなってくる。(いろいろなパターンがあるということだろう。)
続けて、Tracの環境を作る(YourProjectNameHereはプロジェクト名に変える)
sudo mkdir /var/lib/trac
Creating a new Trac environment at /var/lib/trac/kawaguti
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]>
プロジェクト名を入力する
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).
そのままエンター
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]>
そのままEnter
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]>
Subversionリポジトリパスを入力
/var/lib/svn/YourProjectNameHere (YourProjectNameHereはプロジェクト名に変える)
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]>
そのままEnter
(中略)
Then point your browser to http://localhost:8000/kawaguti.
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:
Congratulations!
tracプロジェクトディレクトリの権限をApacheに渡す。
(YourProjectNameHereはプロジェクト名に変える)
sudo chown -R www-data /var/lib/trac/YourProjectNameHere
http://localhost/trac は見えるが、プロジェクトは参照できない。
Apacheの設定が間違っているのだと思う。
休憩。
再開。
http://localhost/ をみると、pythonのソースが表示された。
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2003-2004 Edgewall Software
# Copyright (C) 2003-2004 Jonas Borgstrテカm
# All rights reserved.
AddHandlerでcgiを許可しないとダメそう。
sudo nano /etc/apache2/sites-available/trac
(中略)
AddHandler cgi-script .cgi
SetEnv TRAC_ENV "/var/lib/trac/YourProjectNameHere"
Apacheリスタート
$ sudo apache2 -k restart
apache2: bad user name ${APACHE_RUN_USER}
そういやエラーが出ているんだった。直そう。
sudo nano /etc/apache2/apache2.conf
# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
ここはこう↓変えるべきらしい。なるほど。
# These need to be set in /etc/apache2/envvars
User www-data
Group www-data
Apacheリスタート
$ sudo apache2 -k restart
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
httpd not running, trying to start
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
あれ、ポートがふさがっている。
プロセス見てみよう。
root 5936 0.0 0.5 10468 2544 ? Ss 15:27 0:00 /usr/sbin/apache2 -k start
www-data 17831 0.0 0.3 10468 1620 ? S 16:55 0:00 /usr/sbin/apache2 -k start
www-data 17832 0.0 0.6 232072 3016 ? Sl 16:55 0:00 /usr/sbin/apache2 -k start
www-data 17860 0.0 0.5 231940 2956 ? Sl 16:55 0:00 /usr/sbin/apache2 -k start
kawaguti 27004 0.0 0.1 2816 788 pts/0 R+ 18:15 0:00 grep apache
あ、前のが不正なまま残っている。全部killしてもう一回。
$ sudo kill 5936
$ sudo kill 17831
$ sudo kill 17832
$ sudo kill 17860
$ sudo apache2 -k start
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
http://localhost/ をみてみる。
Welcome to Trac 0.10.4
お、うごいたみたい。
日本語化はできてないけど。