Machine specifications used in this task are:
1. Download the php windows installer, php-5.2.3-win32-installer.msi from php.net. Don’t forget to download the latest collection (PECL) php extensions for windows (PECL x.x.x Win32 binaries). We will also try to 'install’ PECL later. 2. Double click the php-5.2.3-win32-installer.msi file. The following dialog box will be launched.
3. Click Next of the following PHP setup wizard welcome page.
|
4. Accept the EULA, read it and click Next.
5. In the following dialog box, set your PHP installation folder. The given default path is shown below.
6. In our case we change toC:\PHP\. You can use the Browse button to browse the desired installation path. Click Next.
7. Select the web server type installed previously. In our case we use Apache 2.2.x Module and click Next.
8. Set the Apache configuration file (httpd.conf) directory. The default directory is given as shown in the following Figure.
9. However in this case, our Apache configuration file resides under the C:\Apache2\conf\. Change yours accordingly. Click OK.
10.Click Next.
11.In this step we do not select any Extensions and Extras. Only the Programs and Web Server Setup were selected. You can check the disk usage by clicking the Disk Usage button. Click Next.
12.The wizard is ready to install PHP. You can change any settings previously set by using the Back. In our case, just click Next.
13.The installation begins.
14.The installation was completed. Click the Finish button.
![]() |
15.You may want to test the PHP engine for installation verification. If the path for the PHP already set in the environment variable, you can run the php command relatively from any path including the root as shown below.
16.Otherwise you need to run the php command from the PHP installed folder by going to your PHP installed folder and for example, try the following command (your path may be different, change accordingly)
C:\Program Files\PHP>php -v
17.The previous Figure confirms that you PHP installation is OK and working at this moment. Otherwise, there are error(s) displayed mentioning the related error(s) which most of the time is very useful enough for user to find solutions by copying the error message(s) and finding it in the Google search.
18.The PHP path normally added to the system variable, however to make it active, you may need to restart your machine. The following Figures show the PHP path in the System variable for Windows 2003 Server.
1. Select the Advanced tab and click the Environment Variables button.
2. In the System Variables you should see the PHP path as highlighted in the following Figure.
3. You can add the PHP paths to the system variable manually by using the Edit button. The following command shows the help command and options in Windows console.
C:\Program Files\PHP>php -h
4. If you wan to see the PHP current setting, try the following command,
C:\Program Files\PHP>php -i
--------------------------------------------------------------------------------------------------------------------------------------
5. After installing PHP and a web server on Windows, you will probably want to install some extensions for added functionality. You can choose which extensions you would like to load when PHP starts by modifying your php.ini. You can also load a module dynamically in your script using dl() function. The DLLs for PHP extensions are prefixed with php_ under the PHP\ext folder.
Many extensions are built into the Windows version of PHP. This means additional DLL files, and the extension directive, are not used to load these extensions. To change this setting to reflect your setup of PHP edit your php.ini file:
extension_dir = C:\php\extensions.
Example #1 Enable Bzip2 extension for PHP-Windows
// change the following line from ...
;extension=php_bz2.dll
// ... to
extension=php_bz2.dll
Installing the PHP (extensions), PECL for Win32 Manually
1. The PECL collection can be downloaded fromPHP download page (pecl-x.x.x-Win32). Extract thepecl-5.2.6-Win32.zip files. The extracted files and folders are shown below.
2. To your surprising there is no installation as normal setup. It is just a copy and paste method. So, copy and paste all the extracted content to the PHP\ext folder. If there is an overwrite message, just click OK to overwrite the existing files/folders. You can see that all the extension module available under the ext folder.
3. For the PEAR installation, please refer to PHP and Windows XP Pro installation.
4. The PHP configuration file is php.ini located at the root of the PHP installation folder.
1. At the beginning just let the default settings of the php.ini. When you need extra modules to be loaded in order to enable certain features in your web application, and then enable them one by one. Don’t let unusable module(s) running or loaded.
Please read the information provided in the php.ini file when you want to do the editing. If you don’t know what you are supposed to edit, please refer to thedocumentation, to get the basic information (http://php.net/manual/en/ini.core.php).
Testing the PHP engine
1. Create an .html file and type the following code to extract all the php settings information used for your system and at the same time making sure the PHP engine is working. In this case we name the file test.html. Don’t forget to save it.
<HTML>
<BODY>
<?php phpinfo();?>
</BODY>
</HTML>
Or any_filename.php as you want and put the following php code.
<?php phpinfo();?>
2. Put the test.html or any_filename.php file that you name it, under the default Apache web file folder, htdocs (e.g. default installation on Windows:C:\Program Files\Apache Software Foundation\Apache2.2\htdocs)
By assuming that your Apache web server was correctly installed and running, go to your browser and type the following address, http://localhost/any_filename.php or http://localhost/test.html as created in the previous section and then press Enter. If your filename is not test.html or any_filename.php, change accordingly. You have to put the filename in full because by default web server will serve index.* file.
The following web page that contains all your PHP settings that should be expected if your php engine is working. God blesses you and me!!! For real production, please delete the file else every user can see your web server php settings!
3. If there is no output as shown in the previous Figure, or only the source code of the file shown, please restart Apache.
Make sure there is no error(s) message when you do this. Then re-try the previous URL again.
Known Issue
There are errors generated when we try to run PHP on HP machines. We found that the HP machines bundled the PHP parser with its Tools software. To resolve this issue, after PHP fresh installation you need to disable the HP's PHP parser. You can do this by renaming the DLL files that normally located under the HP Tools software folder. We rename two files that will launch the PHP parser. How-to install and configure PHP with extensions on IIS also can be found at Microsoft (PHP & IIS).