Manual Installation Steps

This section contains instructions for manually installing and configuring
PHP on Microsoft Windows.

Selecting and downloading the PHP distribution package

Download the PHP zip binary distribution from
» PHP for Windows: Binaries and Sources.
There are several different versions of the zip package - choose the version that is suitable for
the web server being used:

php-cgi.exe - CGI executable that can be used when running PHP on IIS via CGI or FastCGI.

php-win.exe - the PHP executable for executing PHP scripts without using a command line window
(for example PHP applications that use Windows GUI).

php.exe - the PHP executable for executing PHP scripts within a command line interface (CLI).

php5apache2_2.dll - Apache 2.2.X module.

php5apache2_2_filter.dll - Apache 2.2.X filter.

Changing the php.ini file

After the php package content has been extracted, copy the php.ini-production into php.ini
in the same folder. If necessary, it is also possible to place the php.ini into any other location of your choice
but that will require additional configuration steps as described in PHP Configuration.

The php.ini file tells PHP how to configure itself, and how to work with the
environment that it runs in. Here are a number of settings for the php.ini file
that help PHP work better with Windows. Some of these are optional. There are
many other directives that may be relevant to your environment - refer to the
list of php.ini directives for more information.

Required directives:

extension_dir = <path to extension directory> - The extension_dir needs
to point to the directory where PHP extensions files are stored. The path can be absolute
(i.e. "C:\PHP\ext") or relative (i.e. ".\ext"). Extensions that are listed lower in the php.ini file need
to be located in the extension_dir.

extension = xxxxx.dll - For each extension you wish to enable, you need a corresponding "extension="
directive that tells PHP which extensions in the extension_dir to load at startup time.

log_errors = On - PHP has an error logging facility that can be used to send errors to a file,
or to a service (i.e. syslog) and works in conjunction with the error_log directive below. When running under IIS,
the log_errors should be enabled, with a valid error_log.

error_log = <path to the error log file> - The error_log needs to specify the absolute,
or relative path to the file where PHP errors should be logged. This file needs to be writable for the web server.
The most common places for this file are in various TEMP directories, for example "C:\inetpub\temp\php-errors.log".

cgi.force_redirect = 0 - This directive is required for running under IIS.
It is a directory security facility required by many other web servers. However, enabling it under IIS will
cause the PHP engine to fail on Windows.

fastcgi.impersonate = 1 - FastCGI under IIS supports the ability to impersonate
security tokens of the calling client. This allows IIS to define the security context that the request runs under.

fastcgi.logging = 0 - FastCGI logging should be disabled on IIS. If it is left enabled,
then any messages of any class are treated by FastCGI as error conditions which will cause IIS to generate an HTTP 500 exception.

Optional directives

max_execution_time = ## - This directive tells PHP the maximum amount of time that it can spend
executing any given script. The default for this is 30 seconds. Increase the value of this directive if PHP application take long time to execute.

memory_limit = ###M - The amount of memory available for the PHP process, in Megabytes.
The default is 128, which is fine for most PHP applications. Some of the more complex ones might need more.

display_errors = Off - This directive tells PHP whether to include any error messages in the
stream that it returns to the Web server. If this is set to "On", then PHP will send whichever classes of errors
that you define with the error_reporting directive back to web server as part of the error stream.
For security reasons it is recommended to set it to "Off" on production servers in order not to reveal any
security sensitive information that is often included in the error messages.

open_basedir = <paths to directories, separated by semicolon>, e.g.
openbasedir="C:\inetpub\wwwroot;C:\inetpub\temp". This directive specified the directory paths where PHP
is allowed to perform file system operations. Any file operation outside of the specified paths will result in an error.
This directive is especially useful for locking down the PHP installation in shared hosting environments to prevent
PHP scripts from accessing any files outside of the web site's root directory.

upload_max_filesize = ###M and post_max_size = ###M -
The maximum allowed size of an uploaded file and post data respectively. The values of these directives should be
increased if PHP applications need to perform large uploads, such as for example photos or video files.

PHP is now setup on your system. The next step is to choose a web
server, and enable it to run PHP. Choose a web server from the table of
contents.

Installed apache 2.2Then installed latest PHPI have only php5apache2_4.dll What can I do to make it work properly? Do I need to write LoadModule php5_module "C:/Program Files (x86)/Php/php5apache2_4.dll" in httpd.conf?Or I have to find php5apache2_2.dll somewhere?Can someone post instructions please

I got the 'Fatal Error: call to unindentified function mysql_connect()' and resolved it after many hours of troubleshooting. The problem has to do with the libmysql.dll file residing in multiple directories. It SHOULD only be in the php directory. So, erase the copy in mysql bin and the apache bin and restart apache. I hope this helps someone. if this doesn't help check out forums.mysql.com and search "Call to undefined function mysql_connect". (i got the solution to this problem from here)

In windows XP, the php.ini file must be in c:\windows directory. Or else most of the functions will work except mysql functions. The very first mysql command mysql_connect will fail with the following message "Call to unsupported or undefined function mysql_connect(); "

