Sie sind auf Seite 1von 5

Apache HTTP Server 2.2.3, PHP 5.3.

0 and MySQL 5
Configuration for Windows Platform Guide

Software used:
• Apache HTTP Server v2.2.3
• PHP v5.3.0
• MySQL v5

Here I assume the installation paths for Apache as


C:\Program Files\Apache Software
Foundation\Apache2.2
And extracts the php zip file contents to folder under C:\
drive as
C:\PHP

 Just extract the PHP ZIP file downloaded from the site
http://www.php.net to the dir

C:/PHP

Now copy C:/PHP/php-INI-PRODUCTION file content,


and create a file with name C:/PHP/php.ini paste the
content here, this is the file used by the Apache server to
know the behavior of the php installed.

 Find "DocumentRoot" property and point it towards the


directory where we are going to place our web files.

EX: DocumentRoot "D:/Parent Folder/Sub Folder/"


Place in double quotes if the path contains any spaces
like above.

 Find <Directory "C:/Program Files/Apache Software


Foundation/
Apache2.2/htdocs">
Here it is the default value and make the following change by
commenting the default value/remove default value
Change its value to the what we are already did for
DocumentRoot property in the above step as
<Directory "D:/Parent Folder/Sub Folder">

 Find ScriptAlias property and make the following change to


it,

• ScriptAlias /cgi-bin/ "C:/Program Files/Apache


Software
Foundation/Apache2.2/cgi-bin/"
// It was already there and add the following 3 lines
below that
• ScriptAlias /php/ "C:/PHP/"
• AddType application/x-httpd-php .php
• Action application/x-httpd-php "/php/php-
cgi.exe"

Here "C:/PHP" is the directory where we extract


the content from the ZIP file downloaded from the
http://www.php.net site. Here "PHP" is the name of the dir
that was given by the user for extraction not by the
unzipping application. It contains all the files in the zip
folder.
Change the path "C:/PHP" if the actual path changes.

 In order to get the permission to access and process the php


files it must to load the following file into Apache Server.

LoadModule php5_module
"C:/php/php5apache2_2.dll"
PHPIniDir "C:/php"
AddType application/x-httpd-php .php

 The environment for PHP in Apache Server is done now go to


check PHP proper installation.
 To test PHP installation,

• Create a php file like


<?php phpinfo() ?>
• Save the above single line code in the folder
"D:/Parent Folder/Sub Folder/index.php"
• Now access it from the Apache server using URL
"http://localhost/", but it fail to load if the pointing
folder doesn't contain any file with the name and
extension as "index.html", because always server
looks for a file when we access with the folder name
itself, if the requested folder contains any file with
name "index.html" it rendered if not it shows a
"Forbidden" error message.
• In order to get relax from this; make the following
change in httpd.conf,
Find "DirectoryIndex" property and type the
following after it,

DirectoryIndex index.html index.php

Here server first looks for index.html file if not


found then it
goes for index.php or if you change the order to
.php file
comes first then it looks first for a .php file.

If everything done well you'll see page with lot of


information about PHP installed in the system.

 This Step is for configure PHP for access MySQL 5.x

• First open C:/PHP/php.ini file and find property


;extension=php_mysql.dll
Here ";" indicating a commented line, remove that
to make available it.
• Even after making change, if still there is any
problem founded then make the following change.
Find property extension_dir= and write after it
as extension_dir = “C:/PHP/ext”

Caution:

Each time you make changes in httpd.conf file you


must "restart" the server to take effect by the change
made by you.

Finally:

Sample Apache - PHP - MySQL Program:

<html>
<head>
<title>MySQL PHP Connection test</title>
</head>
<body bgcolor="gray" text="white">
<center>
<?php
echo "Hello.............”
$conn = mysql_connect("localhost", "user_name",
"password");
if(!$conn)
die("<p>Connection to MySQL is failed due to <b>“.
mysql_error()
. "</b> </p>");
Echo "successfully Connected to MySQL<br />";
$db = mysql_select_db("db_name", $conn);
if(!$db)
die("<p><b>" . mysql_error() . "</b></p>");
echo "successfully Connected to MySQL Database<br />";
mysql_close($conn);
echo "Connection to MySQL is Successfully closed";
?>
</center>
</body>
</html>

Das könnte Ihnen auch gefallen