Apache-MySQLPHP Installation & Configuration Tutorial for Beginners :)

Note: This article still seems to attract a fair bit of traffic. Just wanted to let you guys know that this is a pretty old article. PHP development environment has come a long way since then. You may want to download and use any of the following packaged environments instead: WAMP or XAMPP on Windows, or MAMP on OS X

In case you have any other queries, feel free to drop a note in the comments. I’ll try to answer.


This article is a very “narrow” tutorial aimed for complete beginners and dummies, who want to start off coding with AMP (Apache-MySQL-PHP) but do not want to read manual for installing and configuring them.
This write up is very specifically targeted and applies for Windows platform.

Note: To get the real and complete understanding, spend some time with the manuals. They are the best source of information.

Installing and Configuring PHP5 with Apache

    1. Select the most appropriate mirror for you from the following: http://www.apache.org/dyn/closer.cgi/httpd/binaries/win32/ (for Apache), and http://www.php.net/downloads.php for PHP.
    2. Download apache_1.3.x-win32-x86-no_src.exe and PHP 5.1.2 zip package (names PHP-5.x-win32).
        • DO NOT use Apache 2.x with PHP.

       

      • If you use PHP 4.x, make proper changes in the some of the steps given below.

Note:

  1. Install Apache by simply clicking on the exe file. The default path is C:\Program Files\Apache Group\Apache.
  2. Unzip the PHP file to C:\PHP.
  3. Add C:\PHP to system path.
  4. Backup and rename php.ini.dist to php.ini.
  5. Copy php5ts.dll and php.ini to %systemroot%.
  6. Copy php5apache.dll to C:\Program Files\Apache Group\Apache.
  7. Open cmd (command prompt) and run net stop apache (to obviously stop the server).
  8. Backup httpd.conf, located in C:\Program Files\Apache Group\Apache\conf, and then open it in an editor to add the following lines:
    • LoadModule php5_module php5apache.dll
    • AddType application/x-httpd-php .php
    • AddModule mod_php5.c [If you face any problems, remove this line and check again]
  9. Net start Apache.
  10. To check if all everything is in place, write the following code in a notepad and save it as “phpinfo.php” (with inverted quotes).

<?php
phpinfo();
?>

  1. Place the file in your DocumentRoot directory. The default path is C:/Program Files/Apache Group/Apache/htdocs.
  2. Start your Mozilla Firefox browser (it’s not mandatory, just a recommendation :P), and type http://localhost/phpinfo.php.
  3. If everything’s fine, we’ll see something like this:

 

phpinfo.jpg

Installing MySQL:

  1. We can find it in three shapes and sizes :D, The Complete Package, The Essentials Package and The Noinstall Archive. We’d go for the complete package named mysql-[version]-win32.
  2. The installation part is click next type.
  3. At the end of the installation, click to configure and choose the options as per your choice or as given below:
    • Detailed Configuration>Next
    • Developer Machine>Next
    • Multifunctional Database>Next
    • >Next
    • Manual Settings (choose 5)>Next
    • Enable TCP/IP (leave default port as 3306)>Next
    • Add to both, windows services and ssytem path>Next
    • Choose root password>Next
    • Execute.


Configuring MySQL & PHP:

  1. Open php.ini, located in %systemroot%, in and editor and uncomment the following line by removing the semicolon at the beginning of the line:
  2. extension=php_mysql.dll
  3. Copy php_mysql.dll and libmysql.dll from C:\PHP\ext to C:\PHP.
  4. To verify the configuration and administer MySQL, one may use phpmyadmin, found at http://www.phpmyadmin.net/home_page/index.php. However, do make sure not to publish it along with the site :P.
  5. That’s it. Happy Coding (. For anymore queries, either leave your comments or refer to the manuals.