Wednesday, July 11, 2007

Installing Apache, PHP and MySQL on Windows XP

Installing Apache, PHP and MySQL
This tutorial will show you how to install Apache 2.0.59, PHP 5.2.3 and MySQL 5.0.41 on machine running Windows XP.
To start with we will download all of the necessary applications which can be found at the following locations:
Apache: Apache download page
File to download: Win32 Binary (MSI Installer): apache_2.0.59-win32-x86-no_ssl.msi
PHP: PHP download page
File to download: PHP 5.2.3 zip package
MySQL: MySQL download page
File to download: Windows (x86) ZIP/Setup.EXE
Create a folder on your desktop and place all downloaded files inside of it.
Now go the the C:\ drive and create a folder with a name webserver.
This will be the folder where all of our apache, php and mysql files will be kept. Inside of this folder create another two: php and mysql.
Installing Apache
Go to your desktop to the previously created folder and double click apache_2.0.59-win32-x86-no_ssl.msi. This will start installation of Apache web server. Follow the instructions:
Apache Installation Step 1
Fig. 01 - Click next

Apache Installation Step 2
Fig. 02 - Select I accept terms in the licence agreement and click next.

Apache Installation Step 3
Fig. 03 - Click next

Apache Installation Step 4
Fig. 04 - In the first two fields type in localhost and in the last one info@localhost. We will be installing Apache as a service which starts automatically when computer starts therefore we select Port 80. If you are about to use your web server just from time to time then you may choose Port 8080. This way you would need to start Apache manually everytime you are going to use it.

Apache Installation Step 5
Fig. 05 - Select Custom and click next.

Apache Installation Step 6
Fig. 06 - Because we want our server to be installed in C:\webserver click Change button to change the path of the installation.

Apache Installation Step 7
Fig. 07 - Navigate to C:\webserver and click OK. On the next screen click next.

Apache Installation Step 8
Fig. 08 - Now you are ready to install Apache. Click Install.

Apache Installation Step 9
Fig. 09 - Once everything is done click Finish to exit setup.

Apache Installation Step 10
Fig. 10 - You should now see a small Apache icon in the system tray.

Apache Installation Step 11
Fig. 11 - In your C:\webserver folder you should notice an extra Apache2 folder has been created which stores your web server files.

Apache Installation Step 12
Fig. 12 - Now let´s see if Apache is running. Open your browser and if you were installing Apache as a service (Port 80) then type in URL http://localhost and press Enter. You should see the same page as displayed above. If you were installing Apache using Port 8080 then you would need to first start it by going to Start > All Programs > Apache HTTP Server 2.0.59 > Control Apache Server and click Start. Then in your browers´s URL type http://localhost/8080. This should open the same page in your browser.
Make sure you allow Apache access on your firewall.
Installing PHP
Go to your desktop and in the folder you initially created find file called php-5.2.3-Win32.zip.
Extract the content of this file to C:\webserver\php. Pull out all of the files from the php-5.2.3-Win32 folder and place them directly in C:\webserver\php.
Now we need to add our C:\webserver\php folder to the path of the Environment Variables.
To do this right click My Computer icon on your desktop and choose Properties. Then choose Advanced tab and click Environment Variables button (Fig. 13).
Installing PHP Step 1
Fig. 13
Now select Path from the System variables list in the bottom part of the window and click Edit (Fig. 14).
Installing PHP Step 2
Fig. 14
In the new window click inside the Variable value: box and press End button on your keyboard to get to the end of the path.
Now type in or copy and paste the following ;C:\webserver\php (Fig. 15). Make sure you start it with semicolon and to use back slashes.
Installing PHP Step 3
Fig. 15
Once you have done this click OK in all of the windows until you close the System Properties window. Now you need to restart the computer.
Next step will be to find out if our PHP is working. Go to Start > Run and type cmd. In the command prompt window type php -v. You should see something like Fig. 16.
Installing PHP Step 4
Fig. 16
We still have some tweaking to do before we finish our installation.
Go to C:\webserver\php and find file called php.ini-recommended. Rename that file to php.ini.
Open this file and make the following amendments:
  1. identify line with doc_root = and change it to:
    doc_root = C:\webserver\Apache2\htdocs
  2. identify line with extension_dir = "./" and change it to:
    extension_dir = C:\webserver\php\ext