In the above, "the web server's directory" means the directory where the server executable lives, for example for the Apache installation on my XP box this is "\program files\apache group\apache2\bin" and NOT just "\program files\apache group\apache2".

But it's probably best to tell your web server where PHP's ini file is stored, for example via PHPIniDir for Apache's http.conf.

Okay, I'm a total newbie to this, so my findings may be wrong, but this is what I found out.

The manual says "do not have spaces in the path (like C:\Program Files\PHP) as some web servers will crash if you do". Indeed, when using this with PHP5 on WinXP, I got the error message "The specified module could not be found."However, the problem seems not to lie in the SPACE in the pathname, but in the QUOTES that Windows adds when a space is in the pathname! This is what I found:

In the Note Titled "Windows Server 2003 (x64 bits) + IIS 6.0" in step 1 when adding your new .php extension, it will not work unless after you click on the "Home Directory" you make sure that your "Execute permissions:" are set to "Scripts Only".

By default, on my machine, the permissions were set to "None" not allowing php to run.

Also, for more security it might be wise to Add the new extension just to your default site instead of the whole Web Sites folder in IIS. This would only apply if you were hosting multiple sites and had a site you didn't want scripts to run on.

Followed the instructions carefully but still got a 500 error trying to open the classig phpinfo page. After a lot of searching I discovered that everything worked fine after changing the php.ini directive fastcgi.logging from 0 to 1, contrary to what the directions said. I wonder if it was a typo on the instructions or if something changed after a few versions.

After having the same problem as specifed below with "No input file specified". I changed the doc_root as mentioned.

This is fine if all php scripts are going to be run from the c:\inetpub\wwwroot directory. To enable it for multiple websites where the root directories are all different simply leave the doc_root attribute in the php.ini file blank.

This is for the isapi version not cgi implementation. It also means you don't have to set IUSR or IWAM access to the PHP root directory.

Hi everyone, well i've been trying to configure, install, this setup i.e., Apache, php and mysql, well the prb wat i faced was that most of the installation instructions were quite outdated as they used quite old softwares... well these are the simple steps install and configure this entire setup, hope it will help u....(this is for windows)Software versions:Apache - 2.2.11Mysql - 5.1.30-communityPhp - PHP Version 5.2.8

You are correct. I just had the same issue; I was following the PHP installation instructions and some very helpful WIMP instructions.

I was trying to keep things tidy by putting my PHP directory in C:\Program Files\PHP. I set the PATH variable, ISAPI filter config and extension in Application Configuration, but was getting the "Specified module could not be found" error.

Changed the PHP directory to C:\PHP and reconfigured everything, did an iisreset, and it started working immediately.

First i need to use full tag to make it your php script works and second the IIS didn't want to load the extension in the ext folder. I cheked the configuration a couple of thousand of time and everything seen to be ok.

I fixed up given read access in the "ext" folder to de "IUSER/PCNAME" user or to everyone/PCNAME user to the same folder. Just in case i did the same in the rest of the folder inside the php folder.

If you are running websites within an Application Pool (which is now the default for IIS6 under 2K3) you need to make sure that your PHP directory (e.g. C:\PHP) has read permissions for the user assigned to the Application Pool.

1. In the IIS snap-in, choose Application Pools2. Right-click on DefaultAppPool (or other, if you have one defined) and choose Properties3. Click the Identity tab4. Make a note of the user name set as the security account for this application pool (e.g. "Network Service")5. Browse to your PHP directory and grant that user read permissions for the entire directory.

In my case, I had to add permissions for the user "NETWORK SERVICE" to get PHP scripts to work. Otherwise I received 401/403 authorization errors when trying to load them in a remote browser.

Note also that first tried adding IUSR permissions to the PHP directory, but that had no effect.

The part about adding the Path to the System Environment Variables is different on Vista. On XP you DO need to reboot for the Path change to be picked-up correctly. On Vista however you do not, the change is instant.

Just a quick note that the visual C requirements for PHP under a windows 64 bit environment aren't for the x64 version, but for the x86 version. Tried installing PHP 5.4 on Server 2008 R2 after installing the x64 version and got:

The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail.

Which is basically saying that it can't find the correct C++ package, so after installing the x86 version this error went away. YMMV.

- The browser can't find your php code like localhost/dir/dir_code.php from any virtual directory (404 error)- You are sure the code existsYou may rename it with a .html extension and check if it displays- Process of your php code like localhost/root_code.php is ok from the root directory

It may come from the doc_root directive in php.ini whitch should be set to blank :

To install php+apache+win32+mysql with PHP as an Apache module consider the following hints :

- download the 'VC6 x86 Thread Safe' zip file from http://windows.php.net/download/ . Couldn't make the Non Thread Safe version to work as a loadable module from Apache.

