This section will guide you through the general configuration and installation of PHP on Unix systems. Be sure to investigate any sections specific to your platform or web server before you begin the process.
As our manual outlines in the General Installation Considerations section, we are mainly dealing with web centric setups of PHP in this section, although we will cover setting up PHP for command line usage as well.
There are several ways to install PHP for the Unix platform, either with a compile and configure process, or through various pre-packaged methods. This documentation is mainly focused around the process of compiling and configuring PHP. Many Unix like systems have some sort of package installation system. This can assist in setting up a standard configuration, but if you need to have a different set of features (such as a secure server, or a different database driver), you may need to build PHP and/or your webserver. If you are unfamiliar with building and compiling your own software, it is worth checking to see whether somebody has already built a packaged version of PHP with the features you need.
Prerequisite knowledge and software for compiling:
Basic Unix skills (being able to operate "make" and a C compiler)
An ANSI C compiler
flex: Version 2.5.4
bison: Version 1.28 (preferred), 1.35, or 1.75
A web server
Any module specific components (such as gd, pdf libs, etc.)
The initial PHP setup and configuration process is controlled by the use of the commandline options of the configure script. You could get a list of all available options along with short explanations running ./configure --help. Our manual documents the different options separately. You will find the core options in the appendix, while the different extension specific options are descibed on the reference pages.
When PHP is configured, you are ready to build the module and/or executables. The command make should take care of this. If it fails and you can't figure out why, see the Problems section.
本節では、PHPをUnixプラットフォームのApacheにインストールする際の注意事項と コツについて説明します。Apache 2に関する手引きと注意も 別のページにあります。
以下の手順の10行目でconfigure に追加する引数を configureのオプションの全て から選択可能です。ここではバージョン番号が意図的に省略 されています。'xxx'の部分を貴方が使用するファイルに対応するものに 置き換えてください。
この他、PHPを静的オブジェクトとしてインストールすることもできます。
例 4-2. PHPのインストール手順(Apache用静的モジュールインストール)
|
Apache のインストールやUNIXの種類によりサーバを停止し、再起動する 方法はいくつもあります。複数のApache/UNIXの組合せについてサーバを 再起動する際に使用される典型的な方法を以下に示します。 /path/to/ を使用するシステムのアプリケーション へのパスに置き換えて読んで下さい。
例 4-3. Apacheを再起動するためのコマンドの例
|
apachectl および http(s)dctl の実行ファイルの位置はシステムにより 異なります。システムが locate または whereis または which を サポートしている場合、サーバ制御用プログラムを見つけるために使用するこ とが可能です。
PHPをApache用にコンパイルする別の例を以下に示します。
これにより、共有ライブラリ libphp4.so が作成 されます。Apacheのhttpd.confファイルにおいて LoadModuleを使用してApacheにこのライブラリをロードすることが可能 です。上の例では、PostgreSQLサポートがこの libphp4.soライブラリに埋め込まれます。
この例でも Apache用libphp4.so 共有ライブラリ が作成されます。しかし、共有ライブラリ pgsql.so も作成されます。この共有ライブラリ は、php.ini ファイルのextensionディレクティ ブまたはスクリプト内でdl()関数を使用して明示的 にロードすることが可能です。
これにより、libmodphp4.a ライブラリと mod_php4.c およびいくつかの付属ファ イルが作成され、Apacheにソースツリーのディレクトリ src/modules/php4 にコピーされます。続いて、 --activate-module=src/modules/php4/libphp4.a を指定してApacheをコンパイルして下さい。これにより、Apache構築シ ステムは、libphp4.a を作成し、 httpd バイナリに静的にリンクされます。 PostgreSQL サポートはこのhttpdバイナリに直接 インクルードされるため、最終的な結果は、Apache全体とPHP全体を含む 単一のhttpdバイナリになります。
上と同じですが、最終的なhttpdに PostgreSQLサポートを直接インクルードする代わりに、共有ライブラリ pgsql.soをファイル php.iniまたはdl()により直 接的にPHPにロードすることが可能です。
異なったPHPの構築法を選択する際、各方法の利点と欠点を考慮する必要 があります。共有オブジェクトとして構築する場合、Apacheと分割して コンパイルすることが可能で、PHPを追加または変更する際に全体を再コ ンパイルする必要がありません。PHPをApacheに(静的に)組み込む場合に は、PHPはより高速にロード/実行することが可能です。詳細な情報につ いては、ApacheのDSOサポートのWebページ を参照下さい。
注意: Apacheのデフォルトのhttpd.confは次のようなセクションがあります。
これを"Group nogroup"やそれに類する値("Group daemon"も一般的です)に変更しない 限り、PHPはファイルをオープンすることができません。
注意: --with-apxs=/path/to/apxsオプションを 指定する場合にはインストールされているバージョンのapxsを指定してください。 Apacheのソースディレクトリ内にあるapxsバージョンではなく 実際にシステムにインストールされているものでなければなりません。