PHP 7.0.6 Released

## Installation des serveurs Apache 2.x sur les systèmes Microsoft Windows

Cette section contient les notes et conseils d'installation de PHP avec le serveur Apache 2.x sur les systèmes Microsoft Windows. Nous avons également des notes et des instructions pour Apache 1.3.x sur une page séparée.

Note:

Vous devriez lire les étapes d'installation du manuel d'abord !

Note: Support Apache 2.2

Les utilisateurs d'Apache 2.2 doivent conserver à l'esprit que la bibliothèque DLL d'Apache 2.2 sont nommées php5apache2_2.dll plutôt que php5apache2.dll et n'est disponible que pour PHP 5.2.0 et suivants.

Il est vivement recommandé de consulter la » documentation Apache pour avoir une meilleure connaissance du serveur web Apache 2.x. Lisez également les » notes spécifiques à Windows pour Apache 2.x avant de lire cette documentation.

Apache 2.x est prévu pour fonctionner sur les versions de Windows désignées comme serveurs, comme Windows NT 4.0, Windows 2000, Windows XP, ou Windows 7. Bien qu'Apache 2.x fonctionne parfaitement bien sous Windows 9x, le support de ces plateformes est incomplet et quelques fonctionnalités peuvent ne pas fonctionner correctement ; et il n'est pas prévu d'améliorer cela.

Téléchargez la version la plus récente de » Apache 2.x et une version de PHP. Suivez les instructions d'installation manuelle puis revenez ici pour réaliser l'intégration de PHP et Apache.

Il y a trois méthodes pour que PHP fonctionne avec Apache 2.x sous Windows. Vous pouvez exécuter PHP comme gestionnaire, comme CGI ou comme FastCGI.

Note: Souvenez-vous que lorsque vous ajoutez des valeurs représentants un chemin dans la configuration d'Apache sous Windows, tous les antislash, comme c:\repertoire\fichier.ext, devraient être convertis en slashes, comme c:/repertoire/fichier.ext. Un slash final peut également être nécessaire pour les dossiers.

### Installation d'Apache comme gestionnaire

Vous devez insérer les lignes suivantes dans le fichier de configuration httpd.conf d'Apache pour charger le module PHP pour Apache 2.x :

Exemple #1 PHP et Apache 2.x comme gestionnaire

#

# configure the path to php.ini
PHPIniDir "C:/php"

Note: Rappelez-vous de placer votre chemin actuel de PHP dans le chemin C:/php/ des exemples ci-dessous. Assurez-vous d'utiliser soit php5apache2.dll, soit php5apache2_2.dll dans la directive LoadModule et de vérifiez que le fichier correspondant est en réalité situé dans le chemin utilisé dans cette directive.

La configuration suivante activera le gestionnaire PHP pour tous les fichiers qui ont l'extension .php, même si d'autres extensions sont utilisées pour ces fichiers. Par exemple, un fichier nommé example.php.txt sera exécuté par le gestionnaire PHP. Pour vous assurez que seuls les fichiers se terminant par .php sont exécutés, utilisez plutôt la configuration suivante :

<FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch> ### Exécution de PHP en tant que CGI Vous devriez consulter la » documentation Apache CGI où vous trouverez toutes les informations nécessaires à l'exécution d'Apache CGI. Pour exécuter PHP en tant que CGI, vous devez placer tous vos fichiers php-cgi dans un dossier désigné comme dossier CGI en utilisant la directive ScriptAlias. Vous devez ensuite insérer une ligne #! dans vos fichiers PHP, pointant vers le binaire PHP : Exemple #2 PHP et Apache 2.x en tant que CGI #!C:/php/php.exe <?php phpinfo(); ?>  Avertissement En utilisant le mode CGI, votre serveur est ouvert à de possibles attaques sérieuses. Lisez attentivement notre section sur la sécurité en mode CGI pour apprendre comment vous défendre contre ces attaques. ### Exécuter PHP en tant que FastCGI L'exécution de PHP en tant que FastCGI a un beaucoup d'avantages contrairement à son exécution en tant que CGI. Sa mise en place de cette manière est assez simple : Récupérez mod_fcgid depuis » http://httpd.apache.org/mod_fcgid/. Les bibliothèques Win32 sont disponibles au téléchargement depuis ce site. Installez le module suivant les instructions fournies. Configurez votre serveur web comme ci-dessous, en vous assurant d'ajuster tous les chemins pour refléter votre configuration système particulière : Exemple #3 Configuration d'Apache pour exécuter PHP en tant que FastCGI LoadModule fcgid_module modules/mod_fcgid.so # Où se trouve le fichier php.ini ? FcgidInitialEnv PHPRC "c:/php" AddHandler fcgid-script .php FcgidWrapper "c:/php/php-cgi.exe" .php  Les fichiers avec l'extension .php seront maintenant exécutés par le gestionnaire PHP FastCGI. add a note ### User Contributed Notes 56 notes 18 wolfeh1994 at yahoo dot com 2 years ago  Please for the love of god, download the threaded version. I spent over an hour trying to figure out why php5apache2.dll could not be found, and while desperately looking through manuals I went into the php 5 structure and found that it doesn't exist in the non-threaded version.This really could use a mention somewhere other than the PHP 5 structure, like the paragraph to the left of the homepage which talks about which PHP version to choose, or this part of the manual which covers Apache... Anywhere but structure, seriously. I would have never guessed to look there.  ohcc at 163 dot com 9 months ago  If you come with an error like this: Wrapper xxxx cannot be accessed: blah blah blah when starting Apache.You have 3 choices to solve this problem. Any one of them would work.1. Reinstall your applictions in paths that do not contain spaces.2. Place a backslash before every space in the path set to the FcgidWrapper directive in httpd.conf, like:FcgidWrapper "C:/Program\ Files/PHPServer/PHP/php-cgi.exe" .php3. Use mklink (or junction for windows XP/2003) to create a symbol link to the path of php-cgi.exe's containing folder.run cmd.exe and type this command:mklink /j C:\php\ "C:\Program Files\PHPServer\PHP". or this command if you are on Windows XP/2003junction C:\php\ "C:\Program Files\PHPServer\PHP"Remember this : you need to download junction.exe to use it. Don't know where to download? Google it.Then the FcgidWrapper directive should be like this:FcgidWrapper "C:/php/php-cgi.exe" .phpDon't forget to change the paths above to your working paths.  a solution for simpletons like me 4 years ago  Installing Apache and PHP on Windows 7 Home Premium on a Gateway NV75S laptop with a quad AMD A6-3400MAll I need to do with these programs is to test my website out on my laptop. I have HTML and PHP files. I do not need MySQL as I use html5 storage.Getting and installing Apache1 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 Click on httpd-2.2.22-win32-x86-no_ssl.msi (this is a self-installing executable file without crypto ... no Secure Socket Layer) (2.2.22 was the latest version on April 25, 2012)3 Click on the httpd-2.2.22-win32-x86-no_ssl.msi file after it downloads (single click on the file tab in Chrome or double click on the actual file in Downloads)4 Click Next5 Click I accept the terms in the license agreement6 Click Next7 Click Next8 Type localhost in the top box9 Type localhost in the middle box10 Type admin@localhost.com in the bottom box11 Click Next12 Click Next13 Click Next14 Click Install and wait15 Cick Yes to allow the program to make changes16 Click FinishTesting Apache1 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 message It works! should appear.Getting and installing PHP1 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 Click on the Installer link under PHP 5.3 (5.3.10) VC9 x86 Thread Safe (Ignore the Do NOT use VC9 version with apache.org binaries comment on the side panel)3 Click on the php-5.3.10-Win32-VC9-x86.msi file after in downloads (single click on the file tab in Chrome or double click on the actual file in Downloads)4 Click Next5 Click I accept the terms in the License Agreement6 Click Next7 Click Next8 Click Apache 2.2.x Module9 Click Next10 Click Browse11 Double click Apache Software Foundation12 Double click Apache 2.213 Double click conf14 Click OK15 Click Next16 Click Next17 Click Install and wait18 Cick Yes to allow the program to make changes19 Click FinishTesting PHP with Apache1 Open Notepad2 Type 'left bracket character'?php phpinfo(); ?'right bracket character'3 Save the file to C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs as test.php4 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 p5 A table with title PHP Version ... should appearDONE  compleatguru at gmail dot com 2 years ago  I am using Windows 8 x64, running Apache 2.2 and php 5.4.20I found that it is necessary to add System Environment Variable PHPRC=[PHP path], so that php.ini is loaded using your PHP path, instead of C:\Windows.This is how I do for my laptopGo to Control Panel\System and Security\System\Advanced System Settings\Environment VariablesAdd New System VariableName: PHPRCValue: C:\php-5.4.20Hope it relieve those who keep having empty string for Loaded Configuration File under phpinfo();  farinspace 5 years ago  Running PHP under FastCGI:Besides the following in your httpd.conf LoadModule fcgid_module modules/mod_fcgid.so FcgidInitialEnv PHPRC "c:/php" AddHandler fcgid-script .php FcgidWrapper "c:/php/php-cgi.exe" .phpRemember to add the following to the default <Directory "C:/apache/htdocs"> block (or virtual host blocks): Options ExecCGI  tmnuwan12 at yahoo dot com 2 years ago  I am very new to PHP. I was looking to start a Drupal project and spend almost 4 hours to get Apache and Drupal talk each other.What I found out was there are lots of mismatch in documentation and snapshots.As I am using Windows I found out following two installation bundles works without any issue.php-5.3.28-Win32-VC9-x86.msihttpd-2.2.25-win32-x86-openssl-0.9.8y.msiMake sure you install your packages directly into into C: drive in Windows machine (If there are spaces in the file paths it would cause issues).Hope this would help someone.  Anonymous 7 years ago  i followed henke37's way to for the httpd.confI added all this at the very end of httpd.conf# For PHP 5 #load the php main library to avoid dll hellLoadfile "C:\php-5.2.8-Win32\php5ts.dll"#load the sapi so that apache can use phpLoadModule php5_module "C:\php-5.2.8-Win32\php5apache2_2.dll"#set the php.ini location so that you don't have to waste time guessing where it isPHPIniDir "C:\php-5.2.8-Win32"#Hook the php file extensionsAddHandler application/x-httpd-php .phpAddHandler application/x-httpd-php-source .phps Also i didn't use short open tags as they are disabled in "php.ini-recommended" if you don't change anythingSo use this to test <?php phpinfo();?>NOT <? phpinfo(); ?> short open tagsadded my php directory to the PATH system variable and i start apache manually not as a serviceIt works for me hope it helps you!  Guillermo Tallano 2 years ago  Hi guys, In my case, it work right away when I change the version to thread-safe. I spent some time trying the different things that were posted here and I was kind of lazy about downloading a different version, but once I test it with a thead-safe it started right away. So be sure you try this.I was on Apache 2.2, XP and php 5.2.17 thread-safeThis is my conf: LoadModule php5_module "c:/php5/php5apache2_2.dll"AddHandler application/x-httpd-php .php#configure the path to php.iniPHPIniDir 'C:\php5\'Good luck!  Bechesa at gmail dot com 4 years ago  Just a note It might be important you include the absolute path to the php.ini file inside the httpd.conf file so that php may load all the module(s).below is an example #BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALLPHPIniDir 'C:\PHP\php.ini'LoadModule php5_module "c:/php/php5apache2_2.dll"AddHandler application/x-httpd-php .php#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALLOS: windows 2008webserver: apache2.2  bdav 4 years ago  After spending few hours finally figured out that PHPINIDir path should be in single quotes and with backslash and php module with double quotes and regular slashes:PHPIniDir 'c:\apps\php\'LoadModule php5_module "c:/apps/php/php5apache2_2.dll"AddHandler application/x-httpd-php .php  ohcc at 163 dot com 9 months ago  If you come with an error like this: Wrapper xxxx cannot be accessed: blah blah blah when starting Apache.You have 3 choices to solve this problem. Any one of them would work.1. Install your applictions in paths that do not contains spaces.2. Place a backslash before every space in the path set to Wrapper, like:FctidWrapper "C:/Program\ Files/PHPServer/PHP/php-cgi.exe" .php3. Use mklink (or junction for windows XP/2003) to create a link to the path you have installed php in. run cmd.exe and type this command: mklink /j C:\php\ "C:\Program Files\PHPServer\PHP". or this command if you are on Windows XP/2003 junction C:\php\ "C:\Program Files\PHPServer\PHP" Remember this : you have to download online to use this application. Don't know where to download? Go and Google it.Then the FctidWrapper directive should be like this:FctidWrapper "C:/php/php-cgi.exe" .phpDon't forget to change the paths above to your working paths.  a user 4 months ago  If you are having issues getting the PHPIniDir or LoadModule directives to work and all the suggestions already given do not help, double-check if you are not using fancy quotes around your paths (‘ ’ “ ”).This happened to me because I copied the statements from a random website. In my text editor the difference was barely noticeable, but to Apache it certainly is!For example, this will not work:PHPIniDir “C:/PHP7”But this will work:PHPIniDir "C:/PHP7"  ohcc at 163 dot com 9 months ago  PHP 5.2 php5_module php5apache2_2.dllPHP 5.3 php5_module php5apache2_2.dllPHP 5.4 php5_module php5apache2_2.dll/php5apache2_4.dllPHP 5.5 php5_module php5apache2_4.dllPHP 5.6 php5_module php5apache2_4.dllPHP 7.0 php7_module php7apache2_4.dll  BuggedApache 1 year ago  Windows Apache 2.4.12 (x64) PHP 5.6.5 (x64)If your Apache still outputs code instead of parsing a script. Make sure you put a trailing "\" at the end of the PHPIniDir value and use ONLY "\" in path to PHPIniDir. And "/" in LoadModule. A very subtle "feature" of Apache module. Lost several hours after upgrading to apache x64 to resolve the issue.httpd.conf###############################################PHPIniDir "C:\folder\to\hold\php\"LoadModule php5_module "C:/folder/to/hold/php/php5apache2_4.dll"AddHandler application/x-httpd-php .php###############################################  Anonymous 1 year ago  With Apache 2.4 in Windows, it seems that PHPIniDir directive must come before LoadModule directive to be used. Also, name of the DLL file seems to be php5apache2_4.dll, not php5apache2.dll.This configuration in httpd.conf works for me (Apache 2.4.10, PHP 5.6.5):PHPIniDir "C:\PHP"LoadModule php5_module "c:/php/php5apache2_4.dll"<FilesMatch \.php$>      SetHandler application/x-httpd-php</FilesMatch> 
kynetikmedia at gmail dot com
1 year ago
 ****Installed and Working 1- Fell Swoop - UPDATED****Installed on Windows 8.1 XPS 12 - Dell 8GB RAM 128GB SSD - Notes - Complications due to Apache latest version causes issues with the PHP handler on install.  Following below will get it run right off the bat.  Getting and installing Apache1  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) - You will need to go 'Other Files' , 'Binaries' , 'W32', and then your installer MSI will be listed as below.  2  Click on  httpd-2.2.25-win32-x86-no_ssl.msi   (this is a self-installing executable file without crypto ... no Secure Socket Layer)   (2.2.25was the latest version on June 4, 2014)3  Click on the httpd-2.2.25-win32-x86-no_ssl.msi file after it downloads    (single click on the file tab in Chrome or double click on the actual file in Downloads)4  Click Next5  Click I accept the terms in the license agreement6  Click Next7  Click Next8  Type localhost in the top box9  Type localhost in the middle box10 Type admin@localhost.com in the bottom box11 Click Next12 Click Next13 Click Next14 Click Install and wait15 Cick Yes to allow the program to make changes16 Click FinishTesting Apache1  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 message It works! should appear.Getting and installing PHP1  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  Click on the Installer link under PHP 5.3 (5.3.10)   VC9 x86 Thread Safe   (Ignore the Do NOT use VC9 version with apache.org binaries comment on the side panel)3  Click on the php-5.3.10-Win32-VC9-x86.msi file after in downloads   (single click on the file tab in Chrome or double click on the actual file in Downloads)4  Click Next5  Click I accept the terms in the License Agreement6  Click Next7  Click Next8  Click Apache 2.2.x Module9  Click Next10 Click Browse11 Double click Apache Software Foundation12 Double click Apache 2.213 Double click conf14 Click OK15 Click Next16 Click Next17 Click Install and wait18 Cick Yes to allow the program to make changes19 Click FinishTesting PHP with Apache1  Open Notepad2  Type 'left bracket character'?php phpinfo(); ?'right bracket character'3  Save the file to C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs as test.php4  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 p5  A table with title PHP Version ... should appearDONE 
