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.
- Double click the downloaded msi for Apache:
- Click "Next>" as require.
- Next, fill in all the text boxes with the following information:
- "Network Domain": localhost
- "Server Name": localhost
- "Administrator's Email Address": your email address
- Make sure the radio button "for all users, on port 80, as a service - recommended" is selected.
- On the next window, click the radio button "Custom", and then click "Next>".
- On the next window highlight "Apache HTTP Server" and click the "change" button.
- 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.
- Click "Install" to begin the installation
- 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
- Typical Setup
- Skip Sign-Up
- make sure "Configure the mySQL Server now" is checked.
- "Detailed Configuration"
- "Developer Machine"
- "Multifunctional Database"
- "InnoDB Tablespace Settings" - leave everything default
- "Decision Support (DSS)/OLAP"
- 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)
- "Standard Character Set"
- check "Install As Windows Service".
- I recommend leaving "Include Bin Directory in Windows PATH" checked
- enter your root password
- 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 :
- Typical Setup.
- On the next window, click the radio button "Advanced", and click "Next>".
- We're going to install PHP in our server directory instead of the default PHP directory, so in the "Destination Folder" group, click "Browse".
- A browser window will open. Change the destination directory to "C:\Server\PHP". There is no need for a trailing backslash.
- On the following window, leave the SMTP defaults as they are, and click "Next>".
- If you want, you can enter an email address. This will be used as the "From:" email address when using PHP's mail function.
- On the next window, make sure that the radio button "Display all errors warnings and notices" is clicked. Then click "Next>".
- 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>".
- 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 :
- Browse your way to the folder "C:\Server\Apache2\conf".
- Open the file "httpd.conf" for editing.
- 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
- Hit "Enter" after the last line to ensure there is one blank line at the end of the file.
Configure PHP.INI
- Find the file "php.ini" in the windows directory.
- This moves the "php.ini" file from the Windows directory to the PHP directory ("C:\Server\php").
- Using Notepad, open the file "C:\Server\php\php.ini".
- Find that line that reads: extension_dir = "./" (or something similar, as long as its the line with "extension_dir".
- 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 :
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'...
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]['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) :
<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) :
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.