To install Apache with PHP 5 on Windows go through below steps. In case your PHP and Apache versions are different then please do accordingly.
- Please download Apache server from www.apache.org/dist/httpd/binaries/win32. You would like the current stable release version in the no_src.msi extension. After downloading run the installer file to install Apache; C:Program Files is a default location or change this to as desired. The installer gives you option as if you want to run Apache as a service or from the command line. It is recommended not to install Apache as a service, as this may cause problems with startup.
- Extract the PHP binary archive using your unzip utility (Winzip, Winrar or other); C:PHP is a common location.
- Copy and paste a few .dll files from your PHP directory to your system directory (usually C:Windows). You need php5ts.dll in any case. You may also need to copy the file according to your Web server module – C:PHPSapiphp5apache.dll. to your Apache modules directory. You may need other dlls as per need from the dlls subfolder. However start with the two mentioned above.
- Copy either php.ini-dist or php.ini-recommended (preferably later) to Windows directory (C:Winnt or C:Winnt40), and rename it php.ini. Open this file in a text editor . Edit this file to get configuration directives; We highly recommend new users set error reporting to E_ALL on their development. For now, the most important thing is the doc_root directive under the Paths and Directories section. Make sure this matches your IIS Inetpub folder (or wherever you plan to serve out of).
- Specify in your Apache server wherever you want to provide files from and extension(s) as well you want to identify PHP files (.php is the standard, while you can use .html, .phtml, or others you may need). Go to your HTTP configuration files (C:Program FilesApache GroupApacheconf or whatever your path is), and open httpd.conf with a text editor. Look for the word Document Root (which should appear twice) and change both paths to the directory you want to serve files out of. (The default is C:Program FilesApache GroupApachehtdocs.). Add at least one PHP extension directive as shown in the first line of the following code:
LoadModule php5_module modules/php5apache.dll
AddType application/x-httpd-php .php .phtml
You may also need to add the following line:
Restart WWW service.
Go to the Start menu -> Settings -> Control Panel -> Services.
In opened window scroll down the list to IIS Admin Service. Select it and click Stop. After it stops, select World Wide Web Publishing Service and click Start. Stopping and restarting the service from within Internet Service Manager will not suffice. Since this is Windows, you may also wish to reboot.
Now lets test if PHP is working or not.
For that open a text editor and type
<?php phpinfo(); ?>
Save this file in your Web server’s document root directory as “info.php”.
Open Web browser and type the file. You must always use an HTTP request (http://www.yourdomain.com/info.php or http://localhost/info.php or http://ip-address/info.php) rather than a filename (/home/httpd/info.php) for the file to be parsed correctly.
You should see a table of information about your new PHP installation message. If this is then Congratulations!