T:freebsd:mediawiki

出典: Tariki

目次

8/12: Mediawikiのインストール @7.1beta

実は順番が逆。必要なものをインストールして動かなければ足りないものをインストール、という無計画インストールをしたから。それと、まっさらサーバ(学科ネット管理用)で、Apache2.2 (あとCybozu Office 7) のみインストール後の状態からスタートしたので。

MediaWikiのインストール

  • cd /usr/ports/www/mediawiki/ →MediaWikiはバージョン1.13.0
    Lynxからオプション選択。PostgreSQLを用い(2007. 4ころ試したらできていなかったので断念)、TeX数式を書けるようにする。
  • make install
  • short URLなど使う気はないので、とりあえず cd /usr/local/www/apache22/data; ln -s /usr/local/www/mediawiki .

ここまででMediaWiki単体でのインストールは終わり。ただし動かない。

PHPのインストール

  • cd /usr/ports/www/php5-5.2.6.2/
    実は上記MediaWikiインストールでこのバージョンのPHPが関連インストールされている。が、肝心のApacheモジュールがないため以下で作り直し。
  • make clean
  • makeでLynxメニューからApacheモジュールを追加。ついでにマルチバイトも活かしたかな?
  • setenv FORCE_PKG_REGIStERしてmake install
    apacheが既に稼動していたらapachectl stop→start

PostgreSQLのインストール

  • cd /usr/ports/databases/pgsql8.2-server; make install
  • make終了のログ:
For procedural languages and postgresql functions, please note that
you might have to update them when updating the server.

If you have many tables and many clients running, consider raising
kern.maxfiles using sysctl(8), or reconfigure your kernel
appropriately.

The port is set up to use autovacuum for new databases, but you might
also want to vacuum and perhaps backup your database regularly. There
is a periodic script, /usr/local/etc/periodic/daily/502.pgsql, that
you may find useful. You can use it to backup and perfom vacuum on all
databases nightly. Per default, it perfoms `vacuum analyze'. See the
script for instructions. For autovacuum settings, please review
~pgsql/data/postgresql.conf.

To allow many simultaneous connections to your PostgreSQL server, you
should raise the SystemV shared memory limits in your kernel. Here are
example values for allowing up to 180 clients (configurations in
postgresql.conf also needed, of course):
  options         SYSVSHM
  options         SYSVSEM
  options         SYSVMSG
  options         SHMMAXPGS=65536
  options         SEMMNI=40
  options         SEMMNS=240
  options         SEMUME=40
  options         SEMMNU=120

If you plan to access your PostgreSQL server using ODBC, please
consider running the SQL script /usr/local/share/postgresql/odbc.sql
to get the functions required for ODBC compliance.

Please note that if you use the rc script,
/usr/local/etc/rc.conf/postgresql, to initialize the database, unicode
(UTF-8) will be used to store character data by default.  Set
postgresql_initdb_flags or use login.conf settings described below to
alter this behaviour. See the start rc script for more info.

To set limits, environment stuff like locale and collation and other
things, you can set up a class in /etc/login.conf before initializing
the database. Add something similar to this to /etc/login.conf:
---
postgres:\
        :lang=en_US.UTF-8:\
        :setenv=LC_COLLATE=C:\
        :tc=default:
---
and run `cap_mkdb /etc/login.conf'.
Then add 'postgresql_class="postgres"' to /etc/rc.conf.

======================================================================

To initialize the database, run

  /usr/local/etc/rc.d/postgresql initdb

You can then start PostgreSQL by running:

  /usr/local/etc/rc.d/postgresql start

For postmaster settings, see ~pgsql/data/postgresql.conf

NB. FreeBSD's PostgreSQL port logs to syslog by default
    See ~pgsql/data/postgresql.conf for more info

======================================================================

To run PostgreSQL at startup, add
'postgresql_enable="YES"' to /etc/rc.conf

======================================================================
===> Installing rc.d startup script(s)
===>   Registering installation for postgresql-server-8.2.9
===> SECURITY REPORT:
      This port has installed the following files which may act as network
      servers and may therefore pose a remote security risk to the system.
/usr/local/bin/postgres

      This port has installed the following startup scripts which may cause
      these network services to be started at boot time.
/usr/local/etc/rc.d/postgresql

      If there are vulnerabilities in these programs there may be a security
      risk to the system. FreeBSD makes no guarantee about the security of
      ports included in the Ports Collection. Please type 'make deinstall'
      to deinstall the port if this is a concern.

      For more information, and contact details about the security
      status of this software, see the following webpage:
http://www.postgresql.org/
  • /etc/rc.confに以下を追加。