Amaroq
3 years ago
 Like someone else mentioned, on the Windows download page for PHP, ignore the warning about not downloading the VC9 compiled installers for the Apache.org version of Apache.Whoever wrote that is guaranteeing that people install a PHP that breaks their Apache server. (On Windows 7 anyway.) The installer failed to write the correct path info to httpd.conf, and even after fixing that manually, Apache wouldn't start because of missing dlls.Ignore that dumb warning and get the newest installer anyway. Everything just plain works with no hassle and no hunting down dll files over google. 
Maw
3 years ago
 Good God finally I was able to make PHP 5.2 work on Apache 2.4. For those still having problems with "You don't have permission to run php-cgi.exe", you must replace "Order allow,deny" and "Allow from all" from the PHP directory block with "Require all granted". They must have changed the format with Apache 2.4 since the old method used to work just fine for me before.So the usual method of setting up CGI, I'm sure you already know that you should add these 3 lines to httpd.conf:ScriptAlias /php/ "c:/php/" AddType application/x-httpd-php .phpAction application/x-httpd-php "/php/php-cgi.exe"And now add the directory for PHP:<Directory "c:/php">    AllowOverride None    Options None    Require all granted</Directory>Important: Notice that instead of "Order allow,deny" and "Allow from all" added into the PHP directory as usual, I replaced them with "Require all granted" as I mentioned above. 
