Docstoc

Installing IIS PHP and MySQL

Document Sample
Installing IIS PHP and MySQL Powered By Docstoc
					Web based application development using
        IIS, PHP and MySQL



CONTENT


Installing IIS                                              2

Installing PHP                                              4

Integrating IIS with PHP                                    6

Installing MySQL                                            10

Installing MySQL Control Center                             15

A brief MySQL Control Center Tutorial 20

An exercise example                                         28




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.   1
Installing IIS
Insert the Windows XP CD and open the Control Panel and click on ADD REMOVE
PROGRAMS. Then click on Add/Remove Windows Component. You will see the
following window on the screen.




Check the box next to the IIS and click next to install.




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.          2
Once the installation has completed the following screen will b displayed.




The installation of IIS is now complete. Then go to the Administrative Tools and click
on Services.




Locate IIS Admin on services window and highlight it as shown above. It should state
that the service has started. If so then close the window else start the services.
CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.                     3
Installing PHP
The version of PHP that we have downloaded (php-4.1.0-Win32.zip) does not
have an automated installation wizard, but the installation is very easy.




Extract the contents of the installation ZIP to a temporary directory. The directory
structure that has been extracted contains many files for many different
scenarios.




Copy all files to the c drive under a folder c:/php.
Copy the MIBS folder under c:/usr.


CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.               4
Take the file called "php.ini-dist", rename it to "php.ini" and move it to
C:\WINDOWS\ or wherever you usually put your *.ini files.

Take the two files "Msvcrt.dll" and "php4ts.dll", and put them in C:\WINDOWS\
or wherever you usually put your *.dll files. If your system tells you that you
already have "Msvcrt.dll" or it's currently in use, that's fine. As long as you have
it.




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.                   5
Integrating IIS with PHP
Configuring IIS for PHP
We shall assume in this section that your IIS is up and running, click Start-Setting-
Control Panel-Administrative Tools- Internet Service Manager




Select Default Web Site, right click and select property...




Select the Home Directory Tab and click Configuration
In the Application Configuration window select App Mappings and click Add Button




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.                    6
Enter the executable as C:\PHP\PHP.EXE (or the location where you have installed PHP)
and the extension as .php as shown in the above figure and click OK. This configures IIS
to recognize and run PHP Files with PHP interpreter.
Open your favorite text editor and create a text file and type the following in it

<?php
  phpinfo();
?>
phpinfo() is a PHP function which outputs a large amount of information about the
current state of PHP. This includes information about PHP compilation options and
extensions, the PHP version, server information and environment, the PHP environment,
OS version information, paths, master and local values of configuration options, HTTP
headers, and the PHP License.
Save this file as test.php in C:\INETPUB\WWWROOT (or your IIS Web Root Folder)
Open you browser and type http://localhost/test.php in the address bar, click Go to see if
you see output like the screen below to make sure PHP in configured and running
properly.




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.                         7
Fire up your Web browser and go to http://localhost/phpinfo.php. If you can see a page
with many information that simply indicates that Apache is fully configured with PHP --
you should see a page that starts out like this:




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.                  8
(Setting Up Session Folder and Integrated with php.ini)

Open up the php.ini file and make these configuration changes.




Write c:/temp at these places in the php.ini:
             session.save_path
             session.cookie_path
             session.referer_check
             session.entropy_file




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.   9
Installing MySQL
The version of MySQL that we have downloaded is the latest one (php-4.0.21-
Win32.zip) it has an automated installation wizard. First unzip all files to a folder
and then run setup.




Double click on the Setup File




Click Next




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.                10
Click Next, to see Installation Folder options.




Click Next Again, To see the Installation Type, Choose Typical



CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.   11
Click Next, this starts copying Files.




Click Finish to complete the Installation


CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.   12
Configuring MySQL

.Double click the winmysqladmin.exe file from c:\MySQL\bin




You will be asked for a username and password




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.   13
Enter "root" (no quotes) and give a password, Click OK

WinMySQLAdmin will appear as a traffic light icon in your system tray and is
added to the start menu automatically so that it starts whenever you login. The
MySQL database is also added and set to start automatically.




The MySQL Database Server engine is now installed.

Now create a PHP file to test your MySQL. Save this file as testmysql.php in the
htdocs folder


Note 1:

You can also install PHPMyAdmin and MySQL Control Center so that it’s
easier to work with Database and PHP files.

MySQL® Control Center v0.9.2
Site: http://www.mysql.com/products/mysqlcc/index.html
Downloads: http://www.mysql.com/downloads/mysqlcc.html
Filename: mysqlcc-0.9.2-win32.zip




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.              14
Installing MySQL Control Center




Extract the mysqlcc-0.9.4-win32.zip file and then run the setup.exe or mysqlcc.exe




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.                 15
Click next




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.   16
Select “I Accept” and click next




