Apache 2.x (Microsoft Windows 用)

このセクションでは、Microsoft Windows 上の Apache 2.x で PHP をインストールする場合の説明とヒントを記しています。

注意:

まず始めに、 マニュアルインストールの手順 をお読みください。

» Apache ドキュメンテーション を参照し、Apache 2.x サーバーの基本を理解しておくことを強く推奨します。 また、以下の解説を読む前に、Apache 2.x に関する » Windows 固有の情報 についても参照するとよいでしょう。

最新の » Apache 2.x と、 対応するバージョンの PHP をダウンロードしてください。 マニュアルインストールの手順 を実施したら、引き続き以下のとおり PHP と Apache の設定を行ってください。

PHP を Windows 上の Apache 2.x で動かすには三通りの方法があります。 PHP をハンドラとして動かす方法、CGI として動かす方法、そして FastCGI で動かす方法です。

注意: Windows 上で Apache 設定ファイルにパスの値を追加する際、例えば c:\directory\file.ext に含まれるすべてのバックスラッシュは c:/directory/file.ext のように前向きスラッシュに変換する必要があります。 また、ディレクトリを表す際には最後にスラッシュをつけなければなりません。

Apache ハンドラとしてインストール

Apache 2.x 用の PHP モジュールを読み込むには、 以下の行を Apache 設定ファイル httpd.conf に追加しなければいけません:

例1 PHP を Apache 2.x ハンドラとして使う設定

# PHP 8.0.0 より前のバージョンでは、モジュール名は 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"

注意: 上の例の C:/php/ は実際のパスにあわせて修正してください。 LoadModule ディレクティブで PHP 7 の場合 php7apache2_4.dll を、 PHP 8 の場合 php8apache2_4.dll を使うことに注意し、 指定したファイルが実際にその場所にあるかどうかを忘れずに確認しましょう。

CGI として PHP を実行させる

» Apache CGI ドキュメント を読み、Apache 上の CGI について理解しておきましょう。

PHP を CGI として実行するには、ScriptAlias ディレクティブで CGI ディレクトリとして指定した場所に php-cgi ファイルを置かなければなりません。

さらに、PHP ファイルに #! の行を追加して PHP バイナリの場所を指定しなければなりません:

例2 PHP を Apache 2.x 上で CGI として動かす例

#!C:/php/php.exe
<?php
  phpinfo();
?>

警告

CGI モードで公開したサーバーは、いくつかの脆弱性の標的となる可能性があります。 これらの攻撃からサーバーを守る方法については、 CGI セキュリティ のセクションを参照してください。

PHP を FastCGI で実行する

PHP を FastCGI で動かすことは、 CGI として動かすのにくらべると多くの利点があります。 設定方法は単純明快です。

まず mod_fcgid を » https://www.apachelounge.com から取得します。Win32 用のバイナリがこのサイトからダウンロードできます。 そして、説明に従ってモジュールをインストールしましょう。

次にウェブサーバーを以下のように設定します。 パスの部分は適切に変更し、インストールするシステム上の環境にあわせましょう:

例3 PHP を FastCGI として動かす Apache の設定

LoadModule fcgid_module modules/mod_fcgid.so
# Where is your php.ini file?
FcgidInitialEnv PHPRC        "c:/php"
<FilesMatch \.php$>
    SetHandler fcgid-script
</FilesMatch>
FcgidWrapper "c:/php/php-cgi.exe" .php
これで、拡張子 .php のファイルは PHP FastCGI ラッパーが処理するようになります。

add a note add a note

User Contributed Notes 33 notes

up
40
wolfeh1994 at yahoo dot com
10 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.
up
15
ohcc at 163 dot com
9 years 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" .php

3. 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/2003

junction 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" .php

Don't forget to change the paths above to your working paths.
up
2
a user
8 years 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"
up
5
compleatguru at gmail dot com
11 years ago
I am using Windows 8 x64, running Apache 2.2 and php 5.4.20

I 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 laptop
Go to Control Panel\System and Security\System\Advanced System Settings\Environment Variables

Add New System Variable
Name: PHPRC
Value: C:\php-5.4.20

Hope it relieve those who keep having empty string for Loaded Configuration File under phpinfo();
up
2
BuggedApache
9 years 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
###############################################
up
3
Cameron
13 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 -m
and see that the command line version loads all the modules you asked for.

in php.ini, enable
display_errors = On
and
display_startup_errors = On
The 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.
up
1
Z Carlos at Fortaleza
12 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.
up
2
tmnuwan12 at yahoo dot com
10 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.msi
httpd-2.2.25-win32-x86-openssl-0.9.8y.msi

Make 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.
up
10
a solution for simpletons like me
12 years ago
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 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 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  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 Next
5  Click I accept the terms in the license agreement
6  Click Next
7  Click 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 Click Next
12 Click Next
13 Click Next
14 Click Install and wait
15 Cick Yes to allow the program to make changes
16 Click 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 message It works! should appear.

Getting 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  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 Next
5  Click I accept the terms in the License Agreement
6  Click Next
7  Click Next
8  Click Apache 2.2.x Module
9  Click Next
10 Click Browse
11 Double click Apache Software Foundation
12 Double click Apache 2.2
13 Double click conf
14 Click OK
15 Click Next
16 Click Next
17 Click Install and wait
18 Cick Yes to allow the program to make changes
19 Click Finish