Z Carlos at Fortaleza
4 years ago
 A Thread Safe version should be used if you install PHP as an Apache module. The Non Thread Safe version should be used if you install PHP as a CGI binary. 
4 years ago
 I was able to get apache up and running without any problems. Then I tried installing php and it crashed trying to read "C:/php/php5apache2.dll".Fixed the problem by switching it to "C:/php/php5apache2_2.dll"Hope that helps! 
Cooldude
4 years ago
 Also had an exception problem when trying to use mysql with apache and php5. I had to add:"<my MySQL folder>\bin" folder to path"<my php folder>\ext" to paththat fixed it 
Cameron
4 years ago
 Here is yet another aspect of the "faulting module php5ts.dll" crash when trying to start apache.I installed Apache 2.2.18, Mysql 5.1.57 and PHP 5.2.17 (apache module, VC6 thread-safe - initially with no extensions) on a fresh WinXP SP3 system. The versions chosen were because I was trying to replicate as near as possible apps on my Linux server.Everything configured and ran properly without php extensions, so I then reran the msi installer and chose the necessary extensions.  I reconfigured httpd.conf  but apache then just kept crashing.Eventually I came across the "fix" mentioned elsewhere "copy libmysql.dll to apache folder" and suddenly it worked. But why? I checked and the php installation folder was in the system path. The answer was simply that I had never rebooted. It seems that whatever process controls windows services only reads the path at boot time.  I was thrown by assuming that if I started httpd from the command line then it would inherit that path.Here are a few diagnostic tips that helped me along the way:Try the CLI command:php -mand see that the command line version loads all the modules you asked for.in php.ini, enable display_errors = Onanddisplay_startup_errors = OnThe latter pops up a window saying which extension it has trouble loading. Of course it is not perfectly clear, because it says something like 'unable to load "C:\php\ext\php_mysql.dll" - The specified module could not be found'. It lies - it really does find that dll, but it must have failed on the dependency of libmysql.dll. 