- if you set extension=php_mysql.dll and still have problems, copy the file libmysql.dll (shipped with php's zip) to your WINDOWS\System32\ directory. The apache-mysql module fails trying to find this library.

You are absolutly correct. I found this out while trying to install PHP4 with Apache2 on XPPro. Here are 3 general guidelines that I have found to be correct:

- Path may not have spaces. Change C:\Program Files to C:\Progra~1 If you don't understand this, go to start-->run-->command (not cmd). Type cd\ and hit enter. Then type dir. You should see all your directory names there.

It should be noted that even before starting PHP installation, you should research extension requirements for those you plan to use. For a list of common extensions and dll requirements and prerequisites, see the table on this php.net page: http://www.php.net/manual/en/install.windows.extensions.php

Commonly used extensions are listed in alphabetical order in the default php.ini file that comes with the windows packages. Some extensions must be loaded before others or else the server may crash with an unhelpful, seemingly unrelated dll error. For example, in your php.ini file, you must manually place 'extension=php_exif.dll' -after- 'extension=php_mbstring.dll' if you wish to use the exif and mbstring extensions or else your server may crash. The msi installer may or may not automatically have correct load order, but for manual installs, it does not.

Do not attempt to uncomment extension lines in the default php.ini file that comes packaged with php install or zip packages without knowing what you're doing. Before loading extensions in this manner, be sure you have met the prerequisites for load order and have ready any missing dll files listed in the above link.

I did a clean install of Apache 2.2 and PHP 5.2.6 due to conflicts with the old httpd.conf file I had and ran into the "Call to undefined function mysql_connect()" error when trying to run a script that connects to MySQL.

To resolve it I had to copy libmysql.dll from my PHP installation directory to the "bin" folder of my Apache install directory.

I checked the forums.mysql.com as someone else suggested which lead me to this site with the missing step I needed (http://www.artfulsoftware.com/php_mysql_win.html). I spent a good part of the afternoon trying set this up. Hopefully it helps someone out.

For me atleast, the steps for installing php 5 on IIS 6 on windows 2003 seemed to get buried with the other setups. I found it difficult to quickly look through and make sure I covered every step. So I created a clean step by step tutorial with screenshots:http://psdforums.com/article.php?a=9

You have upgraded to PHP5 from PHP4. phpinfo- works fine. You cannot however communicate with mysql (for example) through phpMyAdmin as it throws up an error stating it cannot load the mysqli extension and/or you get the 'bad handshake' warning.

Remember to enter FULL PATH in the extension_dir parameter in php.ini ! Using only "./ext/" or any relative path will have your PHP failing to load extensions when called by Apache. That's quite tricky 'cause extensions are working when PHP is used through command line ...

* Expand the local computer in the left pane * Right-click on "Web Sites" in the left pane, then click "Properties" in the menu that pops up * Flip top the "Home Directory" tab * Click "Configuration" * Flip to the "Mappings" tab * Click "Add..." * Enter the full path to php5isapi.dll in the "Executable" textbox (Browse... to find it more easily if you need to) * Enter ".php" in the "Extension" textbox * Select radial button "Limit to", enter "GET,POST,HEAD" * Click "OK" all the way out

2. Verify php5isapi.dll is allowed

You must verify that the versions of php5isapi.dll that you want to use are allowed.

2.1. In Internet Information Services (IIS) Manager, in the left-hand column, click the Web Services Extensions node and verify php5isapi.dll is allowed and all other Web Service Extensions are prohibited. 2.2. If the version of php5isapi.dll that you want to use does not appear in the list, follow the instructions to enable it and then repeat this procedure:

Go into IISBelow all of the websites is a folder: Web Service ExtensionsIn blue, to the lower left, is a choice: Add A New Web Service ExtensionAdd PHP/PHP5ISAPI.dllChoose To ALLOW it.

2.3 If the version of php5isapi.dll you want to use appears on the list but is not allowed, right click the version of php5isapi.dll you want to allow and click Allow.

3.1. If you are installing IIS on x64-based editions of Windows Server 2003 or Windows Server 2003 R2, IIS must be configured to run in 32 bit emulation mode. Perform the following procedure on each front-end Web server running an x64-based edition of Windows Server 2003.Configure Internet Information Services (IIS) for 32-bit mode

1. Click Start, and then click Run. 2. In the Open box, type cmd, and then click OK. 3. In the command prompt window, navigate to the %drive%:\Inetpub\Adminscripts folder, where %drive% is the drive in which Windows Server 2003 is installed. 4. In the Adminscripts folder, type the following command:

Note The Run WWW service in IIS 5.0 isolation mode check box is only selected if you have upgraded to IIS 6.0 on Windows Server 2003 from IIS 5.0 on Windows 2000. New installations of IIS 6.0 use IIS 6.0 worker process isolation mode by default.

Your PHP.INI file is not required to be in the C:\WINDOWS folder in XP. The trick is to make sure that the PHP.INI can be found. If you fail to reboot after adding the PHP folder to the path and creating the PHPRC environment variable, the file will likely not be found. If you can't reboot, then try creating the registry entries as described in the following document:

When you execute "phpinfo();" pay special attention to the data returned in "Loaded Configuration File". If it does not show a path and a the PHP.INI file name, the file is not being loaded. The path of C:\WINDOWS in the Configuration File Path section is the default location where PHP looks for the INI file and does not mean that the file must be located there; in fact, the following document suggest that you leave the configuration file in the C:\PHP folder: