Your Ad Here

Tuesday, September 14, 2010

Install apache php and mysql

This blog will show you how install apache,php and mysql step by step.

First start installing apache,

Installing Apache
You can download apache in this apache official site, www.apache.org.
It is better to download "Win32 Binary (MSI Installer): apache_2.2.4-win32-x86-no_ssl.ms".
If you download the apache setup then double click it and if prompted, click "run”. Now you can see installation wizard.

Then click “Next”.
Next page will appear terms of agreement select "I accept", and click "Next".
Next page you can read about apache server, read and click “Next”.
Next screen will appear and ask you for specific server information enter you own or if you don’t know what the values must entered here you can use values in below picture.

Then click “Next”.
Next screen ask what type of installation do you want, select “Typical Installation” and click “Next”.
And next step enter “Next” again.
Then final step, click “Install”.
Now your apache server will install to your PC
When it finish, you can check if apache server installation success or not.
Open a browser and writ http://localhost in address bar, If you can see “It’s works!” then the Apache server has been installed successfully


Second we installing PHP,

Installing PHP
Download from official php site, www.php.net
It is better that you get "PHP 5.2.0 zip package".
Then create a new folder in your working drive (C in default ) and put name called “php”.
And copy downloadable file (php-5.2.0-Win32.zip) to created folder (C:\php),then extract it.
Now your php folder can see files and folder.
Then this is important work remember to copy "php.ini-dist" file from "C:/php/" to "C:/WINDOWS" and rename it to "php.ini". Because this is the you configure file of php.
Now you can tell to apache that PHP is exists .
Open apache configuration file ("C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf" or start-> Apache HTTP Server 2.2 -> Configure Apache Server -> Edit the Apache httpd.conf Configuration File) in note pad.
Then add below lines end of the "LoadModule" section:
LoadModule php5_module "c:/php/php5apache2_2.dll"
AddHandler application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "c:/windows"
To test php and apache work well, create a php file(info.php) in your “htdocs”
Folder and put this line in that file,
<?php phpinfo(); ?>
Then restart your Apache Server for the changes to take effect: Start > All Programs > Apache HTTP Server 4.2.4 > Control Apache Server > Restart
And now open a browser then put to http://localhost/info.php. to its url .
If the browser visible something like below picture, then PHP has been installed successfully!

Then configure your PHP .
Open PHP Configuration file(php.ini) located in “C:/WINDOWS/php.ini”
Open and find this first ,
extension_dir = "./"
And change it to
extension_dir = "C:\php\ext"
Second find this line
;session.save_path = "/tmp"
And change it to
session.save_path = "C:\WINDOWS\temp"
OK now apache and PHP successfully installed to your Computer

Third we installing mysql,
Installing MySql
Download mysql in its official site, www.mysql.com
Its better that you download "Windows (x86) ZIP/Setup.EXE (version 5.0.27)" from website.
When finished download extract “mysql-5.0.27-win32.zip” file.
Then double click the extracted file then you can see installation wizard.

Click “Next”.
Then select "Typical" Installation and click "Next".
And click “Install” (this can take several minutes) .
Next it will ask from you to "Sign Up". Select "Skip Sign-Up" for now.
Then next you get installation wizard is completion screen.

Then the MySQL Server Instance Configuration Wizard should appear. Click "Next".
Select "Detailed Configuration" and click "Next" in next screen.
Then select "Developer Machine" and click "Next" in next screen.
In next screen select "Multifunctional Database" and click "Next".
And Click "Next”.
And next screen select "Decision Support (DSS)/OLAP" and click "Next".
Then select "Multifunctional Database" and click "Next". 
Remember to check “Enable TCP/IP Networking" , the Port Number is set to "3306", and "Enable Strict Mode" is checked.
Then Click "Next".
Then select "Standard Character Set" and click "Next".
Remember to Check "Install as Windows Service", set the Service Name to "MySQL", and check "Launch the MySQL Server automatically". Make sure that the "Include Bin Directory in Windows Path" is NOT checked. Click "Next".
Next screen check the box that says "Modify Security Settings". Fill a password for the default "root" account, and confirm the password in the box below. Don’t check the boxes "Enable root access from remote machines" or "Create An Anonymous Account". Click "Next".
Next click “Execute".
And Click "Finish".
To test mysql installation is successful or not, goes to: Start > All Programs > MySQL > MySQL Server 5.0 > MySQL Command Line Client. The MySQL Command Line Client will appear:

Enter the password you created (If you enter an incorrect password MySQL will automatically close the command line)
Next type this commands
Mysql>use test;(test is your database)
Then it will appear Database changed
Mysql>CREATE TABLE users (id int primary key auto_increment, name text);
Then you can see ,
Query OK, 1 row affected
Mysql>INSERT INTO user VALUES(NULL,’Sanjana’);
Then you can see ,
Query OK, 1 row affected
Mysql>SELECT * FROM user;
Now you can see your table that you created.
If you don't get any errors, MySQL has been successfully installed!
Next we will need to configure PHP to work with MySQL.
Configuring PHP to work with MySQL:
Now we must configure php and mysql to work with together
Open php.ini file (C:/WINDOWS/php.ini) and find the line:
;extension=php_mysql.dll


To enable this delete the semicolon at the beginning.
 Next we going to do is get the PHP directory to the Windows PATH
Go to Start > My Computer > Properties > Advanced > Environment Variables
Under the second list (System Variables), there will be a variable called "Path"
Select it and click "Edit". Add ";C:\php" to the very end of the string and click "OK".
Then restart your computer.
Now your computer ready to build a php program with mysql to run on apache .
Write a program and check it.
Put your php files in “htdocs”
To run your file open a browser and  put this as url http://localhost/ your file name.