lebovskiy at ua dot fm
5 years ago
 I install httpd-2.2.17-win32-x86-openssl-0.9.8o.msi and afterphp-5.3.3-Win32-VC9-x86.msi on WinXP SP3. PHP installation add to httpd.conf next lines:LoadModule php5_module "C:/PHP/php5apache2_2.dll"PHPIniDir "C:/PHP"After it Apache dont starts. If remove PHPIniDir line Apache  starts ok, but C:/PHP/php.ini dont loaded. So you cant use any extension (for me it's MySQL).I uninstall VC9 version and install VC6 (php-5.3.3-Win32-VC6-x86.msi) version. All works fine now. 
halmai
5 years ago
 I wanted to install PHP5.3 for Apache2.2 with PostgreSql 9.0 support on WindowsXP. It took me hours to solve it. The following possible problems occur:- You should use the VC6-compiled version of php instead of VC9. The later one does not work properly with apache.- the postgres handler dlls are not working in PHP5.3. The symptom was a misleading and very confusing error message:Unable to load dynamic library 'c:\Progra~1\PHP\ext\php_pgsql.dll'The dll itself was there but when it started to load the other dll (libpq.dll) from the php directory then this caused an error. This error was misinterpreted internally in the above message.The solution was NOT to use the libpq.dll from php but use it from postgres distribution instead. For this purpose I inserted the following line into the apache httpd conf:LoadFile "C:/Progra~1/PostgreSQL/9.0/bin/libpq.dll"This preloads the dll. When php_pgsql.dll would load his own libpq.dll, then there is the preloaded version of this file in the memory already. This prevents us from using the bad version of dll.I hope I helped. 
Nick
5 years ago
 After using the Windows installer for Apache 2.2 and PHP 5.3.2, and installing PHP as an Apache module (not CGI), Apache would crash and fail to start. There were two problems with the configuration files for Apache and PHP.First, make sure your Apache configuration file reads something similar to:LoadModule php5_module "C:/Program Files/PHP/php5apache2_2.dll"PHPIniDir "C:/Program Files/PHP/"While other users have disabled some or all of the MySQL extensions to prevent all three from running at the same time, I have all of them enabled. However, I do not have PostgreSQL, so I needed to comment out loading the php_pgsql.dll in my php.ini file, as follows:;[PHP_PGSQL];extension=php_pgsql.dllThis stopped Apache from crashing and started successfully. 
Michael
6 years ago
 The value for FcgidWrapper cannot contain spaces.. This won't work: FcgidWrapper "c:/program files (x86)/php/php-cgi.exe" .php But this will: FcgidWrapper "c:/progra~2/php/php-cgi.exe" .php 
Steve
6 years ago
 I also had a problem with the PHPIniDir declaration.  This is with Apache 2.2 on XP.  I had to include a final slash, as in PHPIniDir "C:\Program Files\php\".  Apache failed to start if I did not include the slash after php. 
Anonymous
6 years ago
 If anybody here encounters an error regarding PHPIniDir, change PHPIniDir "C:/php/" to PHPIniDir "C:\php\". 
nicolas dot grasset at gmail dot com
6 years ago
 Here is how I created a silent install for Apache2.2 and PHP5.2.10 on Windows XP (running on a MacBook Pro):Download Apache2 and PHP5 installer files in a directory and update the msi file names in the following commands.To have PHP installer find Apache2, do not forget APACHEDIR!msiexec /i apache_2.2.11-win32-x86-no_ssl.msi /passive ALLUSERS=1 SERVERADMIN=admin@localhost SERVERNAME=localhost SERVERDOMAIN=localhost SERVERPORT=80 INSTALLDIR=c:\apachemsiexec /i php-5.2.10-win32-installer.msi /qn APACHEDIR=c:\apache INSTALLDIR=c:\php ADDLOCAL=ext_php_mssql,apache22net stop "Apache2.2"net start "Apache2.2" 
-1
bitoolean
1 year ago
 The DLL to load in Apache 2 is now named php5apache2_4.dll 
-1
jangirashok at gmail dot com
2 years ago
 Can anyone tell me: Why PHP + Apache 2.2.x installation is such a big deal. I am a Java Developer and currently I am trying to learn PHP, but I am not able to install PHP and use it the way we use Java. I could use steps mentioned in comments and run home.php from htdocs folder of apache. But, could anyone please tell me DO I HAVE TO PUT EVERY FILE IN THE SAME FOLDER? Can't I make my workbench where I can put a good project hierarchy and use it like other languages. Its horrible. May be my question is little silly, but I need help for sure.Thanks... 
mjm at alum dot mit dot edu
8 years ago
 If you use the PHP 5 installer, you'll notice that it uses the wrong type of slash on Windows!Change C:/Program Files/PHP/" to C:\Program Files\PHP\" and everything works great! 
packard_bell_nec at hotmail dot com
8 years ago
 If you install PHP as an Apache CGI binary, you can add: AddHandler cgi-script .phpinto Apache httpd.conf, and add shebang line to every PHP scripts like: #!php<?phpphpinfo();?>. But adding shebang line has a disadvantage that if you decided to install PHP as an Apache module afterwards, then the shebang line WILL appear in the web page. In fact, you do NOT need to add shebang line to every PHP script even if you install PHP as an Apache CGI binary, because you can add: ScriptInterpreterSource Registry-Strictinto Apache httpd.conf, and make the registry file and merge it like: Windows Registry Editor Version 5.00[HKEY_CLASSES_ROOT\.php\Shell\ExecCGI\Command]@="\"C:\\Program Files\\PHP\\php-cgi.exe\"". Then you will NOT need to change the PHP scripts which do not contain shebang line. 
philippeboucher at newlogiccanada dot com dot com
8 years ago
 To do a silent install of PHP wich correctly modify the httpd.conf file, you HAVE (I find no other way) to put the directory of the Apache inside the INSTALLDIR's MSI option.  the APACHEDIR doesn't seem to work.  That's the only way I've make it work.  Maybe it's because my Apache is not in the default directory, I don't know, but there is a solution for people who cannot make work the silent install (for those who are told by the php setup that it cannot find the httpd.conf file).Hope it helps someone. 
Jim Keller
9 years ago
 it's important to note that on Apache 2.2.3 (probably other 2.x versions as well) on Windows, the PHPIniDir directive must use forward slashes to delimit directories, not the backslashes commonly used for Windows path strings. If PHP seems to be ignoring the directive, this may be why. 
pcdinh at phpvietnam dot net
9 years ago
 PHP 6 is under active development but for those whose want to try out the new features or just want to keep updated with the development progress of PHP 6.0, you can follow my instructions below to install it on Windows XP and Apache 2.2.3# For PHP 6 do something like this:LoadModule php5_module "c:/server/php6/php6apache2_2.dll"AddType application/x-httpd-php .phpPHPIniDir "c:/server/php6"You should change the path as in your system. The directive LoadModule php5_module seems a bit strange to you. It should be LoadModule php6_module instead. However, I have just taken a look at php.internals and came across a message that said it should be changed in the near future after the PHP 5.2 is official released. At the time I write this, PHP 5.2 RC6 is planned to be released in the next few days. 
subajawa at yahoo dot com
9 years ago
 To install PHP as Apache 2 CGI script, add these lines in addition to the 3 lines mentioned in the document.<Directory "C:/php">    AllowOverride None    Options None    Order allow,deny    Allow from all</Directory> 
Isaac dot Brown at ArvinMeritor dot com
10 years ago
 Some XP machines are having troubles with the PHPIniDir derective not finding the php.ini (or so they think). Directories that do contain a php.ini file are returned as empty and it defaults to the next method of finding php.ini (often C:/windows or C:/winnt). This is likely caused by read permissions not being set correctly on NTFS file systems, however, it has occurred when no cause could be identified. If setting correct file permissions doesn't work, the easiest way around this problem is moving php.ini to the Apache directory or adding the HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath string to your registry and setting it to the correct directory. 
-1
kriss266 at o2 dot pl
3 years ago
 [For the error:] You don’t have permission to access /php/php-cgi.exe/index.php on this server. In order to fix the forbidden error I had to change this line in httpd.conf: <Directory “C:/Server/Apache2.2/cgi-bin/”> AllowOverride None Options None Order allow,deny Allow from all </Directory> to this: <Directory “c:/Server/php”> AllowOverride None Options None Order allow,deny Allow from all </Directory> 
-1
robert dot nevinger at sbcglobal dot net
4 years ago
 Apache 2.2 crashing on WindowsXP/Apache2.2/php5.3.8_Win32.VC9-x86There is a distinction between LoadFile and LoadModule.LoadModule is typically used to load  Shared Objects (.so), and comes in very handy for Dynamically Shared ObjectsLoadFile on windows it typically used to load DLLPlease note:  In order for a LoadMoudle directive to work on a DLL the module must be compiled into the library.  If you use VI you can usually locate the module, but the file is compiled, don't write it!A dll can be located anywhere on the system.A .so should be located in your Apache install modules folder.What worked for me for Windows XP/Apache2.2/php5.3.8_Win32.VC9-x86PHPIniDir "C:/PHP/"LoadFile "C:/PHP/libeay32.dll"LoadFile "C:/PHP/libpq.dll"LoadFile "C:/PHP/libsasl.dll"LoadModule php5_module "C:\PHP\php5apache2_2.dll"This comment is to support the Apache startup, NOT serve PHP pages. 
-1
tcombass at gmail dot com
4 years ago
 If you are having problems with php5ts.dll...php5ts.dll is php5.dll but thread safe, hence the 'ts' at the end.  Software Details:MySQL  5.5PHP 5.2.17 VC6 Non-thread safeApache 2.2.19Win XP SP3Here's how I fixed the problem:I've been looking online on how to integrate Apache with PHP right so I come across this code to put in my httpd.conf apache configuration file:LoadModule php5_module "C:/php/php5apache2_2.dll"AddHandler application/x-httpd-php .phpPhpIniDir "C:/php"I paste it in a voila! it crashes!  I know its not news, but I looked and lo and behold its that darn php5ts.dll file!In short:I installed PHP 5.2.17 VC6 Non-Thread Safe.  I then installed the PHP 5.2.17 VC6 thread safe so I could copy these files from the thread safe installation into the PHP 5.2.17 VC6 Non-Thread safe installation directory:php5apache2_2.dllphp5apache2_2filter.dllNot sure if that last file is needed but I added it anyway.Then I uninstalled the thread safe installation.The Apache service started right up.Had some problems with MySQL too:When I installed it the first time it was fine.  Then I uninstalled it and got that "Service could not be started Error: 0" message.To do a complete deletion do this:1) Use MySQLInstanceconfig.exe to remove the service2) Use the "Add/Remove programs" to uninstall MySQL3) Delete the "c:\program files\MySQL directory"4) Delete the "c:\documents and settings\All Users\Application Data\MySql\" directory5) Launch regedit.exe from START>RUN and press ctrl+f for the find function and type in MYSQL to find and get rid of anything "MySQL" in there.  Press F3 to find repeat instances of "MySQL"I hope this helps you.  I spent about 30hrs uninstalling and reinstalling this crap... 
