kghbln Thank you very much you really help me with this mate ! I just start my Hosting Company and i need to protect server from web shells like: c100.php and many other but i also need phpmyadmin , Wordpress and many other script to install for my customers but with base_dir on that isn't possible, this is really help me , now i know i can allow specific multiple directories and restrict-protect everything else !
Thank you
コア php.ini ディレクティブに関する説明
このリストには、PHPを設定する際に使用可能なコア php.ini ディレクティブが 含まれています。拡張モジュールにより処理されるディレクティブは、それぞれの 拡張モジュールのドキュメントページにリストと詳細が記述されています。 例えば、セッション用ディレクティブに関する情報は、 セッションのページにあります。
httpd オプション
| 名前 | デフォルト | 変更可能 | 変更履歴 |
|---|---|---|---|
| async_send | "0" | PHP_INI_ALL |
言語オプション
| 名前 | デフォルト | 変更可能 | 変更履歴 |
|---|---|---|---|
| short_open_tag | "1" | PHP_INI_ALL | PHP 4.0.0 で PHP_INI_ALL、PHP < 5.3.0 で PHP_INI_PERDIR |
| asp_tags | "0" | PHP_INI_PERDIR | PHP 4.0.0 で PHP_INI_ALL |
| precision | "14" | PHP_INI_ALL | |
| serialize_precision | "17" | PHP_INI_ALL | PHP 4.3.2 以降で利用可能。PHP 5.3.5 までは、デフォルト値は 100 でした。 |
| y2k_compliance | "1" | PHP_INI_ALL | |
| allow_call_time_pass_reference | "1" | PHP_INI_SYSTEM|PHP_INI_PERDIR | PHP 4.0.0 で PHP_INI_ALL |
| disable_functions | "" | php.ini のみ | PHP 4.0.1 以降で利用可能。 |
| disable_classes | "" | php.ini のみ | PHP 4.3.2 以降で利用可能。 |
| exit_on_timeout | "" | PHP_INI_ALL | PHP 5.3.0 以降で利用可能。 |
| expose_php | "1" | php.ini のみ | |
| zend.ze1_compatibility_mode | "0" | PHP_INI_ALL | PHP 5.0.0 以降で利用可能。PHP 5.3.0 で削除。 |
| zend.multibyte | "0" | PHP_INI_ALL | PHP 5.4.0 以降で利用可能。 |
| detect_unicode | "1" | PHP_INI_ALL | PHP 5.1.0 以降で利用可能。PHP 5.4.0 で削除。 |
以下に設定ディレクティブに関する 簡単な説明を示します。
- short_open_tag boolean
-
PHP タグの短縮型 (
<? ?>) を使用 可能にするかどうかを設定します。PHPをXMLと組み合わせて用いる 場合は、<?xml ?>をファイル中で用 いるためにこのオプションをオフにする必要があります。オンにし た場合にPHPでXMLを出力するには、例えば、次のようにします。<?php echo '<?xml version="1.0"?>'; ?>これをオフにした場合、長い方の形式のタグ (<?php ?>)を使用する必要があります。注意:
PHP 5.4.0 より前のバージョンでは、 このディレクティブは、
<? echoと同じ形式の ショートカット<?=も影響を受けます。 このショートカットを使用するには、short_open_tagをonとする 必要があります。 PHP 5.4.0 以降では、<?=は常に有効となります。 - ASP 形式のタグ <% %> を通常のタグ <?php ?> に加えて使用可能にします。 このスイッチにより、出力の短縮形 <%= $value %> も 使用できるようになります。 詳細な情報は、 HTML からのエスケープを参照ください。
- precision integer
- 浮動小数点数に関して表示される最大桁数を指定します。
- serialize_precision integer
- 浮動小数点数をシリアライズするときに格納する桁数を指定します。
- y2k_compliance boolean
- 2000年問題対応を強制します (2000年問題非対応のブラウザにおいて、 問題が発生する可能性があります)。
- allow_call_time_pass_reference boolean
-
関数のコール時に引数が参照で渡された場合に、警告するかどうかを設定します。 推奨される方法は、関数宣言時に参照渡しとするべき引数を指定することです。 将来のバージョンでの動作を保障するために、 このオプションを off とし、 スクリプトがこの状態で正しく動作することを確認することが推奨されます (この機能を使用する度に警告が発生します)。
関数コール時に参照で引数を渡すことは、コードの明解さを損なうために 廃止されています。関数は、引数が参照渡しであると宣言されて いない場合でも、文書化されていない方法で、その引数を修正できます。 副作用を回避するためには、どの引数を参照渡しとするかを関数宣言でのみ 指定すると良いでしょう。
PHP 5 では allow_call_time_pass_reference は非推奨となります。 PHP 5.3.0 より前のバージョンではこの機能を使うと E_COMPILE_WARNING が発生し、PHP 5.3.0 以降では E_DEPRECATED となります。
参照に関する説明も 参照ください。
- expose_php boolean
-
PHP がサーバーにインストールされていることを全世界に晒し、PHP のバージョンも HTTP ヘッダに含めます (X-Powered-By: PHP/5.3.7 など)。 PHP のロゴの guid も公開されるので、PHP を有効にしたサイトの URL にそれを追加すると guids are also exposed, thus appending them to the URL of a PHP enabled site (例: » http://www.php.net/?=PHPE9568F34-D428-11d2-A769-00AA001ACF42) ロゴが表示されるようになります。この設定は phpinfo() の出力にも影響し、無効にすると PHP のロゴやクレジット情報が表示されなくなります。
php_logo_guid() および phpcredits() も参照ください。
- disable_functions string
-
このディレクティブを使うと、特定の関数を セキュリティ の観点から無効にすることができます。 関数名の一覧をカンマ区切りで指定します。disable_functions は セーフモード の影響を受けません。
このディレクティブで無効にできるのは 内部の関数だけです。 ユーザが定義した関数 は影響を受けません。
このディレクティブは php.ini で設定しなければなりません。 たとえばこれを httpd.conf で設定することはできません。
- disable_classes string
-
このディレクティブを使うと、特定のクラスを
セキュリティ の観点から無効にすることができます。
クラス名の一覧をカンマ区切りで指定します。disable_classes は
セーフモード の影響を受けません。
このディレクティブは php.ini で設定しなければなりません。
たとえばこれを httpd.conf で設定することはできません。
注意: バージョンに関するメモ
このディレクティブは PHP 4.3.2 以降で使用可能です。 - zend.ze1_compatibility_mode boolean
-
Zend Engine 1 (PHP 4) との互換モードを有効にします。 この設定は、オブジェクトのコピー、キャスト (プロパティを 保持しないオブジェクトが FALSE あるいは 0 のいずれになるか)、 そして 比較 に影響を与えます。このモードの場合、オブジェクトを渡す際の デフォルトの方法は、参照渡しではなく値渡しとなります。
PHP 4 から PHP 5 への移行というタイトルの セクションも参照してください。
警告この機能は 非推奨 で、 PHP 5.3.0 以降では 削除 されました。
- zend.multibyte boolean
-
マルチバイトエンコーディングで書かれたソースファイルをパースできるようにします。
- detect_unicode boolean
-
BOM (Byte Order Mark) を調べ、 ファイルが有効なマルチバイト文字を含むかどうかを確認します。 この検出は、 __halt_compiler() の処理より前に行われます。 Zend Multibyte モードでのみ利用可能です。
- exit_on_timeout boolean
-
これは Apache1 の mod_php だけで使える項目で、PHP の実行タイムアウトが発生したときに Apache の子プロセスを強制終了させます。このタイムアウトがおこると Apache1 の内部で longjmp() がコールされ、その結果としていくつかの拡張モジュールが一貫性を欠く状態になってしまいます。 プロセスを強制終了させることで、未処理のロックやメモリの後始末も行います。
リソース制限
| 名前 | デフォルト | 変更可能 | 変更履歴 |
|---|---|---|---|
| memory_limit | "128M" | PHP_INI_ALL | PHP 5.2.0 より前は "8M"、PHP 5.2.0 では "16M" |
以下に設定ディレクティブに関する 簡単な説明を示します。
- memory_limit integer
-
スクリプトが確保できる最大メモリをバイト数で指定します。この命令は、 正しく書かれていないスクリプトがサーバーのメモリを食いつぶすことを防止するのに役立ちます。 もし、使用可能メモリに制限を設けたくない場合は、 ここに -1 を指定してください。
PHP 5.2.1 より前のバージョンでは、このディレクティブを使うためには、 コンパイル時に configure で --enable-memory-limit を指定しなければなりません。 このコンパイルフラグは、関数 memory_get_usage() および memory_get_peak_usage() を 5.2.1 より前のバージョンで使う際にも必要となります。
integerを使用する際、 その値はバイト単位で測られます。 この FAQ に記載された 短縮表記を使用することも可能です。
max_execution_time も参照ください。
パフォーマンスチューニング
| 名前 | デフォルト | 変更可能 | 変更履歴 |
|---|---|---|---|
| realpath_cache_size | "16K" | PHP_INI_SYSTEM | PHP 5.1.0 以降で使用可能。 |
| realpath_cache_ttl | "120" | PHP_INI_SYSTEM | PHP 5.1.0 以降で使用可能。 |
以下に設定ディレクティブに関する 簡単な説明を示します。
データ処理
| 名前 | デフォルト | 変更可能 | 変更履歴 |
|---|---|---|---|
| track_vars | "On" | PHP_INI_?? | |
| arg_separator.output | "&" | PHP_INI_ALL | PHP 4.0.5 以降で利用可能 |
| arg_separator.input | "&" | PHP_INI_SYSTEM|PHP_INI_PERDIR | PHP 4.0.5 以降で利用可能 |
| variables_order | "EGPCS" | PHP_INI_PERDIR | PHP <= 5.0.5 では PHP_INI_ALL。 |
| request_order | "" | PHP_INI_PERDIR | PHP 5.3.0 以降で利用可能 |
| auto_globals_jit | "1" | PHP_INI_PERDIR | PHP 5.0.0 以降で利用可能 |
| register_globals | "0" | PHP_INI_PERDIR | PHP <= 4.2.3 では PHP_INI_ALL |
| register_argc_argv | "1" | PHP_INI_PERDIR | PHP <= 4.2.3 では PHP_INI_ALL |
| register_long_arrays | "1" | PHP_INI_PERDIR | PHP 5.0.0 以降で利用可能。PHP 5.3.0 で非推奨。PHP 5.4.0 で削除。 |
| post_max_size | "8M" | PHP_INI_PERDIR | PHP <= 4.2.3 では PHP_INI_SYS。PHP 4.0.3 以降で利用可能 |
| gpc_order | "GPC" | PHP_INI_ALL | |
| auto_prepend_file | "" | PHP_INI_PERDIR | PHP <= 4.2.3 では PHP_INI_ALL |
| auto_append_file | "" | PHP_INI_PERDIR | PHP <= 4.2.3 では PHP_INI_ALL |
| default_mimetype | "text/html" | PHP_INI_ALL | |
| default_charset | "iso-8859-1" | PHP_INI_ALL | |
| always_populate_raw_post_data | "0" | PHP_INI_PERDIR | PHP <= 4.2.3 では PHP_INI_ALL。PHP 4.1.0 以降で利用可能 |
| allow_webdav_methods | "0" | PHP_INI_PERDIR |
以下に設定ディレクティブに関する 簡単な説明を示します。
- track_vars boolean
-
サーバ変数はそれぞれ、グローバル連想配列 $_ENV, $_GET, $_POST, $_COOKIE, $_SERVERで参照することができます。
PHP 4.0.3 以降,
track_varsは常にonとなっている ことに注意してください。 - arg_separator.output string
-
PHPがURLを生成する際にURL引数を区分するために使用されるセパレータ。
- arg_separator.input string
-
入力されたURLを変数にパースする際にPHPが使用するセパレータのリスト。
注意:
このディレクティブで指定した全ての文字は、 セパレータとして認識されます!
- variables_order string
-
EGPCS (Environment (環境変数)、 Get、Post、 Cookie (クッキー)、そして Server) 変数のパースの順番を設定します。例えば variables_order を "SP" に設定すると、PHP は superglobals $_SERVER および $_POST を作成しますが、 $_ENV、$_GET および $_COOKIE は作成しません。"" に設定すると、一切 superglobals を設定しません。
非推奨のディレクティブ register_globals が on になっていると、 variables_order の設定は、 ENV、 GET、POST、 COOKIE および SERVER の各変数がグローバルスコープに取り込まれる順番も左右します。 つまり、たとえば variables_order が "EGPCS" で register_globals が有効になっていたとすると、 $_GET['action'] と $_POST['action'] が両方設定された場合の $action の値は $_POST['action'] の内容になります。 これは、この例におけるディレクティブの設定で P が G より後になっているからです。
警告CGI および FastCGI SAPI の両方で、 $_SERVER にも環境変数の値が格納されます。 つまり、S を指定すると、 ES と指定したのと同じ意味になります。 これは、E が他のどこかで指定されていたとしても同じです。
注意:
$_REQUEST の内容や順序も、このディレクティブの影響を受けます。
- request_order string
-
このディレクティブは、PHP が GET 変数や POST 変数そしてクッキー変数を _REQUEST 配列に登録する際の順序を表します。 登録は左から右の順に行い、後から登録した値が古い値を上書きします。
このディレクティブが設定されていない場合は、variables_order を使用して $_REQUEST を設定します。
デフォルトの配布状態の php.ini ファイルには、クッキーの 'C' が含まれていないことに注意しましょう。 セキュリティを考慮したためです。
- auto_globals_jit boolean
-
有効にした場合、SERVER および ENV 変数はスクリプトの開始時ではなく、 最初に使用された時 (Just In Time) に作成されるようになります。 これらの変数がスクリプトの中で使用されない場合、 このディレクティブを使用することで性能が向上します。
このディレクティブを有効にするには、PHP ディレクティブ register_globals, register_long_arrays, および register_argc_argv を無効にしておく必要があります。PHP 5.1.3 以降では、 register_argc_argv を無効にする必要はありません。
警告SERVER および ENV 変数の利用チェックはコンパイル時に行われます。 したがって、たとえば 可変変数 で使用した場合は初期化を行いません。
- register_globals boolean
-
EGPCS(Environment, GET, POST, Cookie, Server)変数を グローバル変数として登録するかどうかを指定します。
» PHP 4.2.0 以降、 このディレクティブのデフォルトは、offです。
関連する情報については、セキュリティの章の register_globalsの使用 を参照してください。
register_globalsは、 (ini_set()で)実行時に設定することができないことに 注意してください。しかし、前記のようにホストが許可している場合には、 .htaccess を使用することができます。 .htaccess エントリの例を以下に示します。php_flag register_globals off注意:
register_globalsは、 variables_order ディレクティブの影響を受けます。警告この機能は PHP 5.3.0 で 非推奨となりました。 この機能を使用しないことを強く推奨します。
- register_argc_argv boolean
- PHPが変数argvとargcを宣言するかどうかを指定します (これらにはGETの情報が格納されます)。 コマンドライン も参照ください。
- register_long_arrays boolean
-
PHP が、$HTTP_*_VARS のような古い長い
定義済みの変数
を登録するかどうかを指定します。
On (デフォルト) とした場合、$HTTP_GET_VARS のような
定義済みの長い PHP 変数が定義されます。
これらの変数を使用していない場合には、性能面からこのオプションを
off とすることが推奨されています。
かわりに $_GET のようなスーパーグローバル変数を使用してください。
このディレクティブは PHP 5.0.0 で利用可能となりました。
警告
この機能は PHP 5.3.0 で 非推奨となりました。 この機能を使用しないことを強く推奨します。
- enable_post_data_reading boolean
- このオプションを無効にすると、$_POST や $_FILES に値が入らなくなります。 この場合、投稿されたデータを読むには、ストリームラッパー php://input を使う以外の方法はなくなります。 これは、リクエストをプロキシしたり POST データを処理する際のメモリ消費量を抑えたりする際に有用です。
- post_max_size integer
-
POSTデータに許可される最大サイズを設定します。この設定は、ファ
イルアップロードにも影響します。大きなファイルをアップロード
するには、この値を upload_max_filesize
より大きく設定する必要があります。
configureスクリプトでメモリ制限を有効とした場合、memory_limitも
ファイルアップロードに影響します。一般的に memory_limit は、
post_max_sizeよりも大きく
する必要があります。
integerを使用する際、
その値はバイト単位で測られます。
この FAQ に記載された
短縮表記を使用することも可能です。
POSTデータの大きさが、post_max_sizeより大きい場合、
$_POST と $_FILES
superglobals
は空になります。この事象は、いくつかの方法で検出することができます。
例えば、$_GET 変数をデータを
<form action="edit.php?processed=1">のように
処理するスクリプトに渡し、
$_GET['processed'] が設定されているかどうかを
確認する方法があります。
注意:
PHP では、ビット値を表すショートカット K (kilo)、M (mega) および G (giga) を使用することができます。 これらを使用した場合、PHP が規約にしたがって自動的に値を判断します。 32 ビット符号付き整数の最大値を上回る値を指定しないように注意しましょう (32 ビットシステムを使用している場合)。 そのようなことをすると、スクリプトの実行が失敗します。
- gpc_order string
-
GET/POST/COOKIE 変数処理の順番を設定します。この命令の デフォルトの設定は、"GPC"です。例えばこれを"GP"にすると、PHPはクッキーを 完全に無視し、GETメソッド変数を同名のPOSTメソッド変数で上書き します。
注意:
このオプションは、PHP 4では利用できません。 代わりに、variables_order を使用してください。
- auto_prepend_file string
-
メインファイルの前に自動的に付加されるファイルの名前を指定します。 このファイルは、require() 関数のコール時と同様に読み込まれます。 このため、include_path が使用されます。
特別な値 none を指 定すると、ファイルを前に追加する機能は無効となります。
- auto_append_file string
-
メインファイルの後に自動的に追加されるファイルの名前を指定します。 このファイルは、require() 関数のコール時と同様に読み込まれます。 このため、include_path が使用されます。
none を値として 指定するとこの自動付加機能はオフとなります。
注意: スクリプトが exit() で終了する場合、 この自動付加機能は使用されません 。
- default_mimetype string
-
- default_charset string
-
PHP は、デフォルトで常にContent-type:ヘッダで character encodingを出力するようになっています。charsetの送信 を無効にするには、これを空にしてください。
- always_populate_raw_post_data boolean
-
常に $HTTP_RAW_POST_DATA にアクセス可能とします。 この変数には生の POST データが格納されています。指定しなかった場合は、 データの MIME 型が判別できない場合のみこの変数にアクセス可能となります。 しかし、生の POST データにアクセスする方法としては php://input のほうが推奨されます。 $HTTP_RAW_POST_DATA は、 enctype="multipart/form-data" の場合には無効です。
- allow_webdav_methods boolean
-
PHPスクリプトの中で WebDAV http リクエスト (例:PROPFIND, PROPPATCH, MOVE, COPY, 等..) の処理を可能にします。 このディレクティブは、PHP 4.3.2 以降存在しません。 これらのリクエストのPOSTデータを取得したい場合、 always_populate_raw_post_data も同時に設定する必要があ ります。
magic_quotes_gpc, magic-quotes-runtime, および magic_quotes_sybase も参照ください。
パスおよびディレクトリ
| 名前 | デフォルト | 変更可能 | 変更履歴 |
|---|---|---|---|
| include_path | ".;/path/to/php/pear" | PHP_INI_ALL | |
| open_basedir | NULL | PHP_INI_ALL | PHP < 5.3.0 では PHP_INI_SYSTEM |
| doc_root | NULL | PHP_INI_SYSTEM | |
| user_dir | NULL | PHP_INI_SYSTEM | |
| extension_dir | "/path/to/php" | PHP_INI_SYSTEM | |
| extension | NULL | php.ini のみ | |
| zend_extension | NULL | php.ini のみ | |
| zend_extension_debug | NULL | php.ini のみ | |
| zend_extension_debug_ts | NULL | php.ini のみ | |
| zend_extension_ts | NULL | php.ini のみ | |
| cgi.check_shebang_line | "1" | PHP_INI_SYSTEM | PHP 5.2.0 以降で利用可能。 |
| cgi.fix_pathinfo | "1" | PHP_INI_SYSTEM | PHP 4.3.0 以降で利用可能。PHP 5.2.1 までは PHP_INI_ALL でした。 |
| cgi.force_redirect | "1" | PHP_INI_SYSTEM | PHP 4.2.0 以降で利用可能。PHP 5.2.1 までは PHP_INI_ALL でした。 |
| cgi.redirect_status_env | NULL | PHP_INI_SYSTEM | PHP 4.2.0 以降で利用可能。PHP 5.2.1 までは PHP_INI_ALL でした。 |
| fastcgi.impersonate | "0" | PHP_INI_SYSTEM | PHP 4.3.0 以降で利用可能。PHP 5.2.1 までは PHP_INI_ALL でした。 |
| fastcgi.logging | "1" | PHP_INI_SYSTEM | PHP 4.3.0 以降で利用可能。PHP 5.2.1 までは PHP_INI_ALL でした。 |
| cgi.rfc2616_headers | "0" | PHP_INI_ALL | PHP 4.3.0 以降で利用可能。 |
以下に設定ディレクティブに関する 簡単な説明を示します。
- include_path string
-
require()、include()、 fopen()、file()、 readfile() および file_get_contents() 関数がファイルを 探すディレクトリのリストを指定します。フォーマットは、システ ムの環境変数 PATHと同じです。つまり、UNIXでは コロンで、Windowsではセミコロンで区切ったディレクトリのリスト で指定します。
PHP は、インクルードするファイルを探す際に インクルードパスの各エントリを個別に調べます。 まず最初のパスを調べ、見つからなければ次のパスを調べ、…… というように、ファイルが見つかるか warning あるいは error が発生するまで続けます。インクルードパスを実行時に変更したり設定したりするには set_include_path() を使用します。
例1 Unix include_path
include_path=".:/php/includes"
例2 Windows include_path
include_path=".;c:\php\includes"
インクルードパスに . (カレントディレクトリ) を指定すると、相対パス指定によるインクルードができるようになります。 しかし、インクルードのたびに毎回 PHP にカレントディレクトリをチェックさせるよりは、 明示的に include './file' を指定したほうが効率的です。
- open_basedir string
-
PHP から開くことのできるファイルを、指定したディレクトリツリーに限定します。 ファイル自身も含みます。このディレクティブは、セーフモードのオン/オフ には影響を受けません。
スクリプトから fopen() や gzopen() などでファイルを開こうとしたときに、そのファイルの場所をチェックします。 ファイルが指定したディレクトリツリーの外にある場合は、PHP はそのファイルを開きません。 シンボリックリンクの解決も行うので、 シンボリックリンクでこの制限を回避することはできません。 存在しないファイルへのシンボリックリンクは解決できないので、 ファイル名を open_basedir と比較します。
特別な値
.は、 スクリプトの作業ディレクトリを表します。これをベースディレクトリとすることもできますが、 少し危険です。スクリプトの作業ディレクトリは chdir() で容易に変更できるからです。httpd.conf で、(たとえばバーチャルホスト単位で) open_basedir を無効にすることができます。 その他の設定ディレクティブの場合と 同様に "php_admin_value open_basedir none" のようにします。
Windows では、ディレクトリの区切りはセミコロンとなります。 その他のシステムでは、コロンで区切ります。Apache モジュールでは、 親ディレクトリからの open_basedir パスを自動的に継承します。
open_basedir で指定する制約は、PHP 5.2.6 および 5.3.4 以降はディレクトリ名となります。それより前のバージョンでは、この制約はプレフィックスという扱いでした。 つまり、"open_basedir = /dir/incl" とした場合に、仮に "/dir/include" や "/dir/incls" が存在すればそこにもアクセスできていたということです。 指定したディレクトリへのアクセスのみに制限したい場合は、最後にスラッシュをつけて open_basedir = /dir/incl/ のようにします。
デフォルトでは、すべてのファイルを開くことができます。
注意:
PHP 5.3.0 以降では、open_basedir の設定を実行時に厳しくできるようになりました。 open_basedir が php.ini で /www/ と設定されているときに、スクリプト内で ini_set() を使って設定を厳しくして /www/tmp/ のようにできるということです。 複数のディレクトリを指定するときには、定数 PATH_SEPARATOR を使えば OS に依存しない記述ができます。
- doc_root string
-
サーバーにおけるPHPの"ルートディレクトリ"です。この値は空で無 い場合のみ使用されます。PHPが セーフモード で設定されている場合には、 このディレクトリの外側にあるファイルは使用されません。 PHPがFORCE_REDIRECTを指定してコンパイルされていない場合、 (IIS以外の)WebサーバのもとでCGIとしてPHPを実行する際には、 doc_rootを指定するべきです。 他の方法としては、後述の cgi.force_redirect 設定の使用があります。
- user_dir string
-
PHPファイル用にユーザーのホームディレクトリ として使用する基本ディレクトリの名前。例えば、 public_html となります。
- extension_dir string
- extension string
-
PHP の開始時に、どの動的ロード可能な拡張モジュールをロードするかを指定します。
- zend_extension string
-
動的読み込み可能な Zend 拡張モジュール (たとえば APD) を PHP の起動時に読み込む際の絶対パス。
- zend_extension_debug string
-
zend_extension の亜種で、デバッグ情報つきでコンパイルされた拡張モジュール用のもの。
- zend_extension_debug_ts string
-
zend_extension の亜種で、デバッグ情報つきかつスレッドセーフでコンパイルされた拡張モジュール用のもの。
- zend_extension_ts string
-
zend_extension の亜種で、スレッドセーフでコンパイルされた拡張モジュール用のもの。
- cgi.check_shebang_line boolean
-
CGI 版の PHP が、実行するスクリプトの先頭にある #! から始まる行 (shebang) をチェックするかどうかを指定します。 同じスクリプトをスタンドアロンと PHP CGI 経由の両方で使用したい場合などに、 この行が必要になるでしょう。このディレクティブを on にしておくと、 CGI 版の PHP はこの行の内容を読み飛ばすようになります。
- cgi.fix_pathinfo boolean
-
本来の PATH_INFO/PATH_TRANSLATED サポートをCGIで提供します。 PHPの以前の動作は、 SCRIPT_FILENAMEにPATH_TRANSLATEDを設定するというもので、 PATH_INFOの定義を理解していませんんでした。 PATH_INFOに関する詳細については、CGIの仕様を参照してください。 このオプションを1にすることにより、 PHP CGIはこのパスを仕様にあうように修正します。 ゼロとすると、 PHPは以前と同様に動作します。これは、デフォルトでオンになっています。 PATH_TRANSLATEDではなく、SCRIPT_FILENAMEを使用するようにスクリプト を修正する必要があります。
- cgi.force_redirect boolean
-
cgi.force_redirect は、ほとんどのWebサーバのもとで CGI として PHP を実行する際のセキュリティを確保するために必要です。 未定義のままの場合、PHPはデフォルトでこれを on にします。 これを off にする時は、自己責任 の下に 行なってください。
注意:
Windowsユーザ: IIS を使う場合は、このオプションは 必ず off にしなければなりません。 OmniHTTPD や Xitami の場合も同様です。
- cgi.redirect_status_env string
-
cgi.force_redirect を on にし、Apache または Netscape (iPlanet) Webサーバのもとで実行していない場合、 実行を継続して良いかどうかをPHPが判断するために 環境変数の名前を設定する必要があるかもしれません。
注意:
この変数を設定することにより、セキュリティ上の問題を発生する 場合があります。行うことのリスクをまず把握してください。
- fastcgi.impersonate string
-
IIS (または WINNT ベースの OS) のもとでの FastCGI は、 クライアントをコールする際にセキュリティトークンを 匿名化する機能をサポートしています。 これにより、IIS がリクエストを処理するセキュリティコンテキストを 定義できるようになります。Apacheのもとで実行される mod_fastcgi は現在 (2002/03/17) この機能をサポートしていません。 IIS のもとで実行するには、1 に設定してください。 デフォルトは 0 です。
- fastcgi.logging boolean
-
FastCGI 使用中の SAPI ロギングを有効にします。 デフォルトはロギングが有効となっています。
- cgi.rfc2616_headers int
-
PHP に、HTTP レスポンスを返す際に、どの形式のヘッダーを使うか 指示します。0 にセットした場合は、Apache やその他の web サーバで サポートされている Status: ヘッダーを送信します。このオプションの値を 1 にセットした場合は、PHP は » RFC 2616 の仕様に適合した形式のヘッダーを送信します。この意味がわからないときは、 0 のままにしておいてください。
ファイルアップロード
| 名前 | デフォルト | 変更可能 | 変更履歴 |
|---|---|---|---|
| file_uploads | "1" | PHP_INI_SYSTEM | PHP <= 4.2.3 では PHP_INI_ALL、PHP 4.0.3 以降で利用可能 |
| upload_tmp_dir | NULL | PHP_INI_SYSTEM | |
| max_input_nesting_level | 64 | PHP_INI_PERDIR | PHP 5.3.9 以降で利用可能。 |
| max_input_vars | 1000 | PHP_INI_PERDIR | PHP 5.3.9 以降で利用可能。 |
| upload_max_filesize | "2M" | PHP_INI_PERDIR | PHP <= 4.2.3 では PHP_INI_ALL |
| max_file_uploads | 20 | PHP_INI_SYSTEM | PHP 5.2.12 以降で利用可能。 |
以下に設定ディレクティブに関する 簡単な説明を示します。
- file_uploads boolean あるいは integer
-
HTTP ファイルアップロード を有効とするかどうか。 upload_max_filesize, upload_tmp_dir, post_max_size ディレクティブも参照ください。
integerを使用する際、 その値はバイト単位で測られます。 この FAQ に記載された 短縮表記を使用することも可能です。 - upload_tmp_dir string
-
ファイルアップロード時にファイル保存に用いるテンポラリディレクトリ。 PHPの実行ユーザーが書きこみ可能である必要が あります。指定されない場合、PHPはシステムのデフォルト設定を 使用します。
ここで指定したディレクトリに書き込むことができない場合、 PHP はかわりにシステムのデフォルトテンポラリディレクトリを使用します。 open_basedir が on の場合は、システムのデフォルトテンポラリディレクトリへのアップロードを許可しておかなければなりません。
- upload_max_filesize integer
-
アップロードされるファイルの最大サイズ。
integerを使用する際、 その値はバイト単位で測られます。 この FAQ に記載された 短縮表記を使用することも可能です。 - max_file_uploads integer
-
同時にアップロードできるファイルの最大数。 PHP 5.3.4 以降、何もファイルを指定せずに送信されたアップロードフィールドは ファイル数に数えられなくなりました。
SQL全般
| 名前 | デフォルト | 変更可能 | 変更履歴 |
|---|---|---|---|
| sql.safe_mode | "0" | PHP_INI_SYSTEM |
以下に設定ディレクティブに関する 簡単な説明を示します。
- sql.safe_mode boolean
-
オンにすると、デフォルト値が指定されているデータベース接続関数は、 引数で指定された値よりもデフォルト値を優先して使用します。 デフォルト値については、関連するデータベースのドキュメントを参照ください。
Adding multiple directories to open_basedir:
open_basedir = "/var/www/htdocs/:/var/www/tmp/" adds both paths /var/www/htdocs/ and /var/www/tmp/. Do not forget the trailing slash, otherwise the last directory will be considered as a prefix (< 5.3.4).
On Windows you use ; as the seperator.
If you need to use a path in your include_path that has a space in it - I found that I could make it work (in windows anyway) by setting a path like this
L:\Information Technology\Resources\lib\
in the include path like this listed below
include_path = ".;L:\Information" " Technology\Resources\lib\"
Note that there is no way to disable eval() work by using disable_functions directive, because eval() is a language construct and not a function.
Many people advise to disable such potentially-insecure functions like system(), exec(), passthru(), eval() and so on in php.ini when not running in safe mode, but eval() would still work even it listed in disable_functions.
This is a possible solution for a problem which seems to be a php-ini-problem but is not.
If a $_POST is used with large fields e.g. textarea's with more than 120kb characters php returns a blank screen, even if the max_post_size is 8M.
This problem may be caused by an apache-module SecFilter.
Adding the following lines to the .htaccess solves the problem.
SecFilterEngine Off
SecFilterScanPOST Off
I know this is not a php-issue, but i'm still posting it here since it looks like it is a php-problem and I did not find any sites or forums offering this solution.
Amusingly, the include_path logically includes the current directory of the running file as the last entry all the time anyways, so part of the business about shoving "." into the include_path is spurious -- it's "there" on the end all the time, at least in the 5.2.12 source (see main/fopen_wrappers.c around line 503).
This one had me goin' for a while.
For 'short_open_tag',
though it is marked as PHP_INI_ALL in changable column,
you should note the CHANGE_LOG column also:
PHP_INI_ALL in PHP <= 4.0.0.
PHP_INI_PERDIR in PHP < 5.3.0
So as of 4.0, it will not work if you wanna use
ini_set('short_open_tag') to change it's value on the fly.
Note that on some Unix systems (i.e. PHP 5.1.6 on Centos 5.2) include_path in php.ini should NOT be quoted.
For example, instead of
include_path='.:/usr/share/php'
use
include_path=.:/usr/share/php
Using quotes does not cause any error message, but all of your require_once() directives will fail (indicating that file could not be opened) - unless full path to target file is provided.
When display_errors is off, PHP will send an HTTP 500 result header on a fatal error. This is usefull when working with AJAX applications.
A handy trick to pick up parse errors in test_file.php if you can't set display_errors in php.ini or use .htaccess:
<?php
error_reporting (E_ALL);
ini_set ('display_errors', true);
include('./test_file.php');
?>
"post_max_size"
"[..]This can be tracked in various ways, e.g. by passing the $_GET variable to the script processing the data, i.e. <form action="edit.php?processed=1">, and then checking if $_GET['processed'] is set."
using PHP 4.4.8 it seems that only the $_POST array will be empty in case of the file is largen than post_max_size.
so above mentioned method does not work in my case.
i need to use $_POST['processed'] instead of $_GET['processed']
If you are having trouble getting the auto_prepend_file to work with the command line interface make sure that you have set it in the cli specific php.ini and that the read permission is set correctly for that php.ini file.
If you want to display the upload limit without knowing the server configuration, this may be useful:
<?php
function let_to_num($v){ //This function transforms the php.ini notation for numbers (like '2M') to an integer (2*1024*1024 in this case)
$l = substr($v, -1);
$ret = substr($v, 0, -1);
switch(strtoupper($l)){
case 'P':
$ret *= 1024;
case 'T':
$ret *= 1024;
case 'G':
$ret *= 1024;
case 'M':
$ret *= 1024;
case 'K':
$ret *= 1024;
break;
}
return $ret;
}
$max_upload_size = min(let_to_num(ini_get('post_max_size')), let_to_num(ini_get('upload_max_filesize')));
echo "Maximum upload file size is ".($max_upload_size/(1024*1024))."MB.";
?>
Do note however that this limit is not completely reliable; there are other factors which need to be taken into account, such as any other $_POST data and their size, the memory limit, and the script time limit. This does, however, give some rough limit, and helps you avoid "Doh!" problems where you can't figure out why your file won't upload. :)
While the manual says that the file specified by auto_prepend_file is included as if it were called by include(), in fact the file is included as if it were called by require().
In other words, if PHP cannot find the file that you specify with auto_prepend_file, it will throw a fatal error.
register_long_arrays has a very odd behavior (at least in PHP 5.2):
With register_long_arrays=Off the $GLOBALS array will not contain [_SERVER] and [_REQUEST]. They are accessible as superglobals ($_SERVER, $_REQUEST), but they disappear from the $GLOBALS array!
to make sure that all requests use SSL you can use this in a file that is set for auto_prepend_file. This ensures that all requests are SSL
<?php
if(empty($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) != 'on' )
header("Location: https://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}") and exit();
?>
I wish the documentation was more clear as to whether the arg_separator.output character is automatically encoded when PHP outputs it. In other words, is "&" valid or do I need to specify the encoded character "&"? It would make sense to specify only "&" and hope that it is encoded as needed. That way the value could be read by other functions and encoded only when output to HTML, rather than having to test whether it is already encoded and decode it when necessary (for header redirection for example)
"If the size of post data is greater than post_max_size..."
It seems that a more elegant way is comparison between post_max_size and $_SERVER['CONTENT_LENGTH']. Please note that the latter includes not only size of uploaded file plus post data but also multipart sequences. Leo
Starting with PHP 4.4.0 (at least PHP version 4.3.10 did have old, documented behaviour) interpretation of value of "session.save_path" did change in conjunction with "save_mode" and "open_basedir" enabled.
Documented ( http://de.php.net/manual/en/ref.session.php#ini.session.save-path ):
Values of "session.save_path" should or may be **without** ending slash.
For instance:
<?php
// Valid only *before* PHP 4.4.0:
ini_set( "session.save_path", "/var/httpd/kunde/phptmp" );
?> will mean:
The directory "/var/httpd/kunde/phptmp/" will be used to write data and therefore must be writable by the web server.
Starting with PHP 4.4.0 the server complains that "/var/httpd/kunde/" is not writable.
Solution: Add an ending slash in call of ini_set (or probably whereever you set "session.save_path"), e.g.:
<?php
// Note the slash on ".....phptmp/":
ini_set( "session.save_path", "/var/httpd/kunde/phptmp/" );
?>
Hope, that does help someone.
Warning, if you change upload_max_filesize, please note that both post_max_size and memory_limit directives may have to change too.
I did a little experimentation on the behaviour of auto_prepend_file as the order of access wasn't clear to me from the documentation.
1. Apache checks to see if the target file exists.
2. The prepend file is called
3. The target file is called
This means that you can use auto_prepend_file to change the target file before you access it however you can't generate new files.
Please be mindful, that if you plan on re-configuring / recompiling to add --enable-memory-limit support, you may need to run a 'make clean' before you run 'make'. Otherwise, you may end up with a phpinfo() that shows up with --enable-memory-limit as a configure parameter, but the memory_get_usage() function will still force a fatal error.
