Wednesday, April 1, 2009

Installing PHP 5.2.3, MySql 5.0,Apache2.2 on Windows XP





I am working with WAMP technology . As of my experience newer supposed to be struggle when configure WAMP.Here is the configuration notes of PHP to work with MYSQL and Apache2.2 on a Windows XP machine. These are the steps I took. Hope that they work for you...

I installed PHP and MySQL on Windows XP platform with Apache2.2. Please note that PHP,mySQL and Apache is open source , the first thing I did was search google for "Download Apache2.2 " and go to Apache official site to download and Install it.

Download Apache2.2 from here

(Apache2.2 download link)


* PHP 5.2.9-1 installer [17,304Kb]: Click Here to Download

* Download MySQL 5.0 : Click Here to Download

* Download MySQL 5.0 GUI Tools : MySql 5.0 GUI Tools (Tools to help you administer database)


Installing Apache2.2

  1. If you haven't done so already, download the Apache HTTPD Web Server from the Apache web site . Be sure to download the apache_2.2.11-win32-x86-no_ssl MSI installer here: (http://httpd.apache.org/download.cgi)

  2. Save the file to your Windows Desktop.



  3. Apache Web Server Install Window


    Apache Web Server Install Window

    Double click the msi file saved on your Windows Desktop. You will see a window that looks like this:

  4. Click "Next>".

  5. Click the radio button "I accept the terms in the license agreement"

  6. Click "Next>".

  7. On the next window, again click "Next>".

  8. Next, fill in all the text boxes with the following information:

    1. "Network Domain": localhost

    2. "Server Name": localhost

    3. "Administrator's Email Address": your email address


  9. Make sure the radio button "for all users, on port 80, as a service - recommended" is selected.

  10. Click "Next>".

  11. On the next window, click the radio button "Custom", and then click "Next>".

  12. On the next window highlight "Apache HTTP Server" and click the "change" button.

  13. We are going to install all the packages and scripts in the folder C:\www\Apache2\ (assuming C: is your main hard drive). So in the text box "Folder name:" type in "C:\www\Apache2\". The ending backslash is important.

  14. After you have typed in the path, click "OK" and then click "Next>". At this point, you should see a window that looks like this:


    Apache Ready to Install


    Apache Ready to Install

  15. Click "Install" to begin the installation.

  16. Once the Apache installation software has finished installing all the files on your computer, you will see a final window letting you know the installation was a success. Click the "Finish" button.
Tips::
  • To check that the software was in fact installed successfully, open your favorite browser and type "http://localhost/" into the address bar. You should see a page that looks like this:


    Apache Success


    Apache Success

Installing the PHP