Click next again




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.   17
Select the place to install by clicking on browse or you can use the default location and
click next




Do not change the settings in this window. Click next!!!




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.                        18
Click next to install




Once installation is complete the following window will show and click Finish to exit.




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.                     19
A brief MySQL Control Center Tutorial
Source: http://newton.ncc.edu/~steve/mysqltutor/



                             A brief MySQL Control Center Tutorial



  When you first run MySQL Control Center you will be presented with the
  following "Register Server" dialog in which you fill out your connect info.

  "Name" can be anything, "Host Name" is gradient.ncc.edu, "User Name" is
your standard user name that you use on our network. Leave the "Password"
blank and click the option "Prompt for Password" instead. Click "Add" to save
                                  this info.




  Once you are done with the first dialog you will see gradient (or whatever
  you named the session) on the list of MySQL Servers on the left. Double
       click gradient and you will be presented with a password dialog.
CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.        20
 Once connected click the + sign next to the Databases folder to reveal the
 databases you have access to. You should work on the database that is the
same name as your user name. Double click the database to reveal the tables
                              in the database.




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.     21
 To create a new Table right click on "Tables" and choose "New Table" from
                                  the menu.




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.    22
You will be then presented with a screen to enter field names and their data
 type, remember to have a field that is chosen as a primary key, you can do
   this by clicking the field name and then clicking the "Add primary key"
  button on the toolbar. Then save the table by clicking the save button or
       closing the table which will prompt you to give the table a name.




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.      23
To start populating the table double click the table name on the left and you
 will be presented with a screen with the blank table. Right click on screen
                         and choose "Insert Record"




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.       24
   Once you have entered some data you can if you want start running SQL
            queries by clicking the "SQL" button on the toolbar.




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.       25
 Clicking the SQL button will present you will a window where you can write
 SQL queries and to execute the query click the button Execute button (has
                             a "!" symbol on it.)




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.     26
  If you ever have the need to go back and edit a Table's structure you can
    right click on the table and select "Edit table" from the popup menu.



                                                                                                    Tutorial by Steve O.
                                                                       To e-mail suggestions/additions: ochanis@ncc.edu




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.                                                27
An exercise example:

Now create a PHP file to test your MySQL. Save this file as testmysql.php in the
wwwroot folder

Put this HTML code in that file.

                                                   <html>
                                                   <body>
              <h1>Welcome to Apache,PHP/MySQL Test @ Group 13 - CS314</h1>
                                                      <?
                       $connection = mysql_connect("localhost","root","");
                                             if (!$connection){
                         echo mysql_errno().": ".mysql_error()."<br/>";
                                                     exit;
                                                       }
                                    if(mysql_select_db("TEST")){
                           echo("Database TEST already exists<br>");
                           mysql_query("DROP DATABASE TEST");
                               echo("Database TEST removed<br>");
                                                       }
                                   if (mysql_create_db("TEST")){
                                echo("Database TEST created<br>");
                                                       }
                            mysql_query("CREATE TABLE person (
                           id INT NOT NULL AUTO_INCREMENT,
                                         PRIMARY KEY (id),
                                      firstname VARCHAR(25),
                                      lastname VARCHAR(25))"
                                                      );
                         echo("Database TABLE person created<br>");
      mysql_query("INSERT INTO person (firstname, lastname) VALUES ('Ashika', 'Shandil')");
       mysql_query("INSERT INTO person (firstname, lastname) VALUES ('Alvin', 'Singh')");
       mysql_query("INSERT INTO person (firstname, lastname) VALUES ('Joshlyn', 'Deo')");
      mysql_query("INSERT INTO person (firstname, lastname) VALUES ('Pranish', 'Prasad')");
      mysql_query("INSERT INTO person (firstname, lastname) VALUES ('Prasheel', 'Singh')");
                           echo("TABLE person rows inserted<br>");
                                 echo("Retriving Rows<br><br>");
                                          //RETURN RESULT
                      $result = mysql_query ("SELECT * FROM person");
                            // fetch the current row into the array $row
                             while ($row = mysql_fetch_row($result))
                                                       {
                                  // print the values of the attributes
                         for ($i=0; $i<mysql_num_fields($result); $i++)
                                            echo $row[$i] . " ";
                                                echo "<br />";
                                                       }
                                               mysql_close();
                                                      ?>
                                 <p>&copy Group 13 - CS314</p>
                                                   </body>
                                                   </html>


CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.                          28
Open the web browser and put in the address

http://localhost/testmysql.php




If you see this page then you have integrated IIS with PHP and MySQL.




CS313 Software Engineering: IIS-PHP-MySQL basic configuration guide.    29

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:161
posted:2/24/2010
language:English
pages:29