Saturday, January 01, 2011

PHP & Apache HTTP Server - Installation

I heard & known that the PHP was very popular technology for rapid web development. Maybe it's good just to get my brain fresh with some technology alternative, so I decided to start the learning.

OK, first mission is to make PHP works with Apache HTTP server. As usual, since these are open source projects, a lot of information out there, but very hard to find all in one place, and usually the version might be outdated when we are looking for it.

My environment is as follow:
1. Windows XP
2. Apache HTTP server v2.2: Downloaded the httpd-2.2.17-win32-x86-openssl-0.9.8o.msi from here Apache: 2.2
3. PHP Version 5.3.4: Downloaded the php-5.3.4-Win32-VC6-x86.msi from here PHP for Windows
- Please note the installer that will work for Apache is VC6

Install the Apache HTTP server before PHP, then we can take advantage of the PHP installer that it will auto-configure the necessary details to make the Apache web server to serve PHP.

There are my local installed directory structures:
1. Apache: D:/Apps/Apache2.2, I will refer this as <apache_web_server>
2. PHP: D:/Apps/PHP, I will refer this as <php.directory>

To verify the PHP can be serve by Apache:
1. Go to <apache_web_server>/htdocs
- create a file name: phpinfo.php
- Put this line of code to the phpinfo.php file: <?php phpinfo(); ?>

2. Start the Apache web server

3. In browser, type this: http://localhost/phpinfo.php
- you should see a page as follow:
PHP loaded succesfully!


And this is the Apache httpd.conf for the section related to PHP. All lines are written by the PHP installer, exceptAddType application/x-httpd-php .php, I added it manually then it works:

------------------------------------------------------
#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
PHPIniDir "D:/Apps/PHP/"
LoadModule php5_module "D:/Apps/PHP/php5apache2_2.dll"
AddType application/x-httpd-php .php

#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
------------------------------------------------------

And here are some references I used to troubleshooting problem, good luck!
1. <php.directory>/install.txt
2. Setting up CakePHP with Apache

In fact, I think the 2nd reference is more useful for next blog.

No comments: