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

search for in the

Mac OS X へのインストール> <Solaris へのインストール
[edit] Last updated: Fri, 25 May 2012

view this page in

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

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

警告

サードパーティが作った非公式のビルドについてはここではサポートしていません。 何かバグを見つけた場合は、 » ダウンロードページ から取得した最新のビルドでそれが再現するかを確認し、 再現しない場合は Debian チームにバグ報告をお願いします。

Unix 上で PHP をビルドする方法は Debian でもそのまま使えます。 しかし、このページではもうひとつの方法として Debian 固有の情報を扱います。 apt-getaptitude といったコマンドの使い方です。 このマニュアルページでの説明は、これらふたつのコマンドのどちらを使っても実行できます。

APT の使用

まず、Apache 2 と統合する場合は libapache2-mod-php5、PEAR を使う場合は php-pear などの関連パッケージが必要となることを知っておきましょう。

次に、パッケージをインストールする前にはパッケージ一覧を最新に更新しておくようにしましょう。 これは、apt-get update コマンドで行います。

例1 Debian で Apache 2 と組み合わせるインストール例

# apt-get install php5-common libapache2-mod-php5 php5-cli

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

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

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

よりよい設定の管理

ここまでのセクションでは、PHP のコアモジュールだけをインストールしました。 おそらく、さらに MySQLcURLGD などの追加モジュールもインストールしたくなることでしょう。 これらも apt-get コマンドでインストールすることができます。

例3 追加の PHP 5 パッケージを探す方法

# apt-cache search php5
# aptitude search php5
# aptitude search php5 |grep -i mysql

上記の出力を見てわかるとおり、(php5-cgi や php5-cli, php5-dev といった 特別なパッケージのほかにも) さまざまなパッケージがあり、インストールすることが可能です。 必要なものを見定めて、apt-getaptitude でインストールしましょう。 Debian は依存性のチェックを行うので、たとえば MySQL と cURL をインストールする場合はこのようになります。

例4 PHP と MySQL、cURL のインストール

# apt-get install php5-mysql php5-curl

APT は自動的に、 /etc/php5/apache2/php.ini/etc/php5/conf.d/pdo.ini などの php.ini に適切な行を追加し、extension=foo.so といった内容が書き込まれます。しかし、これらの変更を有効にするにはウェブサーバー (Apache など) を再起動しなければなりません。

よく起きる問題

  • PHP スクリプトがウェブサーバーで実行されない場合は、 おそらく PHP がウェブサーバーの設定ファイルに追加されていないのでしょう。 Debian の場合、設定ファイルは /etc/apache2/apache2.conf のようになります。詳細は Debian のマニュアルを参照ください。
  • 拡張モジュールをインストールしたのに関数が未定義だと言われたら、 適切な ini ファイルが読み込まれているかどうかと インストール後にウェブサーバーを再起動したかどうかを確認しましょう。
  • Debian (およびその派生物) でパッケージをインストールする基本的なコマンドは apt-getaptitude のふたつです。 しかし、これらのコマンドの微妙な違いについての説明は、このマニュアルでは行いません。


add a note add a note User Contributed Notes Debian GNU/Linux へのインストール
juraj at jurajsplayground dot com 08-May-2009 05:59
On Ubuntu (since 7.04), rather do:
sudo tasksel install lamp-server

Details:
https://help.ubuntu.com/community/ApacheMySQLPHP
tranzbit at yahoo dot com 02-May-2009 01:59
On Ubuntu:

sudo apt-get install apache2 php5 mysql-client-5.0 mysql-server-5.0 phpmyadmin libapache2-mod-php5 libapache2-mod-auth-mysql php5-mysql

then restart the computer/start mysql manually
From:
http://ubuntuforums.org/showthread.php?t=186492
John Fisher 08-Feb-2007 04: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.
Ben A. 17-Dec-2005 10: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 23-Oct-2005 10: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