Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: Apache専用の関数 - Manual
[go: Go Back, main page]

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

search for in the

apache_child_terminate" width="11" height="7"/> <dotnet_load
Last updated: Thu, 31 May 2007

view this page in

II. Apache専用の関数

導入

以下の関数は、Apacheモジュール版のPHPを実行している場合のみ利用可能です。

注意: PHP 4.3.2以降、PATH_TRANSLATED は、 Apache 2 SAPIでは暗黙のうちに設定されなく なりました。これは、Apacheにより設定されない場合に サーバ変数SCRIPT_FILENAMEと同じ値に設定される Apache 1とは異なります。この変更は、 PATH_TRANSLATEDPATH_INFOが定義されている場合のみ存在するべきであるという CGIの規定を満たすために行われました。

Apache 2のユーザは、PATH_INFOを定義するために httpd.confの中で AcceptPathInfo = Onを使用してください。

インストール手順

PHPのApacheへのインストール方法については、インストールの章を参照してください。

実行時設定

Apache PHPモジュールの動作は、php.iniの設定により影響を受けます。 php.iniの設定は、サーバの設定ファイル内の php_flag の設定 またはローカルなファイル .htaccessにより上書きすることができます。

例 196. .htaccessによりあるディレクトリのPHPによるパー スを無効にする

php_flag engine off

表 17. Apache設定オプション

名前デフォルト変更の可否変更履歴
engine"1"PHP_INI_ALLPHP 4.0.5 から利用可能
child_terminate"0"PHP_INI_ALLPHP 4.0.5 から利用可能
last_modified"0"PHP_INI_ALLPHP 4.0.5 から利用可能
xbit_hack"0"PHP_INI_ALLPHP 4.0.5 から利用可能

PHP_INI_* 定数の詳細および定義については 付録 I. php.ini ディレクティブ を参照してください。

以下に設定ディレクティブに関する 簡単な説明を示します。

設定ディレクティブの短い説明を以下に示します。

engine boolean

PHP によるパースのオン/オフを切り替えます。 このディレクティブは、Apacheモジュール版のPHPでのみ有効です。 このディレクティブは、ディレクティブ毎または仮想サーバ毎にPHPに よるパースを有効または無効にしたいサイトで使用されます。 httpd.confファイルの適当な場所に engine offを置くことにより、PHPを有効また は無効にすることができます。

child_terminate boolean

リクエストの終了時にPHPスクリプトが子プロセスの終了を指定するか どうかを指定します。 apache_child_terminate()も参照してください。

last_modified boolean

PHPスクリプトの修正日をこのリクエストのLast-Modified:ヘッダとし て送信します。

xbithack boolean

PHPがファイル終端を無視して実行ビットが設定されているファイルを パースするようにします。

リソース型

リソース型は定義されていません。

定義済み定数

定数は定義されていません。

目次

apache_child_terminate — このリクエストの後にApacheプロセスを終了する
apache_get_modules — ロードされた Apache モジュールのリストを取得する
apache_get_version — Apache のバージョンを取得する
apache_getenv — Apache の subprocess_env 変数を取得する
apache_lookup_uri — リクエストの一部を指定したURIに対して行い、全ての情報を返す
apache_note — Apacheリクエスト記号(note)を取得/設定する
apache_request_headers — HTTPリクエストヘッダを全て取得する
apache_reset_timeout — Apache の書き込みタイマーをリセットする
apache_response_headers — HTTPレスポンスヘッダを全て取得する
apache_setenv — Apacheサブプロセスの環境変数を設定する
ascii2ebcdic — ASCIIからEBCDICに文字列を変換する
ebcdic2ascii — EBCDICからASCIIに文字列を変換する
getallheaders — 全てのHTTPリクエストヘッダを取得する
virtual — Apache サブリクエストを実行する