postgresql_enable="YES"
# optional
postgresql_data="/usr/local/pgsql/data"
postgresql_flags="-w -s -m fast"
postgresql_initdb_flags="--encoding=utf-8 --lc-collate=C"
postgresql_class="default"
  • 下記ではユーザpgsqlのログイン環境で日本語を設定しているが、上記はC。どっちが優先されるんでしょう?
  • ~pgsqlさんの.cshrc、.profileに下記を追加。DBを生で使うかどうか分からないのだけど日本語をLOCALEに設定。MediaWikiからどう見えるかわからないのだけどTZを設定。以下、雛形の書き換え。
setenv PGLIB /usr/local/lib

# note: PGDATA can be overridden by the -D startup option
setenv PGDATA $HOME/data

#You might want to set some locale stuff here
#setenv PGDATESTYLE ISO
#setenv LC_ALL sv_SE.ISO_8859-1
setenv PGDATESTYLE ISO
setenv LC_ALL ja_JP.eucJP
# if you want to make regression tests use this TZ
#setenv TZ PST8PDT
setenv TZ JST-9
PGLIB=/usr/local/lib

# note: PGDATA can be overridden by the -D startup option
PGDATA=${HOME}/data

export PATH PGLIB PGDATA

# if you use the periodic script from share/postgresql/502.pgsql, you
# can set these
PGDUMP_ARGS="-b -F c"
PGBACKUPDIR=${HOME}/backups
PGBACKUP_SAVE_DAYS=7
export PGBACKUPDIR PGDUMP_ARGS PGBACKUP_SAVE_DAYS

#You might want to set some locale stuff here
#PGDATESTYLE=ISO
#LC_ALL=sv_SE.ISO_8859-1
PGDATESTYLE=ISO
LC_ALL=sv_ja_JP.eucJP
#export PGDATESTYLE LC_ALL
export PGDATESTYLE LC_ALL

# if you want to make regression tests use this TZ
#TZ=PST8PDT
#export TZ
TZ=JST-9
export TZ
  • /usr/local/etc/rc.d/postgresql initdb
    以下は実行時のログ。
Filerna tillh"orande databasen kommer att "agas av anv"andaren "pgsql".
Denna anv"andare maste ocksa k"ora server-processen.

Databasklustret kommer initieras med lokalen C.

skapar katalog /usr/local/pgsql/data ... ok
skapar underkataloger ... ok
v"aljer initialt v"arde f"or max_connections ... 40
v"aljer initialt v"arde f"or shared_buffers/max_fsm_pages ... 28MB/179200
skapar konfigurationsfiler ...ok
skapar databasen template1 i /usr/local/pgsql/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

VARNING: slar pa autentiseringsmetod "trust" f"or lokala anslutningar.
Du kan "andra detta genom att redigera pg_hba.conf eller anv"anda
flaggan -A n"asta gang du k"or initdb.

Success. You can now start the database server using:

    /usr/local/bin/postgres -D /usr/local/pgsql/data
or
    /usr/local/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
  • /usr/local/etc/rc.d/postgresql start

MediaWiki DB、ユーザの追加

  • createuser -U pgsql -S -D -R -P -E wikiuser
    パスワードを設定
  • createdb -U pgsql -O wikiuser -E UTF-8 wikidb
    defaultのwikiuser/wikidbで使うことを仮定
  • cd work/postgresql-8.2.9/contrib/tsearch2/; gmake all; gmake install
    全文検索のためtsearch2をインストール
  • createlang -U pgsql plpgsql wikidb
  • psql -U pgsql wikidb < tsearch2.sql
  • as# psql -U pgsql wikidb
Welcome to psql 8.2.9, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

wikidb=# \d
           List of relations
 Schema |     Name     | Type  | Owner
--------+--------------+-------+-------
 public | pg_ts_cfg    | table | pgsql
 public | pg_ts_cfgmap | table | pgsql
 public | pg_ts_dict   | table | pgsql
 public | pg_ts_parser | table | pgsql
 public | test_tsquery | table | pgsql
(5 rows)

wikidb=# ALTER TABLE pg_ts_cfg OWNER TO wikiuser;
ALTER TABLE
wikidb=# ALTER TABLE pg_ts_cfgmap OWNER TO wikiuser;
ALTER TABLE
wikidb=# ALTER TABLE pg_ts_dict OWNER TO wikiuser;
ALTER TABLE
wikidb=# ALTER TABLE pg_ts_parser OWNER TO wikiuser;
ALTER TABLE
wikidb=# \q

MediaWikiの初期設定

  • ブラウザで MediaWikiのURL/config/index.php にアクセス
    • Wiki名、メールアドレス、言語、各種パスワードの設定程度であとはデフォルト
  • cd /usr/local/www/mediawiki/; mv config/LocalSettings.php .

参考