PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Mac OS X へのインストール> <Unix システムへのインストール
Last updated: Fri, 05 Sep 2008

view this page in

Debian GNU/Linux へのインストール

このセクションでは、» Debian GNU/Linux に PHP をインストールする際の注意事項とヒントについて説明します。

APT の使用

PHP のソースコードをダウンロードし自分でコンパイルすることも可能ですが、 Debian のパッケージシステムを使用することが、もっともシンプルでクリーンな インストール方法です。Linux でのソフトウエアのビルドに不慣れならば、 この方法を取るのが良いでしょう。

最初に決めなければいけないのは、Apache 1.3.x と Apache 2.x のどちらを インストールするかです。それぞれに対応するパッケージは、 libapache-mod-php* および libapache2-mod-php* という名前です。 以下では、Apache 1.3.x を使用する場合について説明します。 また、現在のところ、PHP 5 の Debian 公式パッケージはありません。 ですので、PHP 4 のインストールについて解説します。

Debian では、PHP を CGI や CLI として使用することもできます。 それぞれ、php4-cgi と php4-cli という名前が付けられています。 これらが必要な場合は、下記のステップを対応する名前でもって行ってください。 また、特別なパッケージとしては、さらに、php4-pear があります。 これは、pear コマンドラインユーティリティ および PEAR の最小限の部分がインストールされるものです。

Debian の安定版のパッケージよりも新しいパッケージが必要な場合や、 Debian の公式レポジトリに含まれない PHP 拡張モジュールが必要な場合は、 » http://www.apt-get.org/ を探してみると 良いかもしれません。たとえば、» Dotdeb などが見つかるでしょう。この非公式レポジトリは » Guillaume Plessis が管理しており、最新版の PHP 4 および PHP 5 の Debian パッケージがアップされています。このリポジトリを使用するには、以下の2行を /etc/apt/sources.lists に追加し、apt-get update を実行します。

例1 Dotdeb 関連の apt line

deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all

パッケージのリストが最新であるかにも注意を払う必要があります。 パッケージの更新をしばらく行っていないのならば、apt-get update をまず最初に実行する必要があります。こうすることにより、 Apache と PHP の最新の安定版パッケージを取得することができます。

すべての準備が完了したら、以下の例に従って Apache と PHP をインストールします。

例2 Debian への Apache 1.3 のインストール

# apt-get install libapache-mod-php4

APT により、Apache 1.3 用の PHP 4 モジュールが自動的にインストールされます。 インストール中に Apache を再起動する旨が表示されなかった場合は、手動で 再起動する必要があります。

例3 PHP 4 インストール後に Apache を停止・起動させる

# /etc/init.d/apache stop
# /etc/init.d/apache start

追加モジュールと適切な設定

上記では、PHP のコアモジュールだけがインストールされています。 これだけでは不足の場合もあるでしょう。また将来、MySQL や cURL, GD といった より多くのモジュールを有効にすることが必要になるかも知れません。

PHP を自らコンパイルする場合は、有効にするモジュールを configure コマンドで指定します。APT では、追加のパッケージをインストールします。 それら追加パッケージは、'php4-*'(サードパーティのリポジトリから PHP 5 をインストールする場合は 'php5-*')といった名前が付けられています。

例4 追加のパッケージの名前を取得する

# dpkg -l 'php4-*'

上記の出力を見てわかるとおり、(php4-cgi や php4-cli, php4-pear といった 特別なパッケージのほかにも) さまざまなパッケージがあり、インストールが可能です。 詳細に参照して、必要なものを選択してください。選択したモジュールに必要な ライブラリがインストールされていない場合、APT により自動的にインストールされます。

MySQL, cURL および GD サポートを PHP に追加する場合のコマンドは 以下のようになります。

例5 MySQL, cURL および GD を PHP にインストールする

# apt-get install php4-mysql php4-curl php4-gd

APT により、(システムで)用いられている php.ini (/etc/php4/apache/php.ini, /etc/php4/cgi/php.ini など) に適切な設定が追加されます。

例6 MySQL, cURL および GD を有効にする設定

extension=mysql.so
extension=curl.so
extension=gd.so

追加したモジュールを有効にするには、前述したとおり、Apache を再起動させる必要があります。

よく起きる問題

  • PHP スクリプトが実行された結果が出力されず、PHP のソースコードが表示される場合は、 APT によって、/etc/apache/conf.d/php4 が読み込まれるように、 Apache 1.3 の設定ファイルが変更されるべきところが、 実際には変更されていないものと思われます。 以下の行を /etc/apache/httpd.conf に追加し、 Apache を再起動させてください。

    例7 PHP 4 を Apache で有効にする

    # Include /etc/apache/conf.d/
    
  • 追加の拡張モジュールをインストールしたにもかかわらず、 その機能がスクリプトから利用できない場合は、前述した適切な設定が php.ini に追加されているかどうか確認してください。debconf による設定で コンフリクトが起こると、追加モジュールのインストールに失敗する場合があります。


add a note add a note User Contributed Notes
Debian GNU/Linux へのインストール
John Fisher
09-Feb-2007 01:53
With Apache2 and Php4 under Debian Sarge there is an extra configuration file :  /etc/apache2/sites-available/default
This file is not clearly documented, at least not for noobs, in Apache docs.

It overrides the conf file in the way you expect the /etc/apache2/conf.d/apache2-doc  to do according to the README.

Add ExecCGI to it to get rid of "Options ExecCGI is off in this directory"  errors.
rbemrose at vgmusic dot com
11-Jan-2007 06:10
As a side note, Debian sarge (stable at the time of this writing) does not have a pecl binary in php4-pear, but it appears to exist in testing and unstable.
A random Debian Developer
05-Oct-2006 04:00
PHP5 is available in Debian 4.0 (codename 'etch') or later. Until Debian 4.0 is released you may want to look at www.backports.org which also has the packages.

www.backports.org only allows official Debian Developers to upload packages so it is likely that they are somewhat more trustable than some generic collection of "debs" available for download.
Ben A.
18-Dec-2005 07:53
Although there are no PHP 5 packages for Debian 3.1 (aka "stable" or "sarge"), there are currently PHP 5 packages for "testing"/"etch" and "unstable"/"sid".  Installation works the same way.

Also, the same process can be used for Ubuntu, but note that some of the packages may be in the "universe" section instead of "main".
jimmychan at example dot com
24-Oct-2005 07:01
If you are using Debian 3.1

It is total, the php.ini is under
/etc/php4/apache2

Since Debian 3.1 default apache is 2.0.x version, this one just said how to change the php.ini under apache 1.3.x

If you need enable the ext. need manaul edit php.ini, and comment out # of what the ext. that you want to enable

Of course, you much first install the ext. first by like that

apt-get install php4-gd php4-mysql ......

 
show source | credits | stats | sitemap | contact | advertising | mirror sites