Configuring PHP5 And MySQL In Apache HTTP Server 2.2.* In Windows

This post assumes you already have Apache HTTP Server 2.2.* up and running under a Windows OS. Download the source of PHP5 and MySQL in their official websites and install them. Gone are the days when configuring PHP and MySQL was a big hassle. To have PHP5 and MySQL up and running, add the following code in the httpd.conf (Apache HTTP Server’s configuration file).

This assumes your PHP directory is located in c:/php. Also change the document root. Look for this keyword in the httpd.conf file, DocumentRoot and change the path to where you want to store all your PHP files. In this case, c:/phpweb. The purpose of the <Directory> tag is to allow file permission access so that the PHP compile can access PHP files and execute the scripts.

Also look for the keyword index.html and add an index.php before it so that it can read those kind of files first before looking for index.html.

Make sure libmysql.dll from c:/php is copied to the c:/windows/system32/ folder.
To create a php.ini file, there should be a file called php.ini-recommended. Copy that file and name it to php.ini.
Under the php.ini file, look for these two lines and remove the semicolon.

Look for this extension_dir keyword and place the value c:/php/ext. It should then look like this.

Then, look for this keyword short_open_tag and set it to on. This will enable you to use just <? ?> rather than be forced to use <?php ?>.

That’s it. Create a sample PHP file and place the code below.

Restart your Apache HTTP Server and check the contents of the PHP file. If you see a MySQL table entry, then you’re good to go.

Note: Creating MySQL accounts is a hassle. I suggest you use a MySQL client software when creating user accounts. I use SQLyog.

Related Posts Plugin for WordPress, Blogger...

Leave a Reply

Your email address will not be published. Required fields are marked *