Solaris10 on WebServer (PHPの設定)


4−1 PHPのダウンロード

現時点で一番新しいと思われるPHP-4.4.9をhttp://jp2.php.netからwgetで落とし、/tmpに解答しました。

後術するphpMyAdminをインストールした時点で問題が有るかもしれない事が判明しましたが、こちらでは解決していませんのでインストールするバージョンには注意してください。

# cd /tmp
# wget http://jp2.php.net/get/php-4.4.9.tar.gz/from/jp.php.net/mirror
# gtar xfz php-4.4.9.tar.gz

4−2 前準備

解凍したディレクトリに入りINSTALLのドキュメントを見てインストール先ディレクトリ等を決めます。出来るだけSolarisの標準に合わせようと思いましたが今回は/usr/localに入れる事にしてディレクトリを作成しました。

$ su
# mkdir /usr/local
# exit

4−3 Make

Makeの前にオプションを付けてconfigureスクリプトを実行しMakefileを作成します。

オプション 内容
-prefix=/usr/local インストール先ディレクトリ
-with-mysql MySQLを使用する
-with-gd GDライブラリを使用する
-with-zlib ZLIBを使用する
-enable-mbstring マルチバイト文字への対応
-enable-mbregex マルチバイト文字を使用する
-with-apxs2=/usr/apache2/bin/apxs Apacheの拡張モジュールの作成

どのようにMakeするかを決定したらMakefileの作成を行います。

$ cd /tmp/php-4.4.9
$ ./configure --prefix=/usr/local \
> --with-mysql --with-gd --with-zlib --enable-mbstring \
> --enablembregex --with-apxs=/usr/apache2/bin/apxs

「Than you for using PHP.」等のメッセージが表示されmakefileが正常に作成されたらmakeを実行します。

$ make

「Build complete.」と表示されたら成功です。失敗した場合にはPATH設定等を見直すと解決するかもしれません。
続いてroot権限でインストールを実行します。

$ su
# make install

4−4 httpd.confの修正

apacheからPHPが参照できるように、httpd.confにいくつか修正を加えます。

    :
  { 略 }
    :
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
# The index.html.var file (a type-map) is used to deliver content-
# negotiated documents. The MultiViews Option can be used for the
# same purpose, but it is much slower.
#
DirectoryIndex index.html index.html.var
index.php
    :
  { 略 }
    :
#
# Specify a default charset for all pages sent out. This is
# always a good idea and opens the door for future internationalisation
# of your web site, should you ever want it. Specifying it as
# a default does little harm; as the standard dictates that a page
# is in iso-8859-1 (latin1) unless specified otherwise i.e. you
# are merely stating the obvious. There are also some security
# reasons in browsers, related to javascript and URL parsing
# which encourage you to always set a default char set.
#
#AddDefaultCharset ISO-8859-1
AddDefaultCharset none
    :
  { 略 }
    :
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php .phtml
    :
  { 略 }
    :

4−5 php.iniの作成

/usr/local/lib/phpにphp.iniと言うファイルを作成します。php.iniの中に記述する設定は多くあるようですが端折る事にします。

; php.ini
doc_root=/var/apache2/htdocs

これでPHPのインストールと設定は終了です。apacheに認識させるにはapacheを再起動します。

# svcadm disable apache2
# svcadm refresh apache2
# svcadm enable apache2

[前へ] [目次] [次へ]