PHP5 and MySQL5 Installation Procedures by 43017A

VIEWS: 10 PAGES: 7

									                      PHP5 and MySQL5 Installation Procedures

                      PHP Installation/Testing/Troubleshooting

                                 Mark K. Jowett, Ph.D.

   1. Install IIS (when complete, you will see C:\Inetpub)
   2. http://us.php.net/manual/en/install.windows.manual.php
          a. http://www.php.net/downloads.php
          b. Windows Binaries: PHP 5.2.10 zip package [10,242Kb] - 18 June 2009
              (currently)
          c. Choose a mirror site - United States:
                   i. us.php.net NEXCESS.NET
                  ii. us2.php.net Hurricane Electric
                 iii. us3.php.net Tier Four Colocation
                 iv. www.php.net Yahoo! Inc.

***NOTE: If you are installing PHP 5, extract to C:\php.

   3. Now to install PHP5. Open the zip file & Extract all your files to C:\php\
   4. The next step is to set up a valid configuration file for PHP (php.ini). Some of these
      steps require deleting comments (;).
         a. Make a copy of php.ini-recommended, and change the name to php.ini
         b. Uncomment cgi.force_redirect in php.ini and set it to cgi.force_redirect = 0
             *** This is an important step.***
         c. Install a browscap.ini file. It's fairly straightforward: download
             php_browscap.ini from http://browsers.garykeith.com/downloads.asp,
             change the name to browscap.ini, and save it in the extras folder under
             your PHP install folder (c:\php\extras\browscap.ini), uncomment and
             change the browscap variable in php.ini to be the full path to the file
             (browscap="c:\php\extras\browscap.ini"). Also, be sure to abide by his
             Terms of Use.
         d. Create a session state folder and point the session.save_path php.ini variable
             to it. PHP does not need sessions, but it's something that will most likely be
             useful. Create a session folder w/in the php directory, C:\php\sessions.
             This folder will hold many small files with session variable information for
             PHP. They probably won't take up a whole lot of room, but if you need to
             keep your data off your system drive, then you can put the folder anywhere
             else. Now change the value of the session.save_path variable in php.ini to be
             the full path to that folder. Change session.save_path = "/tmp" to
             session.save_path = "c:\php\sessions"
         e. extension_dir = "c:\php\ext"
         f. doc_root ="c:\inetpub\wwwroot"




                                             1
      g. Uncomment the following extensions. That is, take the semicolon out (;) at
         the beginning of the statement, to have an extension loaded automatically:
              i. extension=php_mysql.dll
             ii. extension=php_mysqli.dll
            iii. extension=php_pdo.dll
            iv. extension=php_pdo_mysql.dll
             v. extension=php_mssql.dll
            vi. extension=php_pdo_mssql.dll

               ***NOTE:

               extension=php_mysql.dll // (older) mysql_xxx interface

               extension=php_mysqli.dll // (newer) mysqli_xxx objects

               extension=php_pdo_mysql.dll // (newest) PDO interface for MySQL

               extension=php_pdo.dll // also required for PDO

               extension=php_mssql.dll // required for MS SQL

               extension=php_pdo_mssql.dll // PDO interface for MS SQL

               The last extension, PHP Data Objects, is an abstraction layer for data
               access. It's relatively new, so you probably won't see much existing
               code using it. Most sites use the mysql_xxx interface, while there are
               some going to the mysqli_interface. The interfaces are quite
               compatible—that is, you can load all of them and select whichever one
               you want to use in your code. Also see,
               http://us3.php.net/install.windows.extensions

5.  Add "c:\php" to the server's PATH environment variable
      a. right-click on My Computer, choose Properties
      b. flip to the Advanced tab
      c. click the Environment Variables button
      d. Double-click the Path variable in the list of System variables.
      e. Add " c:\php;" (sans quotes, but WITH the semicolon) at the beginning of the
          variable value, and no space after it.
      f. The new PATH will be available to any new command prompt, but not to
          existing ones—in other words, you will have to close, then reopen a command
          prompt.
6. Create a PHPRC environment variable, and add "c:\php" as its variable value
   (See above. Though here, there is no need for a semicolon, as it is the only value.)




                                         2
