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
- 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.
- 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.
- Install Apache by simply clicking on the exe file. The default path is C:\Program Files\Apache Group\Apache.
- Unzip the PHP file to C:\PHP.
- Add C:\PHP to system path.
- Backup and rename php.ini.dist to php.ini.
- Copy php5ts.dll and php.ini to %systemroot%.
- Copy php5apache.dll to C:\Program Files\Apache Group\Apache.
- Open cmd (command prompt) and run net stop apache (to obviously stop the server).
- 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]
- Net start Apache.
- To check if all everything is in place, write the following code in a notepad and save it as “phpinfo.php” (with inverted quotes).
- Place the file in your DocumentRoot directory. The default path is C:/Program Files/Apache Group/Apache/htdocs.
- Start your Mozilla Firefox browser (it’s not mandatory, just a recommendation :P), and type http://localhost/phpinfo.php.
- If everything’s fine, we’ll see something like this:
- 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.
- The installation part is click next type.
- 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
- 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
Configuring MySQL & PHP:
- Open php.ini, located in %systemroot%, in and editor and uncomment the following line by removing the semicolon at the beginning of the line:
- Copy php_mysql.dll and libmysql.dll from C:\PHP\ext to C:\PHP.
- 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.
- That’s it. Happy Coding (. For anymore queries, either leave your comments or refer to the manuals.