PHP 4.4.1をVineLiuxにインストールする方法

PHP Evo

PHP 4.4.1のインストール

ProEvo / PHP Evo / PHP 4.4.1のインストール

PHP 4.4.1をVineLinux+Apache2にインストールする方法


1. PHPとは何か?

1.1 PHPについて

PHPは、主にWebアプリケーションをつくるためのスクリプト言語です。
次のような特徴があり、Webアプリケーションの構築に使われています。

1.2 PHPを手に入れる

2005-12-11現在の最新VersionはPHP 5.1.1です。また、前のメジャーバージョンであるPHP4系列では、PHP4.4.1がリリースされています。
今回はPHP4系列の最終Versionである、PHP4.4.1を手に入れることにします。

PHPは、PHP公式サイトからダウンロードできます。
ダウンロードの方法は、PHP 4.3.11のインストール - PHPを手に入れるを参照してください。

2. PHP 4.4.1のインストール

2.1 PHP 4.4.1をインストールする

1.2でダウンロードしたtarball(.tar.bz2という拡張子のアーカイブファイルを使って、PHP4.4.1をインストールします。
次の手順で、PHP 4.4.1をインストールします。

  1. アーカイブファイルを作業ディレクトリにコピーします。
    [atsushifx@agartha 4.x]$ cp php-4.4.1.tar.bz2 /usr/local/src/
  2. コピーしたアーカイブファイルを展開します。
    [atsushifx@agartha 4.x]$ cd /usr/local/src
    [atsushifx@agartha src]$ tar zxvf php-4.4.1.tar.bz2
    [atsushifx@agartha src]$ cd php-4.4.1
  3. configureを実行します。 [atsushifx@agartha php 4.4.1]$ ./cf
    ./cf
    ./configure \
     --mandir=/usr/local/man \
     --with-apxs2=/usr/local/apache/bin/apxs \
     --enable-cli --disable-cgi \
     --enable-mbstring=shared --enable-zend-multibyte \
     --enable-memory-limit \
     --with-zlib \
     --with-iconv=shared --enable-ctype=shared --with-pcre-regex=shared \
     --enable-posix=shared --enable-overload=shared --enable-session=shared \
     --without-mysql \
     --with-gnu-ld
    
  4. PHPをコンパイルします。 [atsushifx@agartha php 4.4.1]$ make
  5. PHPをインストールします。
    
    [atsushifx@agartha php 4.4.1]$ su
    Password: ********
    [atsushifx@agartha php 4.4.1]$ make install
    /bin/sh /usr/local/src/php-4.4.1/libtool --silent --preserve-dup-deps --mode=install cp ext/posix/posix.la /usr/local/src/php-4.4.1/modules
    PATH="$PATH:/sbin" ldconfig -n /usr/local/src/php-4.4.1/modules
    ----------------------------------------------------------------------
    Libraries have been installed in:
       /usr/local/src/php-4.4.1/modules
    
    If you ever happen to want to link against installed libraries
    in a given directory, LIBDIR, you must either use libtool, and
    specify the full pathname of the library, or use the `-LLIBDIR'
    flag during linking and do at least one of the following:
       - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
         during execution
       - add LIBDIR to the `LD_RUN_PATH' environment variable
         during linking
       - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
       - have your system administrator add LIBDIR to `/etc/ld.so.conf'
    
    See any operating system documentation about shared libraries for
    more information, such as the ld(1) and ld.so(8) manual pages.
    ----------------------------------------------------------------------
    /bin/sh /usr/local/src/php-4.4.1/libtool --silent --preserve-dup-deps --mode=install cp ext/session/session.la /usr/local/src/php-4.4.1/modules
    PATH="$PATH:/sbin" ldconfig -n /usr/local/src/php-4.4.1/modules
    ----------------------------------------------------------------------
    Libraries have been installed in:
       /usr/local/src/php-4.4.1/modules
    
    If you ever happen to want to link against installed libraries
    in a given directory, LIBDIR, you must either use libtool, and
    specify the full pathname of the library, or use the `-LLIBDIR'
    flag during linking and do at least one of the following:
       - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
         during execution
       - add LIBDIR to the `LD_RUN_PATH' environment variable
         during linking
       - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
       - have your system administrator add LIBDIR to `/etc/ld.so.conf'
    
    See any operating system documentation about shared libraries for
    more information, such as the ld(1) and ld.so(8) manual pages.
    ----------------------------------------------------------------------
    Installing PHP SAPI module:       apache2handler
    /usr/local/apache/build/instdso.sh SH_LIBTOOL='/usr/local/apache/build/libtool' libphp4.la /usr/local/apache/modules
    /usr/local/apache/build/libtool --mode=install cp libphp4.la /usr/local/apache/modules/
    cp .libs/libphp4.so /usr/local/apache/modules/libphp4.so
    cp .libs/libphp4.lai /usr/local/apache/modules/libphp4.la
    libtool: install: warning: remember to run `libtool --finish /usr/local/src/php-4.4.1/libs'
    chmod 755 /usr/local/apache/modules/libphp4.so
    [activating module `php4' in /usr/local/apache/conf/httpd.conf]
    Installing PHP CLI binary:        /usr/local/bin/
    Installing PHP CLI man page:      /usr/local/man/man1/
    Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts-20020429/
    Installing PEAR environment:      /usr/local/lib/php/
    [PEAR] Archive_Tar    - installed: 1.1
    [PEAR] Console_Getopt - installed: 1.2
    [PEAR] PEAR           - installed: 1.3.6
    Wrote PEAR system config file at: /usr/local/etc/pear.conf
    You may want to add: /usr/local/lib/php to your php.ini include_path
    [PEAR] HTML_Template_IT- installed: 1.1
    [PEAR] Net_UserAgent_Detect- installed: 2.0.1
    [PEAR] XML_RPC        - installed: 1.4.0
    Installing build environment:     /usr/local/lib/php/build/
    Installing header files:          /usr/local/include/php/
    Installing helper programs:       /usr/local/bin/
      program: phpize
      program: php-config
    Installing man pages:             /usr/local/man/man1/
      page: phpize.1
      page: php-config.1
    [atsushifx@agartha php 4.4.1]$

以上でPHPのインストールは終了です。

2.2 PHPをApache2に組み込む

Apache2でPHPを動作させるため、Apache2の設定ファイルを書き換えてPHPをApache2に組み込みます。
組み込みの手順は次のとおりになります。

  1. /usr/local/apache/conf/httpd.confを次のように書き換える
    /usr/local/apache/conf/httpd.conf
    1025|# PHP 組み込み
    1026|LoadModule php4_module modules/libphp4.so
    1027|AddModule mod_php4.c
    1028|AddType application/x-httpd-php .php .inc .phtml
    
  2. Apacheを再起動する
    [root@agartha apache]# /etc/init.d/httpd restart

以上でPHPの組み込みは終了です。

2.3 PHPを設定する

PHPの動作を制御するため、php.iniを設定します。
次のようにphp.iniを書き換えます。

/usr/local/lib/php.ini
 285|error_reporting  =  E_ALL

 292|display_errors = On

 297|display_startup_errors = On

 302|log_errors = On

 327|html_errors = On

 346|error_log = php_error.log

 418|default_charset = "UTF-8"

 430|include_path = ".:/usr/local/lib/php"

 447|extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20020429/"

 555|; Linux Extensions
 556|extension=ctype.so
 557|extension=iconv.so
 558|extension=mbstring.so
 559|extension=overload.so
 560|extension=pcre.so
 561|extension=posix.so
 562|extension=session.so


1051|[mbstring]
1054|mbstring.language = Japanese
1055|mbstring.internal_encoding = UTF-8
1056|mbstring.script_encoding = UTF-8
1057|mbstring.http_input = auto
1058|mbstring.http_output = SJIS-win

設定を反映させるため、Apacheを再起動します。
[root@agartha lib]$ /etc/init.d/httpd

設定項目をphpinfoで確認し、正しく設定されていればPHPの設定は終了です。



$Revision: 2 $
$Date: 2007-02-28 23:35:40 +0900 (豌エ, 28 2譛 2007) $