7.   Add PHP ISAPI extension (c:\php\php5isapi.dll). NOTE: There are two ways to
    setup PHP for the web: ISAPI and CGI. ISAPI is typically more efficient and
    secure. (double-check 5.3 CGI support only)
       a. Load IIS Manager: Start -> Control Panel ->Administrative Tools -> Internet
            Information Services (IIS Manager)
       b. Expand local computer
       c. Right-click on Default Web Site, or the Web site to which you want to add a
            filter, and then click Properties
       d. Select ISAPI Filters tab
       e. Click the "Add..." button and enter "php" (no quotes) as the "Extension
            name:"
       f. And, c:\php\php5isapi.dll as “Executable:” Or, browse to the php5isapi.dll file
            in your PHP install folder
       g. Click Apply (forget about priority and status for now). DO NOT CLICK OK,
            yet.
       h. Click the Documents tab. Click Add… Enter index.php as the “Default
            Document Name:”
       i. NOW, click Ok.
8. Add new extension (.php). This sets up IIS to actually respond to requests for
    php files. Until now, IIS does not know what to do with php files, other than to pass
    them through php5isapi.dll. This step is similar to Step 7.
       a. Load IIS Manager: Start -> Control Panel ->Administrative Tools -> Internet
            Information Services (IIS Manager)
       b. Expand the local computer in the left pane
       c. Right-click on “Default Web Site” in the left pane, then click "Properties" in
            the menu that pops up
       d. Tab to the "Home Directory"
       e. Click "Configuration…"
       f. Click "Add..."
       g. Enter the full path to php5isapi.dll in the "Executable" textbox (see Step 7).
            (Browse... to find it more easily if you need to)
       h. Enter ".php" in the "Extension" textbox (don’t forget the period (.), that is
            .php).
       i. In “Verbs,” select "Limit to", enter "GET,HEAD,POST,TRACE" w/no quotes.
            Check “Script Engine,” and check “Check that file exists.”
       j. Click "OK" all the way out. This will apply to every website.
9. Create folder w/in IIS Web server: C:\Inetpub\wwwroot\php
10. Create index.php file w/in php directory using the following code:




                                          3
<?php

 // testing sessions

 // check to see if files are being created

 // in the session.save_path folder

 session_start();

?>

<html>

 <head>

     <title>PHP Test</title>

 </head>

 <body>

     <p>

      The browser you're using is

      <?php echo $_SERVER['HTTP_USER_AGENT']; ?>

     </p>

     <p>

      <!-- test the browscap setup -->

      Your browser's capabilities are: <br/>

      <pre>

       <?php print_r(get_browser(null, true)); ?>

      </pre>

     </p>

     <?php phpinfo(); ?>

 </body>

</html>

Test index.php by typing http://127.0.0.1/php/ into your browser’s address box.


                                              4
After loading index.php, you should see unformatted information about your browser at
the top of the page (if the browscap support was properly configured above), followed
by preconfigured formatted information about your PHP installation. Be sure to scroll all
the way down to the bottom to see that there were no errors. There were some online
support blogs noting that installations using the CGI configuration instead of ISAPI did
not load several modules, and error messages would print at the bottom of the test page
(index.php).

Also go check your session folder (if you setup session support) for a 0-byte file. That's
the file to hold session data for the session you started by using the command
session_start(). You may delete these when you are no longer accessing any pages.

Troubleshooting:

   1. CAREFULLY go back and review the previously detailed 10 steps.
   2. Here’s how to stop/start the server to retest server-side scripted pages:
         a. Load IIS Manager: Start -> Control Panel ->Administrative Tools ->
             Internet Information Services (IIS Manager)
         b. Expand local computer
         c. Left-click on Default Web Site, click the stop/start buttons at the top of
             the window
         d. Click Stop then refresh your .php page. In IE, you should see “Internet
             Explorer cannot display the webpage”
         e. Now, click Start, and refresh your .php page. It should display.
   3. One way to test extension loading is to run PHP from the command line (Start ->
      Run -> type "cmd" and hit Enter). Type "php" and see if any errors appear.
      Comment out the offending extension in the php.ini file and repeat.
         a. If there are no errors, a blank line will appear after “php”
         b. To terminate the php command, type Ctrl + Pause/Break
         c. To exit out of the command line interface, type exit
   4. Do some Google-sleuthing!




                                           5
***Lastly, AFTER MySQL Install verify PHP and MySQL integration:

Displayed in index.php: http://127.0.0.1/php/

<? if(function_exists("mysql_connect")) echo "MySQL is present."; ?>




                                                6
                         Testing MySQL and PHP

Create MySQLInfo.php file w/in php directory using the following code:




                                  7

								
To top