UJP - 技術情報1

Life is fun and easy!

不正IP報告数

Okan Sensor
 
メイン
ログイン
ブログ カテゴリ一覧

MacPortでApache1.3.41とPHP5連携

MacPortでApache1.3.41とPHP5.2.5を連携


0.改訂履歴

  • 2008.02.26 新規作成

1.はじめに

 このドキュメントでは,MacPortsでインストールしたApache1.3.41とPHP5.2.5を連携させる手順を説明する.

 普通のMacPortsを使ってApacheとPHP5をインストールするだけでは,Apache側でPHPを認識させるようにインストールされない. これはconfigure時のパラメータがプレインストールされているApache2.xベースとなっているのが原因のためである. この手順書で説明している内容は,configureのパラメータをカスタムで編集してコンパイル&リンクを行う手順として応用できる. また,EDITOR環境変数でviを設定して使っているが,その辺りの説明は省く.

 なお,使用しているOSは,MacOS X 10.4.11で,MacPortsは1.6である.

2.PHP5のconfigureの編集

  • PHP5のインストールファイルを編集する.
gacky:/opt/local/etc/apache root# port edit php5
Error: No EDITOR is specified in your environment
gacky:/opt/local/etc/apache root#							
  • エディタが設定されてないので,環境変数にviを設定する.
gacky:/opt/local/etc/apache root# export EDITOR=vi
gacky:/opt/local/etc/apache root#
  • 再度port edit php5を実行すると,次の様な編集画面となるので,apxsの場所を書き換える.
  • これを実行する事で,apache2.xのapxsからapache1.xへ切り替わる.
変更前
    121 # Build an Apache 1 module. On Mac OS X, it uses Apple's provided Apache 1 server.
    122 # On other platforms, the MacPorts apache port is used. Keep the options here
    123 # in sync with those in the relevant part of the post-destroot phase.
    124 variant apache conflicts apache2 description {for Apple Apache} {
    125         if { ! [variant_isset macosx] } {
    126                 depends_lib-append ¥
    127                         path:${prefix}/sbin/apxs:apache
    128                 configure.args-append ¥
    129                         --with-apxs=${prefix}/sbin/apxs
    130         } else {
    131                 destroot.violate_mtree yes
    132                 configure.args-append ¥
    133                         --with-apxs=/usr/sbin/apxs
    134         }
    135 }
変更後
    121 # Build an Apache 1 module. On Mac OS X, it uses Apple's provided Apache 1 server.
    122 # On other platforms, the MacPorts apache port is used. Keep the options here
    123 # in sync with those in the relevant part of the post-destroot phase.
    124 variant apache conflicts apache2 description {for Apple Apache} {
    125         if { ! [variant_isset macosx] } {
    126                 depends_lib-append ¥
    127                         path:${prefix}/sbin/apxs:apache
    128                 configure.args-append ¥
    129                         --with-apxs=${prefix}/sbin/apxs
    130         } else {
    131                 destroot.violate_mtree yes
    132                 configure.args-append ¥
    133                         --with-apxs=/opt/local/sbin/apxs
    134         }
    135 }
  • 再度インストールする.
gacky:/opt/local/etc/apache root# port install php5 @5.2.5_1+apache+macosx+mysql4+pear
Error: Requested variants do not match original selection.
Please perform 'port clean php5' or specify the force option.
Error: Status 1 encountered during processing.
gacky:/opt/local/etc/apache root#
  • cleanを実行するように指示されたので,実行する.
gacky:/opt/local/etc/apache root# port clean php5
--->  Cleaning php5
gacky:/opt/local/etc/apache root#
  • 成功した模様.
  • 再度インストールを実行する.
gacky:/opt/local/etc/apache root# port install php5 @5.2.5_1+apache+macosx+mysql4+pear
--->  Activating php5 5.2.5_1+apache+macosx+mysql4+pear
--->  Cleaning php5
gacky:/opt/local/etc/apache root#
  • 問題なく完了している...が,リコンパイルされてなさそうである.
  • -fを使って強制再コンパイルを行う.
gacky:/opt/local/etc/apache root# port install -f php5 @5.2.5_1+apache+macosx+
mysql4+pear
--->  Fetching php5
--->  Verifying checksum(s) for php5
--->  Extracting php5
--->  Configuring php5
--->  Building php5 with target all
--->  Staging php5 into destroot
Warning: php5 requests to install files outside the common directory structure!
--->  Installing php5 5.2.5_1+apache+macosx+mysql4+pear
Error: Target org.macports.install returned: Registry error: php5 @5.2.5_1+
apache+macosx+mysql4+pear already registered as installed.  Please uninstall it 
first.
Error: Status 1 encountered during processing.
gacky:/opt/local/etc/apache root# 
  • アンインストールが先だとエラーがでた.
  • アンインストールする.
gacky:/opt/local/etc/apache root# port uninstall -f php5 @5.2.5_1+apache+macosx+mysql4+pear
--->  Deactivating php5 5.2.5_1+apache+macosx+mysql4+pear
--->  Uninstalling php5 5.2.5_1+apache+macosx+mysql4+pear
gacky:/opt/local/etc/apache root# 
  • インストールを行う.
gacky:/opt/local/etc/apache root# port install php5 @5.2.5_1+apache+macosx+mysql4+pear
--->  Installing php5 5.2.5_1+apache+macosx+mysql4+pear

If this is your first install, you might want
 * enable php in apache :

cd /opt/local/libexec/apache
/opt/local/apache/bin/apxs -a -e -n "php5" libphp5.so

* copy  /opt/local/etc/php.ini-dist to  /opt/local/etc/php.ini
--->  Activating php5 5.2.5_1+apache+macosx+mysql4+pear
--->  Cleaning php5
gacky:/opt/local/etc/apache root# 
  • アクティブになった.
  • PHPの共有ライブラリがインストールされているディレクトリを
gacky:/opt/local/etc/apache root# cd /opt/local/libexec/apache
gacky:/opt/local/libexec/apache root# 
  • apxsを実行して,libphp5.soをhttpd.confに登録する.
gacky:/opt/local/etc/apache root# /opt/local/sbin/apxs -a -e -n "php5" libphp5.so
[activating module `php5' in /opt/local/etc/apache/httpd.conf]
cp /opt/local/etc/apache/httpd.conf /opt/local/etc/apache/httpd.conf.bak
cp /opt/local/etc/apache/httpd.conf.new /opt/local/etc/apache/httpd.conf
rm /opt/local/etc/apache/httpd.conf.new
gacky:/opt/local/etc/apache root# 
  • httpd.confに,以下の記述があるか,確認する.
LoadModule php5_module        libexec/apache/libphp5.so

AddModule mod_php5.c
  • この設定により,libphp5.soが有効になる.
  • また,以下の記述を追加する.
AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
  • これによって,拡張子PHPが有効になる.
  • あとは,Apacheが起動していたら,再起動すれば良い.


広告スペース
Google