Friday, April 27, 2007

PHP, The Eternal Struggle

I've always wanted to set up a dynamic site but whenever I tried to create a local server for testing I would fall flat on my face. For the last few weeks after browsing through the thousands of pages of the manuals for Apache 2.2, PHP, and MySQL 5.0 I tried to installing PHP to run on Apache.

The first snag I ran into (and I should have seen it at the beginning) was my attempt to install PHP 5.1 with Apache 2.2.

It turns out that PHP 5.1 does not have "php5apache2_2.dll" which is needed to run Apache as a module for enhanced security. After downloading PHP 5.2 and adding the lines
LoadModule php5_module "c:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/php"
I was finally able to start the Apache server without an error message. (c:/php was my choice of where I installed php. It might be different depending on where you unzipped your php file)

So I entered localhost and immediately became of forgetting a step. The Apache configuration file (httpd.conf) was still pointing at "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs" even though I had my root folder set up on the desktop. So I went into the file and found "DocumentRoot" where I promptly entered my desktop directory.

So I go to type in localhost and get the error message: 403 Forbidden You don't have permission to access / on this server. *frowns impatiently*

I go back into the httpd.conf file and scour through it line by line. Soon after DocumentRoot I encounter the problem:
# This should be changed to whatever you set DocumentRoot to.
#

About 26 lines after DocumentRoot it told me to change another line. So I pointed the directory to my desktop directory where all my files were located taking great care to use forward slashes (/) instead of backward slashes (\) and...

Htm files load perfectly but my test.php file comes up blank!

No comments: