|
How to setup Apache and PHP on Windows |
|
|
|
Written by Dan
|
|
Wednesday, 17 March 2004 13:25 |
|
In this tutorial, I will show you how to install the Apache webserver software, and the PHP scripting engine on a Windows machine.
Note: %SystemRoot% is usually c:\winnt for Windows NT/2000 and c:\windows for 95/98/Me/XP - Create a directory which will be your root directory. In this example, we will use c:\webroot. This will be the default directory when users go to your domain.
- Download the latest Apache 1.3 release from http://httpd.apache.org. PHP support for Apache 2.0 is still in its experimental stages, so we are going with version 1.3.
 - Download the latest stable version of PHP from http://www.php.net/downloads.php. Make sure you download the ZIP PACKAGE, DO NOT download the installer!
 - Run the Apache 1.3 installer. Make sure you select 'Run as a service' if you want Apache to start up automatically when your computer boots up. Consult the screenshots below if some of the installation prompts do not make sense.
 - Create the directory c:\php.
- Extract the contents of the PHP zip file to c:\php.
- Copy c:\php\php4ts.dll to your %SystemRoot%\System32 directory.
- Copy c:\php\php.ini-recommended to %SystemRoot%\php.ini.
- Open %SystemRoot%\php.ini with a text editor.
- Look for extension_dir = "./" and change it to extension_dir = "c:\php\extensions".
- By default, you do not need to load any other extensions, but if you eventually want to start generating graphics, I suggest you uncomment ;extension=php_gd2.dll by removing the semicolon.
- Start > Programs > Apache HTTP Server > Configure Apache HTTP Server > Edit the Apache httpd.conf Configuration File. This should open your default text editor, usually notepad.
 - Look for the block of data where you see many LoadModule statements, and add LoadModule php4_module c:/php/sapi/php4apache.dll.
 - Find the block of data where you see many AddModule statements, and add AddModule mod_php4.c.
 - Search for AddType application/x-tar.tgz and add AddType application/x-httpd-php.php on the following line.
 - Look for DocumentRoot, it is probably set to DocumentRoot "C:/Program Files/Apache Group/Apache/htdocs", change it to c:\webroot or whatever directory you created in step 1.
- Look for DirectoryIndex index.html and add index.php to the end of the line. It should say DirectoryIndex index.html index.php.
- Restart the Apache service by going to Start > Programs > Apache HTTP Server > Control Apache > Restart.
- Test your setup by creating a file named index.php in c:\webroot, name it index.php, and add the following line with notepad:
<? phpinfo(); ?> - Go to http://localhost and you should see a page with information about your PHP configuration.

Forum Thread |
|
Last Updated on Tuesday, 07 April 2009 13:51 |