« ロゼッタワールドやってみました | メイン | Googleカレンダーの日本の祝日がおかしい »

LeopardでMacPorts(3)PHP5

前々回前回に続いて、PHP5のインストールです。

インストール

まずは、インストールのコマンド。

MacPortsのPHP5で指定できるvariantsは結構種類があります(「port variants php5」で一覧)。
今回は、apache2に対してmysql5も使用することにします。pearも使いたい。

$ sudo port install php5 +apache2 +mysql5 +pear

インストール後、以下3つの操作を行います。

(1)httpd.conf にLoadModuleを追加する

$ cd /opt/local/apache2/modules
$ sudo /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so

指示通りのコマンド実行で/opt/local/apache2/conf/httpd.conf にLoadModule行が追加されます(sudoだけ追加してます)。

(2)php.iniの配置

$ sudo cp /opt/local/etc/php.ini-dist /opt/local/etc/php.ini

とりあえずは素のままで。

(3)Apacheの設定ファイルでAddTypeする

/opt/local/apache2/conf/extras-confディレクトリにmod_php.confがインストールされているので、これをインクルードする定義をhttpd.confに加えます。

[httpd.conf]
# PHP
Include conf/extras-conf/mod_php.conf

動作確認

Apacheを再起動&phpinfo()を実行して動作確認します。
CLI版も試しておきましょう。

$ /opt/local/bin/php -v
PHP 5.2.5 (cli) (built: Nov 18 2007 13:42:29)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

pearも確認。

$ pear list

インストールオプションについて

phpinfo()すれば、インストールされたモジュールのコンパイルオプションはわかるんですが、MacPortsのvariantsとの関係を探ってみました。

「/opt/local/var/macports/sources/rsync.macports.org/release/ports/www/php5/Portfile」を見てみると、なにやら見たことのあるコンパイルオプションらしき記述がありました。

configure.args \
--mandir=${prefix}/share/man \
--infodir=${prefix}/share/info \
--with-config-file-path=${prefix}/etc \
--enable-calendar \
--with-iconv=${prefix} \
--enable-exif \
--enable-ftp \
--enable-wddx\
--with-zlib=${prefix} \
--with-bz2=${prefix} \
--without-mysql \
--without-sqlite \
--without-pdo-sqlite \
--with-libxml-dir=${prefix} \
--with-gettext=${prefix} \
--with-xml \
--with-expat-dir=${prefix} \
--with-xmlrpc \
--enable-soap \
--enable-filepro \
--enable-bcmath \
--enable-trans-sid \
--enable-mbstring \
--enable-dbx \
--enable-dba \
--with-openssl=${prefix} \
--with-mhash=${prefix} \
--with-mcrypt=${prefix} \
--with-xsl=${prefix} \
--with-curl=${prefix} \
--with-pcre-regex=${prefix} \
--with-gd \
--with-jpeg-dir=${prefix} \
--with-png-dir=${prefix} \
--enable-gd-native-ttf \
--without-pear \
--with-freetype-dir=${prefix}

variantsにあるmysql関連やpearはwithoutされてます。

同じPortfile中で、variant mysql5、variant pearの辺りを見ると、さらにコンパイルオプションを書き換えているようです。ちゃんとしたPortfileの記法はわかりませんが、元のコンパイルオプションを知ってるんで、なんとなく把握できたかな。

やらないと思うけど、Portfileを書き換えれば、好きなコンパイルオプションに変更できるんだろうな。

バージョンの違い

ちなみに。現在のMacPortsではPHP 5.2.5がインストールされましたが、Mac OS Xに元から入ってるのは、こんなバージョンです。

[Leopard]
$ /usr/bin/php -v
PHP 5.2.4 (cli) (built: Sep 23 2007 22:34:35)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

[Tiger]
$ /usr/bin/php -v
PHP 4.4.7 (cli) (built: Jul 10 2007 10:54:32)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

Technorati Tags: ,

トラックバック

このページのトラックバックURL:
http://www.typepad.jp/t/trackback/232075/10698735

このページへのトラックバック一覧 LeopardでMacPorts(3)PHP5:

コメント

コメントを投稿

Apple Store(Japan)



2008年11月

            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            

最近買った本

Powered by TypePad