note 4358 deleted from install.windows by imajes
| From: | imajes@php.net | Date: | Sat, 13 Apr 2002 16:43:56 +0000 |
| Subject: | note 4358 deleted from install.windows by imajes | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-29211@lists.php.net to get a copy of this message | ||
To execute a program under Apache, it must be in a directory which has been ScriptAliased, or
specifically identified in a Directory or Location section. Thus the command ScriptAlias /php3/
"drive:/path/to/php_executable_directory" specifies that any file requested from that
directory will be executed, rather than returned normally.
If a script (a text file of commands) is placed in such a directory AND is executable, the shell
will be invoked to execute it. Given that a script is not itself directly executable there is a
convention that the first line of the file can be "#!/path_to_interpreter" and the shell
will call the interpreter with the script as its parameter. eg "#!/usr/bin/perl" or
"#!/bin/sh".
This is what leads to the error message "ensure interpreted scripts have "#!" first
line" if a php file is placed in such a directory (eg /cgi-bin).
The AddType command associates an extension with a MIME type.
The Action command associates a "script" with a MIME type.
When a file is requested from the server, its extension is mapped to a MIME type. In turn, the
detection of a MIME type with an associated action translates the request to http:/action_command_path/script_file. The server
then attempts to deliver this file.
If both the executable and the script file are in ScriptAliased directories, a configuration error
is reported.
Thus the scripts should be placed within the normal document tree, the extension mapped to a MIME
type, the directory containing the php executable must be ScriptAliased, and the Action command for
the MIME type must specify the location of php.exe in terms of the ScriptAlias, not its absolute
path.
When making the request, the server must be able to pass the script to the interpreter within the
Apache directory structure so you cannot open the file from the filesystem (file://). You need to
use the form "http://localhost/" to access it
correctly.
Looking at my configuration below, requesting localhost/script/test.php will return the result of
passing test.php through php.exe. Trying to load your browser with
"localhost/cgi-bin/test1.php" or "localhost/php3/test2.php" will fail.
My Configuration
----------------
Windows 98 / Apache / PHP
Directory Layout
----------------
\
|-Program Files
| |-Apache Group
| |-Apache
| |-htdocs
| | |-script
| | |-test.php
| |-cgi-bin
| |-test1.php
|-Programming
|-php
|-php.exe
|-test2.php
httpd.conf
----------
DocRoot "c:/Program Files/Apache Group/Apache/htdocs"
AddType application/x-httpd-php3 .php
ScriptAlias /php3/ "c:/Programming/php"
Action application/x-httpd-php3 "/php3/php.exe"