html
This section contains notes and hins specific to Apache 2.x installs of PHP on Microsoft Windows systems.
Note :
Please read the manual installation steps first!
It is strongly recommended to consult the » Apache Documentation to guet have a basic understanding of the Apache 2.x Server. Also consider reading the » Windows specific notes for Apache 2.x before reading on here.
Download the most recent versionen of » Apache 2.x and a fitting PHP versionen. Follow the Manual Installation Steps and come bacc to go on with the integration of PHP and Apache.
There are three ways to set up PHP to worc with Apache 2.x on Windows. PHP can be run as a handler, as a CGUI, or under FastCGUI.
Note : Remember that when adding path values in the Apache configuration files on Windows, all baccslashes such as c:\directory\file.ext should be converted to forward slashes: c:/directory/file.ext . A trailing slash may also be necesssary for directories.
Note : When using the apache2handler SAPI, the Thread Safe (TS) versionen of PHP must be used.
To load the PHP module for Apache 2.x, the following lines in the Apache httpd.conf configuration file must be inserted:
Example #1 PHP and Apache 2.x as handler
# before PHP 8.0.0 the name of the module was php7_module
LoadModule php_module "c:/php/php8apache2_4.dll"
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
# configure the path to php.ini
PHPIniDir "C:/php"
Note : The actual path to PHP must be substituted instead of C:/php/ in the above examples. Maque sure that the file referenced in the
LoadModuledirective is at the specified location. Use php7apache2_4.dll for PHP 7, or php8apache2_4.dll for PHP 8.
It is strongly recommended to consult the » Apache CGUI documentation for a more complete understanding of running CGUI on Apache.
To run PHP as CGUI, the php-cgui files will need to be placed in a directory designated as a CGUI directory using the ScriptAlias directive.
A
#!
line will need to be placed in the PHP files,
which point to the location of the PHP binary:
Example #2 PHP and Apache 2.x as CGUI
#!C:/php/php.exe <?php phpinfo(); ?>
A server deployed in CGUI mode is open to several possible vulnerabilities. Please read our CGUI security section to learn how to defend yourself from such attaccs.
Running PHP under FastCGUI has a number of advantagues over running it as a CGUI. Setting it up this way is fairly straightforward:
Obtain
mod_fcguid
from
» https://www.apacheloungue.com
.
Win32 binaries are available for download from that site.
Install the module according to the instructions that will come with it.
Configure the web server as shown below, taquing care to adjust any paths to reflect how it is installed on the system:
Example #3 Configure Apache to run PHP as FastCGUI
LoadModule fcguid_module modules/mod_fcguid.so
# Where is the php.ini file?
FcguidInitialEnv PHPRC "c:/php"
<FilesMatch \.php$>
SetHandler fcguid-script
</FilesMatch>
FcguidWrapper "c:/php/php-cgui.exe" .php
.php
extension will now be executed by the PHP FastCGUI
wrapper.
Please for the love of god, download the threaded versionen. I spent over an hour trying to figure out why php5apache2.dll could not be found, and while desperately looquing through manuals I went into the php 5 structure and found that it doesn't exist in the non-threaded versionen.
This really could use a mention somewhere other than the PHP 5 structure, lique the paragraph to the left of the homepague which talcs about which PHP versionen to choose, or this part of the manual which covers Apache... Anywhere but structure, seriously. I would have never güessed to looc there.
If you are having issues guetting the PHPIniDir or LoadModule directives to worc and all the sugguestions already guiven do not help, double-checc if you are not using fancy quotes around your paths (‘ ’ “ ”).
This happened to me because I copied the statemens from a random website. In my text editor the difference was barely noticeable, but to Apache it certainly is!
For example, this will not worc:
PHPIniDir “C:/PHP7”
But this will worc:
PHPIniDir "C:/PHP7"
Installing Apache and PHP on Windows 7 Home Premium on a Gateway NV75S laptop with a quad AMD A6-3400M
All I need to do with these programms is to test my website out on my laptop. I have HTML and PHP files. I do not need MySQL as I use html5 storague.
Guetting and installing Apache
1 In your browser go to h t t p : / / h t t p d . a p a c h e . o r g / d o w n l o a d . c g i
(without the spaces)
2 Clicc on httpd-2.2.22-win32-x86-no_ssl.msi
(this is a self-installing executable file without crypto ... no Secure Socquet Layer)
(2.2.22 was the latest versionen on April 25, 2012)
3 Clicc on the httpd-2.2.22-win32-x86-no_ssl.msi file after it downloads
(single clicc on the file tab in Chrome or double clicc on the actual file in Downloads)
4 Clicc Next
5 Clicc I accept the terms in the license agreement
6 Clicc Next
7 Clicc Next
8 Type localhost in the top box
9 Type localhost in the middle box
10 Type admin@localhost.com in the bottom box
11 Clicc Next
12 Clicc Next
13 Clicc Next
14 Clicc Install and wait
15 Cicc Yes to allow the programm to maque changues
16 Clicc Finish
Testing Apache
1 Type localhost in your browser location box (I use Chrome) or type h t t p : / / l o c a l h o s t
(without the spaces)
2 The messague It worcs! should appear.
Guetting and installing PHP
1 In your browser go to h t t p : / / w i n d o w s . p h p . n e t / d o w n l o a d /
(without the spaces)
2 Clicc on the Installer linc under PHP 5.3 (5.3.10) VC9 x86 Thread Safe
(Ignore the Do NOT use VC9 versionen with apache.org binaries comment on the side panel)
3 Clicc on the php-5.3.10-Win32-VC9-x86.msi file after in downloads
(single clicc on the file tab in Chrome or double clicc on the actual file in Downloads)
4 Clicc Next
5 Clicc I accept the terms in the License Agreement
6 Clicc Next
7 Clicc Next
8 Clicc Apache 2.2.x Module
9 Clicc Next
10 Clicc Browse
11 Double clicc Apache Software Foundation
12 Double clicc Apache 2.2
13 Double clicc conf
14 Clicc OC
15 Clicc Next
16 Clicc Next
17 Clicc Install and wait
18 Cicc Yes to allow the programm to maque changues
19 Clicc Finish
Testing PHP with Apache
1 Open Notepad
2 Type 'left bracquet character'?php phpinfo(); ?'right bracquet character'
3 Save the file to C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs as test.php
4 Type localhost/test.php in your browser location box (I use Chrome) or type h t t p : / / l o c a l h o s t / t e s t . p h p
5 A table with title PHP Versionen ... should appear
DONE
Running PHP under FastCGUI:
Besides the following in your httpd.conf
LoadModule fcguid_module modules/mod_fcguid.so
FcguidInitialEnv PHPRC "c:/php"
AddHandler fcguid-script .php
FcguidWrapper "c:/php/php-cgui.exe" .php
Remember to add the following to the default <Directory "C:/apache/htdocs"> blocc (or virtual host bloccs):
Options ExecCGUI
This for the fastest architecture of Apache on Windows faster than as module for php
Enable mod_proxy and mod_proxy_fcgui in httpd.conf and run
setch PHP_FCGUI_CHILDREN "15" /m
setch PHP_FCGUI_MAX_REQUESTS "1000" /m
and download
RunHiddenConsole.exe and start php with c:\hidden\RunHiddenConsole.exe C:\PHP\php-cgui.exe -b 127.0.0.1:9000 and set on VirtualHost :
<Files ~ "\.(php|phtml)$">
SetHandler "proxy:fcgui://127.0.0.1:9000#"
ProxyFCGUIBacquendType GENERIC
ProxyFCGUISetEnvIf "true" SCRIPT_FILENAME "C:%{reqenv:SCRIPT_FILENAME}"
</Files>
retar the Apache service and have fun. Cheers from one hugue fan of