-1
yakfish
5 years ago
 If Apache won't start after PHP install, check for this scenario:When I followed the instructions for the Windows installer, using Apache HTTP server 2.2.17, the install completed normally but Apache would then fail to start. It turned out that the installer was not properly configuring the last section of Apache's httpd.conf file:#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALLPHPIniDir "c:/php/"LoadModule php5_module "c:/php/php5apache2_2.dll"#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALLThe text above is the correct configuration (in my case, I had asked the installer to place PHP into directory C:/PHP.)  However, the installer omitted the string "c:/php/" from the two lines above where you can see them. I had to edit the file, and add that string in manually, before Apache would start correctly. 
-1
2 years ago
 I got PHP 5.2.10 working on Apache 2.2 NOT using the .msi for PHP after a half day of trying different versions of PHP and Apache as well as changing everything from paths to folders. Eventually from reading many of the notes listed here I thought I'd download the threadsafe version but all I used from it were two .dll files. I took the php5apache2_2.dll and the php5ts.dll and swaped them out in my PHP folder and bingo! started working like a charm. The php5apache2_2.dll was probably unnecessary but I switched it out anyway.Summary... Add php5ts to your PHP folder 
-1
So Happy - phpinfo now loads correctly
2 years ago
 After installing Apache 2.2 and PHP 5.3.7 I could not get the phpinfo.php to display. When i attempted to pull up the php info page my browser would load the php script instead. I had added the following line to the Apache conf fileLoadModule php5_module "c:/php/php5apache2_2.dll"AddHandler application/x-http-php .phpPHPIniDir "c:/php"The issue was in the second line of code for the AddHandler, the code was missing a d after x-http, when I saw this typo I added the d, saved the conf file, cleared the cache of firefox, stopped Apache then started Apache again and the php info displayed correctly so make sure the line reads as followsAddHandler application/x-httpd-php .php 
-2
o.machala[at]email[dot]cz
3 years ago
 If you have a problem "The requested operation has failed!" and LOG says "Module php5apache2_2.dll not found" and have:PHPIniDir "P:\PHP\"LoadModule php5_module "P:\PHP\php5apache2_2.dll"in httpd.conf make sure you have installed the apache2.2 (not apache 2.0 or earlier versions). It was my problem and i downloaded correct version from http://www.apache.org/dist/httpd/binaries/win32/ and everything just works. 
-1
CP
7 years ago
 This is old news to some. But people with Apache 2.0.55 / PHP 5.1.2 might like a reminder before they pull their hair out! (Some of us have ISPs using older version and need to test on a like version before we upload.)If using PHP 5.1.2, to run Apache as a module, do *not* use Stephan's "php5apache2.dll" from http://www.ApacheLounge.com. That is for pre-5.1.2!**There is a "php5apache2.dll" included with Windows PHP 5.1.2 zip file by default.**If you forget this and overwrite the included DLL with Stephan's (as I did) you'll spend hours attempting to escape "DLL hell", with no success. 
-2
Bechesa at gmail dot com
4 years ago
 Just a note It might be important you include the absolute path to the php.ini  file inside the httpd.conf file so that php may load all the module(s).below is an example #BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALLPHPIniDir 'C:\PHP\php.ini'LoadModule php5_module "c:/php/php5apache2_2.dll"AddHandler application/x-httpd-php .php#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALLOS: windows 2008webserver: apache2.2 
