PHP5をソースからインストール [Debian][PHP]
2008/03/09 Sun [Edit]
【目標】
PHP5をソースからインストール
【環境】
coLinux0.7
Debian GNU/Linux 4.0 (Etch)
Apache2.0.63
GNU Make 3.81
gcc version 4.1.2
PHP5.2.5
参考:
PHP: Apache 2.0 (Unixシステム用) - Manual
1.ソースのDL
2.makefile生成
【コンフィグオプション説明】
PHP: Configure オプション - Manual
3.make
4.php.iniの設定
php.ini-distを元にphp.iniを作成。
【php.ini設定内容】
PHP: php.ini ディレクティブ - Manual
PHP: マルチバイト文字列 - Manual
5.Apacheの設定変更
httpd.confの書き換え
以下を追加。 "AddType" で検索すればそれっぽい箇所があると思います。
Apache再起動
6.確認
ドキュメントルート直下に以下のファイルを作成
ブラウザでアクセスしてみる。
http://hostname/a.php
PHPの設定情報が表示されたら成功です。
PHP5をソースからインストール
【環境】
coLinux0.7
Debian GNU/Linux 4.0 (Etch)
Apache2.0.63
GNU Make 3.81
gcc version 4.1.2
PHP5.2.5
参考:
PHP: Apache 2.0 (Unixシステム用) - Manual
1.ソースのDL
| $ wget http://jp2.php.net/get/php-5.2.5.tar.gz/from/jp.php.net/mirror $ tar xzvf php-5.2.5.tar.gz $ cd php-5.2.5 |
2.makefile生成
| $ ./configure
\ --enable-sigchild \ --enable-mbstring \ --enable-mbregex \ --enable-force-cgi-redirect \ --enable-zend-multibyte \ --with-gd \ --with-jpeg-dir=/usr \ --with-png-dir=/usr \ --with-zlib \ --with-zlib-dir=/usr \ --with-openssl \ --disable-cgi \ --enable-ftp \ --with-curl \ --with-mysql=/usr/local/mysql \ --with-mysql-sock=/tmp/mysql.sock \ --with-mysqli=/usr/local/mysql/bin/mysql_config \ --with-apxs2=/usr/local/apache2/bin/apxs \ --with-mcrypt=/usr/local/lib |
【コンフィグオプション説明】
PHP: Configure オプション - Manual
| --enable-sigchild defunctを防止する。 --enable-mbstring マルチバイト文字列関数を有効にする。 --enable-mbregex マルチバイト正規表現関数を有効にする。 --enable-force-cgi-redirect サーバ内でのリダイレクトの際のセキュリティチェックを有効にする。 Apache で CGI バージョンを稼動させる場合、このオプションを 使用すべきらしい。 --enable-zend-multibyte PHP国際化を有効にする。 --with-gd gdLibraryを使用する。 410 Gone PNGやJPEG、GIF形式のイメージを生成する為のライブラリ。 --with-jpeg-dir=/usr libjpegの場所を指定。 --with-png-dir=/usr libpngの場所を指定。 --with-zlib zlibを使用する。 --with-zlib-dir=/usr zlibの場所を指定。 --with-openssl opensslを使用する。 --disable-cgi PHP の CGI バージョンをビルドしない。 --enable-ftp FTP関数を有効にする。 --with-curl libcurlを使用する。 --with-mysql=/usr/local/mysql mysqlの場所を指定。 --with-mysql-sock=/tmp/mysql.sock phpがmysqlに接続するためのソケットの場所を指定。 --with-mysqli=/usr/local/mysql/bin/mysql_config mysqli 拡張サポート。 PHP: mysqli - Manual MySQL 4.1 以上で提供される機能を利用することができるようになる。 --with-apxs2=/usr/local/apache2/bin/apxs APXSを使ってlibphp5.soを生成する。 --with-mcrypt=/usr/local/lib Mcrypt 暗号化関数を使用する。 |
3.make
| $ make # make install |
4.php.iniの設定
php.ini-distを元にphp.iniを作成。
| # cp /home/onion/src/php-5.2.5/php.ini-dist /usr/local/lib/php.ini |
【php.ini設定内容】
PHP: php.ini ディレクティブ - Manual
PHP: マルチバイト文字列 - Manual
| ;; 出力バッファリングを有効にする output_buffering = On ;; mb_output_handlerによる出力変換を有効にする output_handler = mb_output_handler ;;GET, POST, COOKIE で受け取るデータに含まれる ', ", \, NULL値 をバックスラッシュ (\) で自動エスケープするか magic_quotes_gpc = Off ;; HTTP の Content-Type ヘッダの charset 要素にデフォルトで設定する文字セット default_charset = UTF-8 ;;mbstring (マルチバイト処理) でデフォルトとする言語 mbstring.language = Japanese ;; 内部文字エンコーディングのデフォルト値 mbstring.internal_encoding = EUC-JP ;;HTTP 入力文字エンコーディングのデフォルト値 mbstring.http_input = ASCII,JIS,SJIS,EUC-JP ;; HTTP 出力文字エンコーディングのデフォルト値 mbstring.http_output = UTF-8 ;; 自動エンコード mbstring.encoding_translation = Off ;PHP の文字列中の文字コードを判定するためのコード順 mbstring.detect_order = ASCII,EUC-JP,UTF-8,SJIS,JIS ;;コード変換する際に、コードが変換できない文字とかをどのように扱うかを指定 ;; none は、変換できない文字は出力しない mbstring.substitute_character = none; ;;シングルバイト対応の関数を mbstring 関数の対応する関数でオーバーロード (置換) ;http://jp.php.net/manual/ja/ref.mbstring.php#mbstring.overload ;mail() 関数をオーバーロードするには 1 を指定します。 2 は文字列関数、4 は正規表現関数を表します。つまり、例えば 7 を指定すると、メール関数、文字列関数および正規表現関数が オーバーロードされることになります。 mbstring.func_overload = 7 ;;セッションデータファイルの保存及び検索ディレクトリ session.save_path = "/tmp" ;;ドキュメントルートの指定 doc_root = /usr/local/apache2/htdocs |
5.Apacheの設定変更
httpd.confの書き換え
以下を追加。 "AddType" で検索すればそれっぽい箇所があると思います。
| AddType application/x-httpd-php .php |
Apache再起動
| # /etc/init.d/httpd2 restart |
6.確認
ドキュメントルート直下に以下のファイルを作成
| # vi a.php <?php phpinfo(); ?> |
ブラウザでアクセスしてみる。
http://hostname/a.php
PHPの設定情報が表示されたら成功です。
Comments
Track Backs
TB URL