Testing PHP with Apache

1  Open Notepad
2  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.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 Version ... should appear

DONE
up
5
bdav
12 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
up
5
farinspace
14 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" .php

Remember to add the following to the default <Directory "C:/apache/htdocs"> block (or virtual host blocks):

    Options ExecCGI
up
1
Amaroq
11 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.
up
1
bradley dot henke at colorado dot edu
13 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!
up
1
Steve
14 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.
up
2
Nick
14 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.dll

This stopped Apache from crashing and started successfully.
up
1
kynetikmedia at gmail dot com
10 years 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 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) - 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 Next
5  Click I accept the terms in the license agreement
6  Click Next
7  Click 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 Click Next
12 Click Next
13 Click Next
14 Click Install and wait
15 Cick Yes to allow the program to make changes
16 Click 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 message It works! should appear.

Getting 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  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 Next
5  Click I accept the terms in the License Agreement
6  Click Next
7  Click Next
8  Click Apache 2.2.x Module
9  Click Next
10 Click Browse
11 Double click Apache Software Foundation
12 Double click Apache 2.2
13 Double click conf
14 Click OK
15 Click Next
16 Click Next
17 Click Install and wait
18 Cick Yes to allow the program to make changes
19 Click Finish

Testing PHP with Apache

1  Open Notepad
2  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.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 Version ... should appear

DONE
up
1
packard_bell_nec at hotmail dot com
17 years ago
If you install PHP as an Apache CGI binary, you can add:
AddHandler cgi-script .php
into Apache httpd.conf, and add shebang line to every PHP scripts like:
#!php
<?php
phpinfo
();
?>
. 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-Strict
into 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.
up
1
nicolas dot grasset at gmail dot com
15 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:\apache
msiexec /i php-5.2.10-win32-installer.msi /qn APACHEDIR=c:\apache INSTALLDIR=c:\php ADDLOCAL=ext_php_mssql,apache22
net stop "Apache2.2"
net start "Apache2.2"
up
1
Bechesa at gmail dot com
12 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 UNINSTALL
PHPIniDir '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 UNINSTALL

OS: windows 2008
webserver: apache2.2
up
1
mjm at alum dot mit dot edu
16 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!
up
1
Anonymous
9 years 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>
up
0
ohcc at 163 dot com
9 years 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" .php

3. 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" .php

Don't forget to change the paths above to your working paths.
up
0
Guillermo Tallano
11 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-safe

This is my conf:
LoadModule php5_module "c:/php5/php5apache2_2.dll"
AddHandler application/x-httpd-php .php
#configure the path to php.ini
PHPIniDir 'C:\php5\'

Good luck!
up
0
Maw
11 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 .php
Action 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.
up
0
Cooldude
13 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 path

that fixed it
up
0
lebovskiy at ua dot fm
14 years ago
I install httpd-2.2.17-win32-x86-openssl-0.9.8o.msi and after
php-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 don`t starts. If remove PHPIniDir line Apache  starts ok, but C:/PHP/php.ini don`t loaded. So you can`t 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.
up
0
halmai
14 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.
up
0
Michael
14 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
up
0
Anonymous
14 years ago
If anybody here encounters an error regarding PHPIniDir, change PHPIniDir "C:/php/" to PHPIniDir "C:\php\".
up
0
Anonymous
15 years ago
i followed henke37's way to for the httpd.conf

I added all this at the very end of httpd.conf

# For PHP 5
#load the php main library to avoid dll hell
Loadfile "C:\php-5.2.8-Win32\php5ts.dll"

#load the sapi so that apache can use php
LoadModule 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 is
PHPIniDir "C:\php-5.2.8-Win32"

#Hook the php file extensions
AddHandler application/x-httpd-php .php
AddHandler 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 anything
So use this to test
<?php
phpinfo
();
?>
NOT
<? phpinfo(); ?> short open tags

added my php directory to the PATH system variable and i start apache manually not as a service

It works for me hope it helps you!
up
-2
alx dot suvorov at gmail dot com
6 years ago
For PHP 7 configuration just add these lines to the end of httpd.conf file (of Apache):

PHPIniDir "/alex/apps/php-7.2.3/"
LoadModule php7_module "C:/alex/apps/php-7.2.3/php7apache2_4.dll"
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

Here "/alex/apps/php-7.2.3/" is PHP path.

Then:
1. Rename php.ini-development or php.ini-production to php.ini
2. Uncomment / set extension_dir parameter in php.ini
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "ext"

You are set. Just re/start Apache server (httpd -k restart).
up
-1
gmatwy at gmail dot com
8 years ago
version
httpd-2.4.23-win32-VC14.zip
php-5.6.26-ts-Win32-VC11-x86.zip

install path c:/wamp/
php path c:/wamp/php
apache path c:/wamp/Apache24
used as Apache handler

modify as below

#below for apache
#modify c:/ to c:/wamp/
#modify ServerName to localhost:80 and remove#
#DirectoryIndex insert index.php

#below for php
#rename file php.ini-production to php.ini
LoadModule php5_module "C:/wamp/php/php5apache2_4.dll"
PHPIniDir "C:/wamp/php/"

AddType application/x-httpd-php .php
AddType application/x-httpd-php .html

AddHandler application/x-httpd-php .php

And things goes well !
up
-4
jangirashok at gmail dot com
10 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...
To Top