Freemindscafe

Enabling Apache2 for php

#1

Configuring apache2 web server

You need to insert the following lines into your Apache httpd.conf configuration file to load the PHP module for Apache 2.x:

# 
LoadModule php5_module "E:/softwares/php/php7apache2_4.dll"
AddHandler application/x-httpd-php .php

# configure the path to php.ini
PHPIniDir "E:/softwares/php"

Screenshot

Here “E:/softwatres/php” is php installation directory. Refer to http://www.freemindscafe.com/t/installing-php-on-windows-machine/86/1 for details.

hello.php file

Create the following hello.php file under apache web server’s document root. Please refer to http://www.freemindscafe.com/t/installing-apache2-web-server-on-windows-machine/85 to define the document root for the apache web server.

<html> 
	<head> 
	<title>PHP Test</title>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
	</head>

<body> 
	<h1>PHP Test</h1>
		<p><b>An Example of PHP in Action</b></p>
		<?php echo "The Current Date and Time is: <br />"; 
		echo date("g:i A l, F j Y.");?> </p>
	<h2>PHP Information</h2> 
		<p> <?php phpinfo(); ?> </p> 
	</body> 
</html>
  • Start apache webserver
  • Access hello.php file in the browser by pointing it to http://localhost/hello.php
  • php scripting should kick in and should render the following