Save and close the file.
Apache Configuration
Now we need to make sure that Apache knows where to search for php modules.
To do that first go to C:\webserver\Apache2\conf and open file httpd.conf in your text editor.
Because we will be running PHP as an Apache module which is faster and more secure option comparing to CGI binary, we will need to do the following changes to httpd.conf file:
  1. identify LoadModule section and add the following line at the top of this section:
    LoadModule php5_module "C:/webserver/php/php5apache2.dll"
  2. identify AddType section and add the following line at the top of this section:
    AddType application/x-httpd-php .php
  3. lastly place the following line somewhere within the content:
    PHPIniDir "C:/webserver/php/" - ensure you have a closing slash at the end of the path.
Save and close file. Restart Apache by going to Start > All Programs > Apache HTTP Server 2.0.59 > Control Apache Server and click Restart.
Now go to C:\webserver\Apache2\htdocs folder and select all files by pressing Ctrl + A on your keyboard. Right click on any of the selected files and choose Properties. In Attributes section of the General tab tick Hidden checkbox and click Apply and OK to close the window. This way you will only see your own files in this folder which is the root of our web server and the place where you will be setting up all your projects.
Inside C:\webserver\Apache2\htdocs create a file and give it a name phpinfo.php. Open this file with your text editor and place the following line:
<?php phpinfo(); ?>. Save and close the file.
Open your browser and type the following line in the URL:
http://localhost/phpinfo.php.
You should see now a PHP information page (Fig. 17).
Installing PHP Step 5
Fig. 17
Now that our Apache and PHP is installed let´s move on to the next section where we will be installing MySQL.

Installing MySQL
Go to your desktop and inside the folder you have initially created find file mysql-5.0.41.win32.zip. Extract the content of this file to the same folder on the desktop. Now go inside mysql-5.0.41-win32 folder and double click Setup.exe. Follow the steps:
Installing MySQL Step 1
Fig. 18 - Click next.

Installing MySQL Step 2
Fig. 19 - Select Custom and click next.

Installing MySQL Step 3
Fig. 20 - Click Change button to change the path of the installation.

Installing MySQL Step 4
Fig. 21 - Navigate to C:\webserver\mysql and click OK, then click next.

Installing MySQL Step 5
Fig. 22 - Click Install to start installation.

Installing MySQL Step 6
Fig. 23 - During installation a new window will pop up introducing MySQL Enterprise. Simply click next twice to continue with your installation.

Installing MySQL Step 7
Fig. 24 - Your installation is finished. You are now ready to configure your MySQL Server. Click Finish to start configuration.
MySQL Configuration
MySQL Configuration Step 1
Fig. 25 - On the first screen click next.

MySQL Configuration Step 2
Fig. 26 - Select Detailed Configuration and click next.

MySQL Configuration Step 3
Fig. 27 - Select Developer Machine and click next.

MySQL  Configuration Step 4
Fig. 28 - Select Multifunctional Database and click next.

MySQL Configuration Step 5
Fig. 29 - Leave everything as default and click next.

MySQL Configuration Step 6
Fig. 30 - Select Decision Support (DSS)/OLAP and click next.

MySQL Configuration Step 7
Fig. 31 - Leave two options checked and port number as 3306 and click next.

MySQL Configuration Step 8
Fig. 32 - Select Standard character Set and click next.

MySQL Configuration Step 9
Fig. 33 - Select Include Bin Directory in Windows PATH and leave other options as default. Click next.

MySQL Configuration Step 10
Fig. 34 - Tick Modify Security Settings and type in a password you want to use to access MySQL server, then click next.

MySQL Configuration Step 11
Fig. 35 - Click Execute to apply configuration settings.

MySQL Configuration Step 12
Fig. 36 - Click Finish to exit configuration wizard.
The last thing you need to do is to open php.ini file located in C:\webserver\php and uncomment the line extension=php_mysql.dll by removing semicolon ; at the beginning. Save the file and close it. Restart the computer.
This way you have completed your installation and you are now ready to start developing your web applications using Apache, PHP and MySQL.
Good Luck!


Be a better Heartthrob. Get better relationship answers from someone who knows.
Yahoo! Answers - Check it out.

0 Comments: