How to Install Apache, MySQL, PHP, and phpMyAdmin on Windows

Install all the software needed to run a PHP + MySQL enabled web server on your Windows PC. All software mentionned in this article are free.

Most easy way is to use package software to automate whole process. Check the alternate method section for easiest way.

Do do this manually follow the below mentioned steps.

Getting Started :

  • Download the Apache HTTPD Web Server from the Apache website (httpd.apache.org). Be sure to download the latest stable Win32 Binary version of Apache with the MSI Installer.
  • Download the latest stable PHP Windows Binaries with installer. (Click Here )
  • Download the latest stable Windows version, which includes a Windows Installer, of the MySQL Database Server. (Click Here )
  • Download the phpMyAdmin Database Manager file. (Click Here )

Now we have downloaded all the software. Let us install them one by one.

How to Install the Apache Web Server on Windows.

  1. Double click the downloaded msi for Apache:
  2. Click "Next>" as require.
  3. Next, fill in all the text boxes with the following information:
    • "Network Domain": localhost
    • "Server Name": localhost
    • "Administrator's Email Address": your email address
  4. Make sure the radio button "for all users, on port 80, as a service - recommended" is selected.
  5. On the next window, click the radio button "Custom", and then click "Next>".
  6. On the next window highlight "Apache HTTP Server" and click the "change" button.
  7. We are going to install all the packages and scripts in the folder C:\Server (assuming C: is your main hard drive). So in the text box "Folder name:" type in "C:\Server\". The ending backslash is important.
  8. Click "Install" to begin the installation
  9. Click the "Finish" button.

To check that the software was in fact installed successfully, open your favorite browser and type "http://localhost/" into the address bar and check the apache default page.

How to Install MySQL Database Server on Windows :

Run the MSI file and use the following settings

  1. Typical Setup
  2. Skip Sign-Up
  3. make sure "Configure the mySQL Server now" is checked.
  4. "Detailed Configuration"
  5. "Developer Machine"
  6. "Multifunctional Database"
  7. "InnoDB Tablespace Settings" - leave everything default
  8. "Decision Support (DSS)/OLAP"
  9. Make sure "Enable TCP/IP Networking" is checked and leave the port number at 3306 (at this point, if you have a firewall, it will usually try to access itself on the localhost)
  10. "Standard Character Set"
  11. check "Install As Windows Service".
  12. I recommend leaving "Include Bin Directory in Windows PATH" checked
  13. enter your root password
  14. then hit "execute" and it´ll install and set it up.

And that's it, you're done installing MySQL.

Install the PHP Engine on Windows PC :

  1. Typical Setup.
  2. On the next window, click the radio button "Advanced", and click "Next>".
  3. We're going to install PHP in our server directory instead of the default PHP directory, so in the "Destination Folder" group, click "Browse".
  4. A browser window will open. Change the destination directory to "C:\Server\PHP". There is no need for a trailing backslash.
  5. On the following window, leave the SMTP defaults as they are, and click "Next>".
  6. If you want, you can enter an email address. This will be used as the "From:" email address when using PHP's mail function.
  7. On the next window, make sure that the radio button "Display all errors warnings and notices" is clicked. Then click "Next>".
  8. On the next window is where you pick which web server software you are using. Since you have installed Apache, pick "Apache" from the list. Then click "Next>".
  9. On the next window make sure that the check box ".php" is checked, and then click "Next>".

If a message window pops up asking, "Do you want to keep your php.ini file", click "NO". Now a message window should pop click ok.

Now PHP is installed, but we need to change some of Apache's settings to get everything working the way it should.

Configure PHP with APACHE :

  1. Browse your way to the folder "C:\Server\Apache2\conf".
  2. Open the file "httpd.conf" for editing.
  3. Scroll to the very bottom of the page, and add these lines:
    • ScriptAlias /php "c:/server/php/"
    • AddType application/x-httpd-php .php
    • Action application/x-httpd-php "/php/php-cgi.exe
  4. Hit "Enter" after the last line to ensure there is one blank line at the end of the file.

Configure PHP.INI

  1. Find the file "php.ini" in the windows directory.
  2. This moves the "php.ini" file from the Windows directory to the PHP directory ("C:\Server\php").
  3. Using Notepad, open the file "C:\Server\php\php.ini".
  4. Find that line that reads: extension_dir = "./" (or something similar, as long as its the line with "extension_dir".
  5. Change the line to: extension_dir = "c:\Server\php\ext"

Getting PHP5 to work with mySQL

Unfortunately PHP5 removed built-in support for mySQL. So you´ll need to copy some files by hand. open the folder you unzipped your PHP to. Copy the libmysql.dll file (should be located like C:\Server\php\libmysql.dll ) into your Window´s System folder (usually C:\Windows\System32\ although might be c:\WinNT\System\ or something).

Then open up your php.ini in a text editor and search for ;extension=php_mysql.dll and remove the ; in front of that line.

Do the same for ;extension=php_mbstring.dll. Without the mbstring extension phpMyAdmin is unable to split strings correctly and it may result in unexpected results.
Restart Apache and see if you get any errors. If it complains about php_mysql.dll either your extention directory isn´t correct or windows can´t find libmysql.dll

If you don´t want to move files outside your php5 directory, you may also add the php5 directory to the PATH on Windows.

Now you are done.

How to Install phpMyAdmin on Windows

phpMyAdmin lets you control you MySQL database from a web browser.

To install PHPMyAdmin, you need to extract the .zip file to the C:\SimplePHP folder and rename the phpmyadmin folder as C:\SimplePHP\phpMyAdmin. After, open the config.inc.php file and find the line starting with $cfg['PmaAbsoluteUri'] and change it for :

$cfg['PmaAbsoluteUri'] = 'http://localhost/mysql/';

phpMyAdmin can also try to auto-detect the proper value if this directive is left as it is (blank) and this line is changed to 'TRUE'...

$cfg['PmaAbsoluteUri_DisableWarning'] = FALSE;

 

Next, you need to locate the series of lines starting with $cfg['Servers'][$i][] and make sure the four following lines are identical :

$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';

 

Since we installed PHPMyAdmin out of the C:\SimplePHP\root folder which is the web server's root folder, we will use a trick to make sure PHPMyAdmin is found by the web server.

To achieve this feat, you will once again need to open the httpd.conf file and insert the following code in the Aliases section (located at about two thirds of the beginning of the file) :

Alias /mysql/ "C:/SimplePHP/phpMyAdmin/"

<folder "C:/SimplePHP/phpMyAdmin/">
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.1
</folder>

This enables us to access PHPMyAdmin by typing the below address in our browser (the "/" is very important) :

http://localhost/mysql/

You are done!

Alternate Method

Download the full package of Xampp that contains everything. It also has a control panel, to admin everything. Xampp is the best and easiest way to do all this. For novice users I highly recomand Xampp.

http://www.apachefriends.org/en/xampp.html

Alternatively you can also install appserv. This program contains all you need to easily setup these programs in a Windows NT/2000/XP PC.