PHP + Apache + MySQL perfect setup

This tutorial will show you with a lot of illustration how to setup a perfect WAMP - Windows, Apache, MySQL, PHP - development environment.

PHP 5 is already deprecated. PHP 7 is the actual version and PHP 8 is coming. Here is an article how to install PHP 8 on Windows 10.


Near the basic components you can find some nice tool which can help you to improve development process.
The following softwares will be installed during this tutorial:
  • Apache 2.2.3
  • MySQL 5.0.27
  • Php 5.2
  • SQLyog
  • PHP Designer 2007


Installing Apache

Apache Step 1.
Download Apache 2.2.3 from the Apache website: http://httpd.apache.org/download.cgi



Apache Step 2.
Start installation.

Step1



Apache Step 3.
Accept the license agreement.

Step1

Step1



Apache Step 4.
Setup a network and server domain. In the development environment you can write what you want here. Generally use localhost

Step1



Apache Step 5.
Select installation mode. The typical is perfect for us.

Step1



Apache Step 6.
Select in installation directory, where you want to store Apache main files.

Step1



Apache Step 7.
Finish the installation

Step1

Step1

Step1




Apache Step 8.
To test your new installed web server open a web browser and visit the URL: http://localhost You should get a result like this:

Step1


We will come back later to refine Apache configuration, but now let's install PHP.
[newpage=Installing PHP]

Installing PHP

PHP Step 1.
Download the PHP package from here: http://us2.php.net/get/php-5.2.0-Win32.zip/from/a/mirror



PHP Step 2.
Create a new directory in you Program Files with name php like this:
Step1



PHP Step 3.
Now edit Apache configuration file (httpd.conf) to enable php processing. You can find the configuration file in the Apache installation directory/conf/httpd.conf. On my machine the exact location is: D:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf



PHP Step 4.
Add the following 3 lines to your httpd.conf file. You can put them anywhere in the file but maybe it makes sense to put them after the other LoadModule section.
LoadModule php5_module "d:/Program Files/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "D:\Program Files\php"

Step1



PHP Step 5.
Now you have to restart Apache.
Start menu -> Programs -> Apache HTTP Server 2.2.3 -> Control Apache Server -> Restart



PHP Step 6.
At the moment PHP is installed so you should try it. Create a new file in the Apache document root directory (D:\Program Files\Apache Software Foundation\Apache2.2\htdocs) with name info.php Put the following 3 lines into this file and then save it.
?php
phpinfo();
?>
Step1



PHP Step 7.
Let's try it out. Visit the following URL: http://loclahost/info.php You should get a page similar to this:
Step1

[newpage=Installing MySQL - Part 1]

Installing MySQL

The last main component is MySQL.

MySQL Step 1.
Download the free version of MySQL database server ( Select Windows (x86) ) from here: http://dev.mysql.com/downloads/mysql/5.0.html#downloads



MySQL Step 2.
Start installation.

Step1



MySQL Step 3.
Select custom installation.

Step1



MySQL Step 4.
Set the directory where to install MySQL.

Step1



MySQL Step 5.
Follow the instruction for the next 2 steps.

Step1

Step1




MySQL Step 6.
You can skip MySQL account creation.
Step1



MySQL Step 7.
Select configuration right now and a new wizard will start.

Step1

Step1



MySQL Step 8.
Select detailed configuration.

Step1



MySQL Step 9.
Now select development machine.

Step1



[newpage=Installing MySQL - Part 2] MySQL Step 10.
And after the Multifunctional Database.

Step1



MySQL Step 11.
You can select where MySQL stores the data files.

Step1



MySQL Step 12.
Let's set the allowed concurrent connections to 10. It is enough as it is only a home development server and we don't want to waste a lot of resources for MySQL.

Step1



MySQL Step 13.
Configure port and default character set.

Step1

Step1



MySQL Step 14.
Set MySQL as Windows service and start it with Windows.

Step1



