📄 install.txt
字号:
Windows NT/2000/XP and IIS 4 or newer
To install PHP on an NT/2000/XP Server running IIS 4 or newer, follow
these instructions. You have two options to set up PHP, using the CGI
binary (php.exe in PHP 4, or php-cgi.exe in PHP 5) or with the ISAPI
module.
In either case, you need to start the Microsoft Management Console
(may appear as 'Internet Services Manager', either in your Windows NT
4.0 Option Pack branch or the Control Panel=>Administrative Tools
under Windows 2000/XP). Then right click on your Web server node (this
will most probably appear as 'Default Web Server'), and select
'Properties'.
If you want to use the CGI binary, do the following:
* Under 'Home Directory', 'Virtual Directory', or 'Directory', click
on the 'Configuration' button, and then enter the App Mappings
tab.
* Click Add, and in the Executable box, type: C:\php\php.exe for PHP
4 or C:\php\php-cgi.exe for PHP 5 (assuming that you have unziped
PHP in c:\php\).
* In the Extension box, type the file name extension you want
associated with PHP scripts. Leave 'Method exclusions' blank, and
check the 'Script engine' checkbox. You may also like to check the
'check that file exists' box - for a small performance penalty,
IIS (or PWS) will check that the script file exists and sort out
authentication before firing up PHP. This means that you will get
sensible 404 style error messages instead of CGI errors
complaining that PHP did not output any data.
You must start over from the previous step for each extension you
want associated with PHP scripts. .php and .phtml are common,
although .php3 may be required for legacy applications.
* Set up the appropriate security. (This is done in Internet Service
Manager), and if your NT Server uses NTFS file system, add execute
rights for I_USR_ to the directory that contains php.exe /
php-cgi.exe.
To use the ISAPI module, do the following:
* If you don't want to perform HTTP Authentication using PHP, you
can (and should) skip this step. Under ISAPI Filters, add a new
ISAPI filter. Use PHP as the filter name, and supply a path to the
php4isapi.dll / php5isapi.dll.
* Under 'Home Directory', click on the 'Configuration' button. Add a
new entry to the Application Mappings. Use the path to the
php4isapi.dll / php5isapi.dll as the Executable, supply .php as
the extension, leave 'Method exclusions' blank, and check the
'Script engine' checkbox.
* Stop IIS completely (NET STOP iisadmin)
* Start IIS again (NET START w3svc)
_________________________________________________________________
Apache 1.3.x on Microsft Windows
This section contains notes and hints specific to Apache 1.3.x
installs of PHP on Microsoft Windows systems. We also have
instructions and notes for Apache 2 on a separate page.
Note: You should read the manual installation steps first!
There are two ways to set up PHP to work with Apache 1.3.x on Windows.
One is to use the CGI binary (php.exe for PHP 4 and php-cgi.exe for
PHP 5), the other is to use the Apache module DLL. In either case you
need to edit your httpd.conf to configure Apache to work with PHP, and
then restart the server.
It is worth noting here that now the SAPI module has been made more
stable under Windows, we recommend it's use above the CGI binary,
since it is more transparent and secure.
Although there can be a few variations of configuring PHP under
Apache, these are simple enough to be used by the newcomer. Please
consult the Apache Documentation for further configuration directives.
After changing the configuration file, remember to restart the server,
for example, NET STOP APACHE followed by NET START APACHE, if you run
Apache as a Windows Service, or use your regular shortcuts.
Note: Remember that when adding path values in the Apache
configuration files on Windows, all backslashes such as
c:\directory\file.ext must be converted to forward slashes, as
c:/directory/file.ext.
_________________________________________________________________
Installing as a CGI binary
If you unziped the PHP package to C:\php\ as described in the Manual
Installation Steps section, you need to insert these lines to your
Apache configuration file to set up the CGI binary:
Example 2-3. PHP and Apache 1.3.x as CGI
ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php
# For PHP 4
Action application/x-httpd-php "/php/php.exe"
# For PHP 5
Action application/x-httpd-php "/php/php-cgi.exe"
# specify the directory where php.ini is
SetEnv PHPRC C:/php
Note that the second line in the list above can be found in the actual
versions of httpd.conf, but it is commented out. Remember also to
substitute the c:/php/ for your actual path to PHP.
Warning
By using the CGI setup, your server is open to several possible
attacks. Please read our CGI security section to learn how to defend
yourself from those attacks.
If you would like to present PHP source files syntax highlighted,
there is no such convinient option as with the module version of PHP.
If you chose to configure Apache to use PHP as a CGI binary, you will
need to use the show_source() function. To do this simply create a PHP
script file and add this code: <?php
show_source("original_php_script.php"); ?>. Substitute
original_php_script.php with the name of the file you wish to show the
source of.
_________________________________________________________________
Installing as an Apache module
You should add the following lines to your Apache httpd.conf file:
Example 2-4. PHP as an Apache 1.3.x module
AddType application/x-httpd-php .php
# For PHP 4
LoadModule php4_module "c:/php/sapi/php4apache.dll"
# For PHP 5
LoadModule php5_module "c:/php/php5apache.dll"
# specify the directory where php.ini is
SetEnv PHPRC C:/php
You may find after using the Windows installer for Apache that you
need to define the AddModule directive for mod_php4.c. This is
especially important if the ClearModuleList directive is defined,
which you will find by scrolling down a few lines. You will see a list
of AddModule entries, add the following line at the end of the list:
AddModule mod_php4.c. For PHP 5, instead use AddModule mod_php5.c
If you would like to use the source code highlighting feature, you
need to add the following line to your httpd.conf: AddType
application/x-httpd-php-source .phps. This should be inserted at the
same place where you inserted AddType application/x-httpd-php .php
above). With this setup, all files served with the .phps extension
will be syntax highlighted for the browser.
_________________________________________________________________
Apache 2.0.x on Microsoft Windows
This section contains notes and hints specific to Apache 2.0.x
installs of PHP on Microsoft Windows systems. We also have
instructions and notes for Apache 1.3.x users on a separate page.
Note: You should read the manual installation steps first!
Warning
Do not use Apache 2.0.x and PHP in a production environment neither on
Unix nor on Windows. For information on why, read the following FAQ
entry
You are highly encouraged to take a look at the Apache Documentation
to get a basic understanding of the Apache 2.0.x Server. Also consider
to read the Windows specific notes for Apache 2.0.x before reading on
here.
PHP and Apache 2.0.x compatibility notes: The following versions of
PHP are known to work with the most recent version of Apache 2.0.x:
* PHP 4.3.0 or later available at http://www.php.net/downloads.php.
* the latest stable development version. Get the source code
http://snaps.php.net/php4-latest.tar.gz or download binaries for
Windows http://snaps.php.net/win32/php4-win32-latest.zip.
* a prerelease version downloadable from http://qa.php.net/.
* you have always the option to obtain PHP through anonymous CVS.
These versions of PHP are compatible to Apache 2.0.40 and later.
Apache 2.0 SAPI-support started with PHP 4.2.0. PHP 4.2.3 works
with Apache 2.0.39, don't use any other version of Apache with PHP
4.2.3. However, the recommended setup is to use PHP 4.3.0 or later
with the most recent version of Apache2.
All mentioned versions of PHP will work still with Apache 1.3.x.
Warning
Apache 2.0.x is designed to run on Windows NT 4.0, Windows 2000 or
Windows XP. At this time, support for Windows 9x is incomplete. Apache
2.0.x is not expected to work on those platforms at this time.
Download the most recent version of Apache 2.0.x and a fitting PHP
version. Follow the Manual Installation Steps and come back to go on
with the integration of PHP and Apache.
There are two ways to set up PHP to work with Apache 2.0.x on Windows.
One is to use the CGI binary the other is to use the Apache module
DLL. In either case you need to edit your httpd.conf to configure
Apache to work with PHP and then restart the server.
Note: Remember that when adding path values in the Apache
configuration files on Windows, all backslashes such as
c:\directory\file.ext must be converted to forward slashes, as
c:/directory/file.ext.
_________________________________________________________________
Installing as a CGI binary
You need to insert these three lines to your Apache httpd.conf
configuration file to set up the CGI binary:
Example 2-5. PHP and Apache 2.0 as CGI
ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php
# For PHP 4
Action application/x-httpd-php "/php/php.exe"
# For PHP 5
Action application/x-httpd-php "/php/php-cgi.exe"
Warning
By using the CGI setup, your server is open to several possible
attacks. Please read our CGI security section to learn how to defend
yourself from those attacks.
_________________________________________________________________
Installing as an Apache module
You need to insert these two lines to your Apache httpd.conf
configuration file to set up the PHP module for Apache 2.0:
Example 2-6. PHP and Apache 2.0 as Module
# For PHP 4 do something like this:
LoadModule php4_module "c:/php/sapi/php4apache2.dll"
AddType application/x-httpd-php .php
# For PHP 5 do something like this:
LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "C:/php"
Note: Remember to substitute the c:/php/ for your actual path to
PHP in the above examples. Take care to use either php4apache2.dll
or php5apache2.dll in your LoadModule directive and not
php4apache.dll or php5apache.dll as the latter ones are designed to
run with Apache 1.3.x.
Warning
Don't mix up your installation with DLL files from different PHP
versions. You have the only choice to use the DLL's and extensions
that ship with your downloaded PHP version.
_________________________________________________________________
Sun, iPlanet and Netscape servers on Microsoft Windows
This section contains notes and hints specific to Sun Java System Web
Server, Sun ONE Web Server, iPlanet and Netscape server installs of
PHP on Windows.
From PHP 4.3.3 on you can use PHP scripts with the NSAPI module to
generate custom directory listings and error pages. Additional
functions for Apache compatibility are also available. For support in
current webservers read the note about subrequests.
_________________________________________________________________
CGI setup on Sun, iPlanet and Netscape servers
To install PHP as a CGI handler, do the following:
* Copy php4ts.dll to your systemroot (the directory where you
installed Windows)
* Make a file association from the command line. Type the following
two lines:
assoc .php=PHPScript
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -