Cannot load .php pages

Greetings everyone,

I recently began to get through my Database Driven Website book and got to the point where a small bit of code was to be added just to test the web server that has been made locally.

I setup the web server on my own computer and checked the Apache server monitor, it showed that i had PHP loaded successfully on the server. I then continued to add the code from the book:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<title>Today&rsquo;s Date</title>
		<meta http-equiv="content-type"
				content="text/html; charset=utf-8"/>
	</head>
	<body>
		<p>Today&rsquo;s date (according to this web server) is
			<?php

			echo date('l, F dS Y.');

			?>
		</p>
	</body>
</html>

After i had created this file, by writing the code out in Notepad and then ensuring the format was set to .php and set in the Apache “htdocs” directory, i proceeded to go to http://localhost/today.php.

This turned out to not work, instead of appearing and having broken code or just saying “cannot load page”, the browser continues to load the page forever without changing status at all and without any error messages.

Note: I am able to go to http://localhost/ without any errors, the default text “It works!” appears fine.

Well i guess i’ll bear that in mind, thanks. I’ll see if anybody has any solutions, but if not i’ll just load that WAMP as I had planned to, but the book said it’s better to load manually to see how everything works. Now i know how most of it works, shoulden’t hurt really.

I recomend using XAMPP or WAMP instead of setting up the server yourself as it works straight away without any problems.

The code works for me localy, from memory there was a similar post in the last couple of days with some suggestions.

I have gone through the instructions you layed out and rechecked the ones found in my book(Build Your Own Database Driven Web Site Using PHP & MySQL by Kevin Yank, 4th Edition) but i am getting a file download now when i launch the http://localhost. It calls it an “application/x” file.

Well apart from one php document, i am able to run the server fine now with WampServer, so i think the problem is resolved for the time being. Thanks for the assistance.

Are you starting the server ?

On XAMPP I get a control panel and I need to start Apache and Mysql as I need it.

That is what i did after i wrote that last response, thanks for the help so far though.

I am indeed running on Windows. Now the server is running again and i am able to load the index page, the PHP page that i had created to show the date and time prompts for download instead of going to the page itself.

Are you sure you configured those three lines in your apache configuration file?
‘httpd.conf’ inside C:\Program Files\Apache Software Foundation\Apache2.2\conf.


LoadModule php5_module "c:/php/php5apache2_2.dll"

Hope you changed the path to php5apache2_2.dll.


AddType application/x-httpd-php .php

This is really needed to recognize the PHP file by apache.

And finally you need to set the php’s ini file’s location:


PHPIniDir "C:/php"

That’s it.

I presume that you are in Windows.

Hi Bluecewe,

Welcome to the sitepoint forums!

I am not sure which book you are reading now and following the codes. As suggested b y Rubble, if you are not about to learn how to install Apache, PHP and MySQL independently (means you are going to work directly on a project) then it is better to go for XAMPP or WAMP which are really easy one. I would prefer WAMP because it is more easier than XAMPP to follow on.

But if you are about to learn how to install them independently, then you should install them in a sequence like

  • First install Apache and test what you did in the browser http://localhost. If it shows “It works” then your apache is running perfectly in port 80 successfully.
  • Now install PHP (unzip or untar or use installer) in a drive. Then you need to configure at least these three lines in your apache configuration file:

LoadModule php5_module “c:/php/php5apache2_2.dll”

AddType application/x-httpd-php .php

PHPIniDir “C:/php”

Hope you can the required values for first and third line. You can leave the second line as it is.

  • Finally you can use the installer of MySQL just as is. Normally no need to configure it if you are windows because it will be asked when you install it.

Hope you can manage.

I think you are having problem on configurations. So better remove all apache, php and mysql previously install and download WAMP Server installer and install like other windows applications and use it. It is pretty easier one for you.