Run PHP as an Apache Module - no friends required
December 26th, 2006 at 5:53 pm (PHP Articles, Apache Articles)
This simple extract shows how to run PHP as an Apache module on windows with just 4 lines of code. PHP configuration will be covered in another article. This does not require XAMPP or WAMP and I feel gives you a bit more control over the installation.
- Windows 2000 or XP
- Administrator access on said Operating System
- Apache 2.0x
- PHP, any version (4x +) but not the installer package
Steps:
- Download Apache web server for windows (2.0.59 recommended)
- Follow the default installation steps
- Download the PHP binaries for Windows
- Extract all the files into a folder of your choice
Once these tasks have been completed you should have Apache running as a service and all files will be located in X:\Program Files\Apache Group\Apache2 - X being your default hard drive.
You can really extract PHP to any location you wish, but in this example I have extracted php-5.2.0-Win32 to the following directory: X:\Program Files\Apache Group\php\php-5.2.0-Win32.
Next step is to open up your httpd.conf file in a text editor, wordpad or notepad, and add a few lines. The file, from the default installation is found in the X:\Program Files\Apache Group\Apache2\conf folder.
Do a search from “LoadModule” and you will see a list of modules that Apache tries to initiate when starting up. At the foot of this section, add the following 4 derivatives - each on a separate line: LoadModule; PHPIniDir; AddType; second AddType.
LoadModule php5_module "X:/Program Files/Apache Group/php/php-5.2.0-Win32/php5apache2.dll"
PHPIniDir "X:/Program Files/Apache Group/php/php-5.2.0-Win32"
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
That’s it. Left-click the Apache monitor icon that should be in your task-bar and press restart. You can create a php page to test if the installation has worked. Save the following as info.php in your X:\Program Files\Apache Group\Apache2\htdocs folder assuming you haven’t modified your document root.
<?php
phpinfo();
Open up http://localhost/info.php in your favorite web browser. You should now see your PHP information nicely displayed on screen. You will notice some irregularities on the page, but that will be covered in the next article.
Source: http://www.skiffie.com/code/server/php-as-apache-module.










Tina said,
December 26, 2006 at 9:54 pm
Hi
thanks for such informative articles i found it during search. however i was wondering if there is any software / installer that can install php 5 with mysql and apache on linux and if apache is already installed then change the http.conf file to tell apache to run php as module because i have to set up a new server from scratch and i dont want to install php, apache and mysql separately but if any installer is available please let me know.
thanks
jabba_29 said,
December 27, 2006 at 3:44 pm
See this article.
However, installing separately shouldn’t that difficult…
Articles Repository » Blog Archive » PHP Ini Tweaks said,
December 27, 2006 at 10:33 pm
[…] In my previous articles, I showed how to enable PHP as an Apache module without relying on anything other than the standard Apache installer and how to run 2 versions of PHP on Apache for Windows. […]
rakesh said,
December 28, 2006 at 6:06 pm
Tina
Try out Xampp, i think it will solve yours problem…
Ansar said,
December 30, 2006 at 1:14 pm
Hi Tina,
You can try for WAMP Server for Windows.
W -Windows
A-Apache
M-Mysql
P-PHP
You can try for LAMP Server for Linux.
L - Linux
A-Apache
M-Mysql
P-PHP
There are various version of above depending on your choice of PHP,Mysql,Apache version.
Ansar Ahmed
tina said,
December 30, 2006 at 1:28 pm
thanks jabba,rakesh and ansar.
I wonder if someone could post article on how to use php to connect with oracle with oci and ora functions.
thank you very much , this blog is gr8 so as the writers