LeopardでMacPorts(3)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








コメント