Foswiki

提供: ArchWiki
2017年10月20日 (金) 21:41時点におけるKusakata (トーク | 投稿記録)による版 (カテゴリ変更)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
ナビゲーションに移動 検索に移動

Foswiki は Perl で書かれたフリーのエンタープライズコラボレーションプラットフォームです。ユーザーとオープンソースコミュニティによって開発・サポート・メンテナンスされています。

詳しくは wikipedia:FoswikiFoswiki のウェブサイト を参照してください。

同じようなニーズに応える Java ベースのソフトウェアとして XWiki も存在します。

インストール

ノート: 以下の理由から AUR には foswiki パッケージが存在しません:
  • 現在のところ Foswiki にはアップグレードするたびに作業が必要になります。
  • Foswiki にはプラグインをインストール・アップデート・削除する便利なシステムが存在しますが、インストールディレクトリに書き込みが行えないと機能しません。

以下の手順では Foswiki のインストール場所として /srv/http/foswiki ディレクトリを使用します。

Foswiki Installation Guide には詳しい説明があり (すこし多すぎるくらいです)、資料として役に立ちます。公式ガイドに概ね従いつつ、Arch Linux 固有の設定事項に注意してください。

  • Foswiki ウェブサイト から最新のリリースを入手してください。
  • アーカイブをダウンロードしたら http ユーザーとして /srv/http/foswiki に展開します。例 (root で実行):
# su -s /bin/bash - http
$ mkdir /tmp/foswiki
$ cd /tmp/foswiki
$ wget <archive-url>
$ tar xzf Fos*
$ rm *.tgz
$ exit
# mv /tmp/foswiki/* /srv/http/foswiki
# rmdir /tmp/foswiki
# cd /srv/http/foswiki
  • 必要に応じて、インストールディレクトリのアクセス権限を制限してください:
# chmod o-rx .
  • この段階で、全てのファイルのパーミッションが正しいことを確認してください (詳しくは Foswiki ガイドの Setting File Access Permissions を参照)。
ファイルのパーミッションが適切かどうか確認したい場合、find を使うことでパーミッションをテストできます。例えば、以下のコマンドはアクセスモードが 755 に設定されていないディレクトリが存在するか確認します:
# find . -type d \! -perm 755
バージョン 1.1.5 現在、所有者しか書き込めないように誤って設定されているファイルがひとつだけ存在します。他のファイルはアーカイブから展開したときのままでパーミッションは問題ありません。以下のコマンドを使うことで正しいパーミッションを設定し (root または http で実行)、同じ問題が起こる可能性のあるファイルを取得します:
$ find pub data -name '*,v' -type f -exec chmod 444 \{\} \;
  • bin/LocalLib.cfg.txtbin/LocalLib.cfg にコピーしてください。所有者とアクセス権限が元のファイルと同じであることを確認してください。
  • 新しくコピーしたファイルを編集して $foswikiLibPath 行を以下のようにしてください:
$foswikiLibPath = '/srv/http/foswiki/lib';

Apache

Foswiki インストールガイドの Configure the Webserver セクションを見て Apache を設定してください。

Nginx

Nginx で Foswiki を使うのは厄介ですが、以下で全て説明します。必要に応じて変更ができるように、設定にはコメントを付します。