Instructions for installing the PHP Engine.

  1. If you haven’t done so already, download the PHP Windows Binaries - You can download the software from the PHP.net website, (http://www.php.net/downloads.php) Be sure to download PHP 5.0.4 installer Windows installer and PHP 5.0.4 zip package. (Note: the version numbers might be different). Save the files on your Windows Desktop.

  2. On your Windows Desktop, double click the PHP installer file. Once you've done that, you should see a window that looks like this:

    PHP Install Window


    PHP Install Window


  3. Click "Next>".

  4. On the next window, click "I Agree".

  5. On the next window, click the radio button "Advanced", and click "Next>".

  6. We're going to install PHP in our server directory instead of the default PHP directory, so in the "Destination Folder" group, click "Browse".

  7. A browser window will open. Change the destination directory to "C:\www\php". There is no need for a trailing backslash.

  8. Click "OK" on the browser window, and then click "Next>".

  9. Select "Next>" on the next three screens.

  10. On the following window, leave the SMTP defaults as they are, and click "Next>".

  11. If you want, you can enter an email address. This will be used as the "From:" email address when using PHP's mail function.

  12. On the next window, make sure that the radio button "Display all errors warnings and notices" is clicked. Then click "Next>".

  13. 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>".

  14. On the next window make sure that the check box ".php" is checked, and then click "Next>".

  15. Now that you have set all the options, you should see a window that looks like this:


    PHP Ready to Install


    PHP Ready to Install


    PHP is ready to install, so click "Next>" to begin the installation.

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

  17. Now a message window should pop up that looks like this:

    Image:apache_configuration.jpg


  18. This is normal. Click "OK". When the PHP installer window pops up, click "OK" again.

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

  20. In Windows open "My Computer", and browse your way to the folder "C:\www\Apache2\conf".

  21. Double click the file "httpd.conf" so we can edit it. This should open the file in Notepad.

  22. Scroll to the very bottom of the page, and add these lines:

    1. ScriptAlias /php "c:/www/php/"

    2. AddType application/x-httpd-php .php

    3. Action application/x-httpd-php "/php/php-cgi.exe"


  23. You should highlight and copy the text from this page, and then paste it into the httpd.conf page to ensure there are no typos. Hit "Enter" after the last line to ensure there is one blank line at the end of the file.

  24. When we installed PHP, it created the file "C:\Windows\php.ini". We want to move that file to the directory "C:\www\php" so it’s easier to edit when we need to. # Open "My Computer" and browse to "C:\Windows".

  25. Find the file "php.ini" in the windows directory.

  26. Right-click the file and pick "Cut".

  27. Now browse to the directory "C:\www\php".

  28. Right-click an empty area in the window and select "Paste". This moves the "php.ini" file from the Windows directory to the PHP directory.

  29. Now double click the file php-5.0.4-win32.zip that is saved on your desktop. (Note: the version number might be different).

  30. Extract the contents of this file to "C:\www\php".

  31. Using Notepad, open the file "C:\www\php\php.ini".

  32. Find that line that reads: extension_dir = "./" (or something similar, as long as its the line with "extension_dir".

  33. Change the line to: extension_dir = "c:\www\php\ext"

  34. Now find the line that reads: ;extension=php_mysql.dll Delete the ; so that the line now reads: extension=php_mysql.dll

  35. Now open the directory "C:\www\MySQL\bin".

  36. Find the file "libmysql.dll".

  37. Right-click the file and select "Copy".

  38. Browse to the directory "C:\Windows\System32" and Paste the file into that directory.

  39. Now you need to restart Apache to ensure the new lines added to the httpd.conf file have an effect.

  40. On the Windows taskbar click "Start">"All Programs">"Apache HTTP Server">"Control Apache Server">"Restart". This should restart the Apache server. Now we need to create a test PHP to see if everything is working.

  41. Open Notepad (usually found in "Start">"All Programs">"Accessories">"Notepad"), and copy and paste the following lines into a new document: <?PHP phpinfo(); ?>

  42. In Notepad, click "File">"Save". Save this file in the directory "C:\www\Apache2\htdocs" as "phpinfo.php". Notepad has a bad habit of adding .txt to the end of all documents you save, so make sure from the "Save" dialog that comes up in Notepad, change "Save as type" from "Text Documents (*.txt)" to "All Files". Now click the "Save" button to save your new PHP document.

  43. Open your favorite browser and in the address bar type "http://localhost/phpinfo.php". If everything is set up correctly, you should see a page that looks like this:


    PHP Success


  44. PHP is now installed!

Tips

If you want to save your time, use XAMPP software bundle or WITSuite EasyInstaller (WITSuite installation video: http://www.witsuite.com/products/installer/). It is most simple way to install Apache, PHP, MySQL on Windows.

    • Be sure to make these last changes to the Apache configuration file to prevent a 403 FORBIDDEN message when testing to see if PHP has been successfully installed.

  • <Directory "c:/php/">

  • AllowOverride None

  • Options None

  • Order allow,deny

  • Allow from all

  • </Directory>

INSTALLING MYSQL

Step 1: Install MySQL 5.0.

Step 2: Install MySQL 5.0 GUI Tools. These will allow you to view your databases and data structures

Step 3: Configure an Instance: The best way I configured it to work successfully was once it was installed to go into the "MySQL Server Instance Configuration Wizard" and click "Detailed Configuration", "Developer Machine", "Non-Transactional Database Only", "Decision Support (DSS)/OLAP", "Check Enable TCPIP Netwokring", Port 3306, "Standard Character Set", "Install as a Windows Service", Give it a main password that you remember like "root", Click "Execute!!".


*** Please note your username will be "root" and password will be whatever you typed (in this example "root"). After you hit "Execute", You should see 4 buttons light up with no red 'X's and you know MySql is configured correctly!


Step 4: Open the MySQL Administrator program. Set server host = localhost, username=root and password=root or whatever you set it to. Click on catalogs, if you see "mysql" then that is a main database.

This means that MySQL is installed properly!!

Step 5: I have provided a simple PHP script to test database connection to
MYSQL. Copy and paste this into a file call it for example: "testmysql.php"

and place it into the web root folder (same folder as "phptest.php")

Step 6: If you run this script by typing: http://127.0.0.1/testmysql.php
and it says "Successfully Connected to MySQL Database Manager!" and "Successfully Connected to Database 'MYSQL'" then this means that MySQL is now communicating with PHP and is installed and working properly!!!

Hope it helped!


No comments:

Post a Comment