VineLinux3.x/Apache2.0/PHP4のインストール

Last-modified: 2018-02-03 (土) 09:34:02 (2267d)

概要

PHP(Hypertext Preprocessor)4をソースからインストールします。

ダウンロードサイト
http://jp2.php.net/downloads.php

apache2のworkerに対応させるためには、先にWebサーバ - Apache2のインストールでapache2をソースからインストールしてください。

設定手順

ダウンロード、解凍

# wget http://jp2.php.net/distributions/php-4.4.0.tar.gz
--15:47:31--  http://jp2.php.net/distributions/php-4.4.0.tar.gz
           => `php-4.4.0.tar.gz'
jp2.php.net をDNSに問いあわせています... 210.138.109.182
jp2.php.net[210.138.109.182]:80 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 4,972,107 [application/x-tar]

100%[==============================================>] 4,972,107      1.10M/s    ETA 00:00

15:47:35 (1.16 MB/s) - `php-4.4.0.tar.gz' を保存しました [4972107/4972107]

# tar zxf php-4.4.0.tar.gz 
# cd php-4.4.0

configureの前にインストールが必要だと思われるパッケージ

# apt-get install flex \
> bzip2-devel \
> MySQL-server MySQL-devel \
> openssl-devel \
> libjpeg-devel zlib-devel libpng-devel \
> t1lib-devel
パッケージリストを読みこんでいます... 完了
依存情報ツリーを作成しています... 完了
* openssl-devel は既に最新バージョンがインストールされています。
以下の追加パッケージがインストールされます:
  t1lib
以下のパッケージが新たにインストールされます:
  MySQL-devel MySQL-server bzip2-devel flex libjpeg-devel libpng-devel t1lib t1lib-devel
  zlib-devel
アップグレード: 0 個, 新規インストール: 9 個, 削除: 0 個, 保留: 0 個
13.0MB のアーカイブを取得する必要があります。
展開後に 32.9MB のディスク容量が追加消費されます。
続行しますか? [Y/n]y
取得:1 http://updates.vinelinux.org 3.1/i386/plus MySQL-server 4.0.23-0vl0 [10.7MB]
取得:2 http://updates.vinelinux.org 3.1/i386/main t1lib 1:5.0.2-0vl1 [162kB]
取得:3 http://updates.vinelinux.org 3.1/i386/plus MySQL-devel 4.0.23-0vl0 [930kB]
取得:4 http://updates.vinelinux.org 3.1/i386/devel bzip2-devel 1.0.2-0vl2 [36.9kB]
取得:5 http://updates.vinelinux.org 3.1/i386/plus flex 2.5.4a-30vl1 [119kB]
取得:6 http://updates.vinelinux.org 3.1/i386/devel libjpeg-devel 6b-21vl2 [167kB]
取得:7 http://updates.vinelinux.org 3.1/i386/devel zlib-devel 1.1.4-0vl3 [64.4kB]
取得:8 http://updates.vinelinux.org 3.1/i386/updates libpng-devel 2:1.2.8-0vl1 [174kB]
取得:9 http://updates.vinelinux.org 3.1/i386/devel t1lib-devel 1:5.0.2-0vl1 [624kB]
13.0MB を 8s 秒で取得しました (1528kB/s)
変更を適用しています...
Preparing...                ########################################### [100%]
   1:MySQL-server           ########################################### [ 11%]
Preparing db table
Preparing host table
Preparing user table
Preparing func table
Preparing tables_priv table
Preparing columns_priv table
Installing all prepared tables
050802 16:23:27 /usr/sbin/mysqld: Shutdown Complete


PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h x22 password 'new-password'
See the manual for more instructions.

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at https://order.mysql.com

   2:t1lib                  ########################################### [ 22%]
   3:MySQL-devel            ########################################### [ 33%]
   4:bzip2-devel            ########################################### [ 44%]
   5:flex                   ########################################### [ 55%]
   6:libjpeg-devel          ########################################### [ 66%]
   7:zlib-devel             ########################################### [ 77%]
   8:libpng-devel           ########################################### [ 88%]
   9:t1lib-devel            ########################################### [100%]
完了

apache2(worker対応)とmysqlを使う場合に必要十分だと思われるオプション例

詳しいオプションは、http://php.s3.to/man/install.configure.html

# ./configure \
--prefix=/usr \
--with-apxs2=/usr/local/apache2/bin/apxs \	←apache2のapxsの場所を指定
--with-config-file-path=/etc \
--with-mysql=/usr \
--with-jpeg-dir=/usr \
--with-zlib-dir=/usr \
--with-bz2 \
--with-openssl \
--with-gd \
--with-t1lib \
--with-ttf \
--enable-exif \
--enable-mbregex \
--enable-mbstring \
--enable-zend-multibyte \
--enable-gd-jis-conv \
--enable-gd-native-ttf
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+
|                          *** NOTE ***                              |
|            The default for register_globals is now OFF!            |
|                                                                    |
| If your application relies on register_globals being ON, you       |
| should explicitly set it to on in your php.ini file.               |
| Note that you are strongly encouraged to read                      |
| http://www.php.net/manual/en/security.globals.php                  |
| about the implications of having register_globals set to on, and   |
| avoid using it if possible.                                        |
+--------------------------------------------------------------------+

Thank you for using PHP.

が出ればOKだす。

ちなみに、PHPがスレッドセーフでコンパイルされるかどうかは、上の画面が出てくるちょっと前のほうに、

Configuring Zend
:
checking whether to enable thread-safety... yes
:

となっているかどうかで分かる。これは、apache2がスレッドセーフ(worker)でインストールされていればyes、そうでなければnoになる。

# make
# make install

php.iniをコピー

# cp php.ini-dist /etc/php.ini

/etc/php.iniの編集

# vi /etc/php.ini
output_buffering	 = On

output_handler		 = mb_output_handler

magic_quotes_gpc = Off

以下は、設定しなくてもよいかも。PHPのソースがEUC-JPで出力をEUC-JPに固定したい場合のみ、設定すればよいかと思います。Shift_JISなどで書かれたPHPを一緒に動かす場合は文字化けします。

default_charset 	 = EUC-JP

mbstring.language = Japanese
mbstring.internal_encoding = EUC-JP
mbstring.http_input  = auto
mbstring.http_output = EUC-JP
mbstring.encoding_translation = On
mbstring.detect_order = auto
mbstring.substitute_character = none

apache2の再起動

# /etc/rc.d/init.d/apache2 restart
httpdを停止中:                                             [  OK  ]
httpdを起動中:                                             [  OK  ]

動作確認

apacheのDocument Rootとして指定しているディレクトリ以下にinfo.phpを作成

# vi /home/httpd/html/info.php

に、

<?php phpinfo() ?>

と記述して保存。

クライアントより、

http://xxxxxx/info.php

で表示されれば完了。

確認が終わったら、info.phpは削除すること。

コメント