-2
pkay(number42) at gmail dot com
5 years ago
 Running Apache2.2 on Windows 7.  There was no php5apache2_2.dll on my system, and all I got was a message box "The requested operation has failed!" (no, that's not OK).Finally realized that thread-safe version (VC6, mind!) was necessary - it had the dll in it.Downloaded that, apache runs with LoadModule php5_module 'C:/Program Files (x86)/PHP/php5apache2_2.dll'#etc 
-1
mike at supergrowlasers dot com
5 years ago
 I just spent 5 hours repeatedly trying, usuccessfully, to get Apache to parse php files instead of sending them to the browser.  I am setting up a Win 7 Pro box, and went through the configuration several times, as well as trying other configuration directives I found elsewhere by searching.Nothing worked. I was tearing my hair out and ready to cry.  I have set this up numerous times on XP with no problem.  But on Win 7 Pro it wasn't happening.Eventually I found this code, which worked perfectly (after taking out directives from httpd.conf that weren't working, of course)LoadFile "C:/php/php5ts.dll"LoadModule php5_module "C:/php/php5apache2.dll"<IfModule php5_module>    #PHPIniDir "C:/Windows"    #PHPIniDir "C:/Winnt"    <Location />        AddType text/html .php .phps        AddHandler application/x-httpd-php .php        AddHandler application/x-httpd-php-source .phps    </Location></IfModule>If you've been having the same problem, try this. You're welcome. 
-1
cormac at kernan dot eu
8 years ago
 All good advice from henke, except where it says "Do not edit the system path".  You will NOT be able to load extensions that have dependencies e.g. MySQL, without adding PHP to your system path.  This threw me for some time as other extensions without dependencies will work without this requirement. 
-1
anonymousness
8 years ago
 Verrrrrrrry important note:If you enable multi-byte strings for your installation of PHP, the extension loaded MUST be the first extension in the list.Apache, NOR PHP will generate any error messages or warning information in the error log or in system logs about this.This information needs to be included in the Readme or in the distributed INI files.The recommended PHP ini's should place extension=php_mbstring.dll  at the top of the list of extensions.I had completely forgotten about this when recently upgrading php on a test server; and almost set out to re-install apache. 
-1
charlie at oblivion dot cz
9 years ago
 ..try to set the extension_dir in php.ini to the absolute path.. (when you are pretty sure that you have set the PHPIniDir the right way) 
-4
Kerry Kobashi
6 years ago
 If you find that Apache crashes when you attempt to start it, its likely that one of the PHP extensions is the cause. This is likely the case if you use the PHP Windows installer and choose all extensions in the setup program to be installed on disk. Unfortunately, it will also enable all extensions too causing potential problems.For example, after installing PHP 5.2.11 and Apache 2.2 under Windows XP, Apache kept crashing. This was due to using all three versiosn of mysql extensions attempting to run:[PHP_MYSQL]extension=php_mysql.dll[PHP_MYSQLI]extension=php_mysqli.dll[PHP_PDO_MYSQL]extension=php_pdo_mysql.dll 
-7
Gedi
4 years ago
 I was struggling with configuring PHP 5.2.17. (msi version) forApache 2.2.22. on Windows 7. Apache was working before fine.The following failure message came as I tried to start Apache:"The requested operation has failed!"After many hours finally the comment from "bdav 05-Mar-2012 02:23" helped me and the following code in httpd.conf made Apache working with PHP:LoadModule php5_module "c:/php/php5apache2_2.dll"AddHandler application/x-httpd-php .phpPHPIniDir 'c:\php\'I hope I can save some hours of frustration to some beginners like me. 
-4
cfoesterle at yahoo dot com
8 years ago
 I do not have IIS installed on my server, only Apache. So I had to edit the PHP.ini file and comment out (add leading ";") to the following line "extension=php_iisfunc.dll" as I was getting "Faulting application httpd.exe, faulting module php_iisfunc.dll" errors when this line was active. I also added an additional  "AddType application/x-httpd-php .html" to my httpd.conf file so that inline php would work with files ending with an extension of ".html" on my server. 
-4
brokenarrow218 at rochester dot rr dot com
5 years ago
 man I had a heck of time.. I was really starting to think I was just too simple minded.. I run PHP on iis7 as well as apache.. my os is win7 pro.. my host uses php 5.2 sooooo..to run on apache 2.2 download nonthread safe version (my case VC6 x86 Non Thread Safe (2011-Jan-06 18:38:35)) and add this to the end of your apache httpd.conf file#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALLPHPIniDir "c:/php/"LoadModule php5_module "c:/php/php5apache2_2.dll"AddHandler application/x-httpd-php .php<FilesMatch \.php\$>      SetHandler application/x-httpd-php </FilesMatch>#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALLfired right up.. `