add a note add a note User Contributed Notes
Apache専用の関数
bgshea at gmail dot com
29-Nov-2005 12:41
here is a dynamic version of henk_nicolai at REMOVE-THIS at hotmail dot com's code

    $req = $_SERVER['REQUEST_URI'];
    // Remove rubbish.
    $newReq = ereg_replace ( $_SERVER['SCRIPT_NAME'] . '[^?]*', $_SERVER['SCRIPT_NAME'], $req);
    if (strlen($newReq) < strlen($req))
    {
        header ('Location: '.$newReq);
        header ('HTTP/1.0 301 Moved Permanently');
        die;  // Don't send any more output.
    }
    unset($req);
    unset($newReq);

this can be placed at the top of any file that is to be access by the URI.
pike
02-Nov-2005 08:16
to henk_nicolai

the behaviour you describe is not a "glitch" of apache :-). an url like
"http://my_server.nl/index.php/foo".  should return the resource http://my_server.nl/index.php and pass "/foo" as PATH_INFO in the environment.

which is extremely usefull if you use it wisely.

for more info on PATH_INFO and PATH_TRANSLATED, see http://nl2.php.net/reserved.variables . PATH_INFO is not related to the php pathinfo() function

$2c,
*pike
outofnet at mail dot ru
27-Aug-2004 11:44
Important info for Apache2 users that have several virtual hosts.

It seems php_flag directive has a different behaviour under Apache 2 (from what it is under 1.3) when used inside <VirtualHost> block.

If you override global php.ini settings with php_flag for one of your virtual host - then your other non-customized virtual hosts may use this overrided settings as well. php_flag records are messed up among different virtual hosts under single Apache 2 server. It may result from Apache 2 multi-thread nature.

Here is an example:

Suppose you have two Virtual hosts: V1 and V2.
For V1 in Apache configuration you use
php_flag magic_quotes_gpc 1
V2 is supposed to use global php.ini settings, so you didn't put any php_flag records into Apache conf for V2 (this worked under Apache 1.3).
And your default php.ini settings are:
php_flag magic_quotes_gpc 0

When you run your server you'll notice that magic quotes is (sometimes) set to On at V2!
The value turns On at V2 when there have been a previous request to V1.

To solve the problem either move php_flag into .htaccess located inside customized virtual host directory OR put php_flag with default settings into all your <VirtualHost> blocks that are not customized. So for V2 put:
php_flag magic_quotes_gpc 0

It is critical to be very carefull with php_flag engine 0.

My configuration is:
PHP 4.3.4, Apache 2.0.50, Linux RedHat 9
henk_nicolai at REMOVE-THIS at hotmail dot com
20-Nov-2002 09:03
My Apache server has a problem when someone enters a URI like: "http://my_server.nl/index.php/". (Note the extra slash.) The server executes the index.php script anyway, which causes the browser directory and the current directory used in the script to be different. And therefore my relative links don't work, and my stylesheet is not loaded. A quick test ("http://www.php.net/manual/en/index.php/") reveals that also this site has this glitch.

When a client requests a directory without the last slash ("http://www.php.net/manual") the server sends a HTTP 301 (Moved Permanently) response with a redirect to the correct URI ("http://www.php.net/manual/"), and my idea was to do the same when the user adds a slash too much:

<?php
   $req
= $_SERVER['REQUEST_URI'];
  
// Remove rubbish.
  
$newReq = ereg_replace ('index.php[^?]*', 'index.php', $req);
   if (
strlen($newReq) < strlen($req)) {
    
header ('Location: '.$newReq);
    
header ('HTTP/1.0 301 Moved Permanently');
     die; 
// Don't send any more output.
  
}
   unset(
$req); unset($newReq);

   ... (
rest of the script) ...
?>

Replace every occurence of 'index.php' with your filename and you're done. Hope it helps. :-)

(Note: I'm not using fragments in my URI's (like 'index.php#bottom'), and this code may not do what you want if you are using them.)
cjm2 at earthling dot net
11-Jan-2002 08:40
If you are trying to find a Handler to use with apache's mod_mime functions (e.g. SetHandler).  Use the MIME type associated with php.

e.g. SetHandler application/x-httpd-php
jarl at diku dot dk
25-Mar-2000 08:12
Many of the environment variables can be found here:
http://www.php.net/manual/language.variables.predefined.php

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