Foswiki は Perl で書かれており一連の CGI スクリプトとして実行されるようになっています。FastCGI アプリケーションとして Foswiki を実行したい場合は FastCGIEngineContrib を確認してください。ただし FastCGI を使用した場合、一部のプラグインが動作しません。

  • fcgiwrap をインストールしてください (Nginx#手順1: fcgiwrap を参照)。ここではソケットを使って fcgiwrap をセットアップした環境を使います。
  • /etc/nginx/foswiki.conf という名前のファイルを以下の内容で作成します:
location /bin/configure {
  # It is important to protect this location with a password.
  auth_basic "Restricted";
  auth_basic_user_file htpasswd/foswiki-configure;
  # (Temporarily?) allow an IP address below for configuration access
  #allow 127.0.0.1;
  deny all;
  fastcgi_pass fcgiwrap;
  include      fastcgi.conf;
  fastcgi_split_path_info ^(/bin/configure)(.*);
  fastcgi_param PATH_INFO $fastcgi_path_info;
}
location /bin/ {
  fastcgi_pass fcgiwrap;
  include      fastcgi.conf;
  fastcgi_split_path_info ^(/bin/\w+)(.*);
  fastcgi_param PATH_INFO $fastcgi_path_info;
  # Setting the NO_FOSWIKI_SESSION environment variable prevents a
  # session being created. If a bot is spawning too many sessions, add its
  # user agent string to this regexp.
  set $no_foswiki_session "";
  if ($http_user_agent ~* "^gsa-crawler") {
    set $no_foswiki_session true;
  }
  fastcgi_param NO_FOSWIKI_SESSION $no_foswiki_session;
  # This prevents the %INCLUDE% macro from including our own topics as URLs
  # and also prevents other Foswikis from doing the same. This is important to
  # prevent the most obvious Denial of Service attacks.
  if ($http_user_agent = "") { return 403; }
}
# Contains public-facing files.
# The rewrite rule is necessary for enforcing access policies. Otherwise,
# access would be free to this directory. Comment it out if you do not like
# the performance hit (but see /pub/... locations below).
location /pub/ {
  rewrite ^/pub/(.*)$ /bin/viewfile/$1 last;
}
# Prevent HTML attachments from rendering directly in the browser; it could
# potentially be a security risk.
location ~* /pub/.*\.html?$ {
  types {}
  default_type application/octet-stream;
}
# These locations contain CSS, JS, and other assets that are trusted and really
# need to be cached, and that we do not want going through CGI for reasons of
# performance. The ^~ prefix prevents the above HTML security fix from applying
# to these locations (e.g. WYSIWYG uses some HTML from /pub/System).
location ^~ /pub/System/ {  # General system support files
}
location ^~ /pub/Main/SitePreferences/ {  # Attachments for site logos etc...
}
# Anything in the Trash should not be visible.
# This is not necessary if access policies are being enforced for the /pub
# directory through the rewrite rule above.
#location /pub/Trash {
#  deny all;
#}
location /robots.txt {
}
# Pretty URLs: /Main/Foo, /edit/Main/Foo, etc...
location / {
  rewrite ^/(?:[A-Z].*)?$ /bin/view$uri last;
  rewrite ^/([a-z]+/[A-Z].*) /bin/$1 last;
  # The above should catch most day-to-day things. This is for some more unusual
  # situations (e.g. when Main requires authentication, when resubmitting a
  # form, maybe some other situations):
  rewrite ^ /bin$uri last;
}
警告: 本番環境で作業する場合、ファイル上部の allow ディレクティブに注意してください。configure スクリプトへのアクセスが不要な場合、コメントアウトしたままにしてください。Foswiki のセキュリティホールとなる可能性があるため、必要なければ使えないようにしたほうが安全です。
  • ファイル上部の allow ディレクティブをアンコメントして、127.0.0.1 をあなたのローカルマシンの IP アドレスに置き換えてください。
  • /etc/nginx/nginx.conf にある nginx のメイン設定ファイルに新しく server セクションを追加してください。例:
server {
  listen 80;
  server_name foswiki;
  root /srv/http/foswiki;

  include foswiki.conf;
}
  • foswiki.conf ファイルから参照できるように、nginx.confserver ブロックの前に upstream ブロックを追加してください:
upstream fcgiwrap {
  server unix:/var/run/fcgiwrap.sock;
}
  • Nginx Wiki の手順 に従って、必要な場所に htpasswd ファイルを作成してください。上記の設定ではファイルの場所は /etc/nginx/htpasswd/foswiki-configure としています。ファイルのパーミッションは適切に設定してください。例えば root で以下のコマンドを実行:
# mkdir -p /etc/nginx/htpasswd
# cd /etc/nginx/htpasswd
# printf "admin:$(openssl passwd -crypt <YOURPASSWORD>)\n" >> foswiki-configure
# chgrp http foswiki-configure
# chmod 640 foswiki-configure
  • ブラウザで /configure の URL を開いてください。例: http://foswiki/configure.
  • General Path Settings セクションで、{ScriptUrlPaths}{view} 設定の中身を削除してください。完全に空白にする必要があります (これで Nginx で設定した URL が使われるようになります)。
  • 他の設定は問題ありません。"Save Changes" を押して設定を保護するパスワードを設定してください (HTTP ベーシック認証と同じパスワードを設定すると良いでしょう)。
  • Foswiki の設定を確認して、もういちど保存してください。
  • /etc/nginx/foswiki.conf の上部にある allow ディレクティブをコメントアウトして configure スクリプトを使えないようにしてください。
  • これで Foswiki のインストールは完了です。

インストール後の設定

wiki がセットアップできたら、以下の cron ルールを設定すると良いでしょう:

アップグレード

公式の Foswiki Upgrade Guide にアップグレードする手順が載っています。古い環境で使っていたプラグインのインストールを忘れないでください。lib/Foswiki/Plugins ディレクトリを比較すると簡単です。アップグレードで一番面倒なのは古い環境から新しい環境へのトピックのコピーです。自動で行うスクリプトが存在し、古い環境で変更を加えたコアトピックのマージだけに作業を減らせます。

スクリプトは https://github.com/giddie/bits-n-pieces/blob/master/Foswiki/foswiki-copy に存在します。

  • diff (またはその亜種) を使って手動でマージが必要なトピックや lib/LocalSite.cfg を比較してください。
  • Foswiki で元の中身の版を保存したい場合、ウェブインターフェイスを使ってトピックを編集すると良いでしょう。
  • 以下のファイルをコピーしてください:
    • リビジョンデータが含まれている <topic>.txt,v ファイル。
    • 手動でマージするトピックの pub フォルダ。
    • ユーザーのパスワードハッシュが含まれている data/.htpasswd ファイル。