MySQL Step 15.
Define the root password

Step1



MySQL Step 16.
As final step execute the configuration.
Step1

Step1

Now all main software component is installed. We just need to do some small refinement to work all of them together. [newpage=Fine tune PHP]

Fine tune PHP


Starting from PHP 5 the MySQL support is not built in by default in the PHP interpreter. You can check it on your own fresh installed web server by checking the PHP Info page. See the Installing PHP section. Try to find the word mysql. There will be nothing.

Fine tuning Step 1.
To allow MySQL you have to edit a little bit the php.ini file. You can find it in the PHP installation directory. At the moment there are only a php.ini-dist and a php.ini-recommended files in this directory. These files contains the basic settings.



Fine tuning Step 2.
Rename the php.ini-recommended to php.ini.



Fine tuning Step 3.
Now open it for editing and try to find the line:
extension_dir
Change the line from
;extension_dir = "./"
to
extension_dir = "D:\Program Files\php\ext"
Take care that the first semicolon(;) was removed.



Fine tuning Step 4.
Next step is allow the MySQL extension. Try to find the line:
;extension=php_mysql.dll
Remove the semicolon from the first place.
Save the file.



Fine tuning Step 5.
To make sure that Apache will find the correct MySQL dll copy the libmysql.dll from the php directory into the Apache/bin directory.



Fine tuning Step 6.
Restart Apache and check the PHP Info page again. Now you have to find a MySQL section.




At the moment you have a full working WAMP server installed on your PC. However to work easy it is recommended some useful tools for MySQL tasks and for PHP coding. You will get the information on the next page. [newpage=MySQL Management]

MySQL Management


It is not an easy way to work with MySQL via command line. The package has some built in tools but they are not the best. So we will install SQLyog which is a free MySQL tool to handle your database fast and easy.

MySQL Management Step 1.
Download the community edition of SQLyog from here: http://webyog.com/en/downloads.php



MySQL Management Step 2.
Start the installation

Step1



MySQL Management Step 3.
After accepting the license agreement you can set the directory where to install the tool

Step1

Step1



MySQL Management Step 4.
The installation runs fast and you can start the new tool to manage your MySQL database.

Step1

Step1




On the next page we will setup the management tool and create a new MySQL user. [newpage=MySQL skills]

MySQL skills


Now we will create a new MySQL database user. But before we setup our new tool.

MySQL skills Step 1.
After starting SQLyog the first time you need to create a new connection.

Step1



MySQL skills Step 2.
Create a new connection and fill the Server information as follows. You have defined the root password during the installation of MySQL

Step1

Step1



MySQL skills Step 3.
The interface is quite friendly. You can find available databases on the left, a query editor on the top right and a result set browser on the bottom right.

Step1



MySQL skills Step 4.
Before start playing with the tool, let's create a new user.
Select Tool -> User Manager -> Add User

Step1



MySQL skills Step 5.
Setup a user name, password and others as follows and save it.

Step1



MySQL skills Step 6.
Now you have created a new user with a limited privileges. You can repeat the Step 1 and 2 to login as the new user.

Step1




At least we will setup a nice PHP IDE on the next page.
[newpage=PHP IDE]

PHP Designer 2007


You can use any text editor to edit php files but there are some nice tool that can help to reduce your PHP coding efforts. Here we will install the free version of PHP Designer 2007. PHP Designer 2007 Step 1.
Download the PHP Designer 2007 personal edition from here: http://www.mpsoftware.dk/phpdesigner_personal.php



PHP Designer 2007 Step 2.
Select your language and start the installation
Step1

Step1



PHP Designer 2007 Step 3.
After accepting the license agreement you can set the directory where to install the tool
Step1

Step1



PHP Designer 2007 Step 4.
Now some usual settings and installation is ready
Step1

Step1

Step1

Step1



PHP Designer 2007 Step 5.
Now you can edit you r first PHP script with this friendly IDE
Step1

Step1