< PHP 3.5.2, Windows XP Pro SP2 and IIS 5.1 | Java & Friends  | PHP and PEAR/PECL on Windows XP Pro SP2 >


 

 

Running and Testing PHP Engine on Windows

 

 

What do we have in this session?

  1. Running PHP Commands from Windows Console

  2. Configuring IIS to Parse PHP files/extensions using FastCGI

  3. Testing the IIS Web Server with PHP Files

  4. Blank Web page Problem

  5. Working PHP Engine Example

 

 

 

 

Running PHP Commands from Windows Console

 

The following screenshots show running php on Windows command prompt.

 

Running php on Windows command prompt - php -h

Running php on Windows command prompt - php -i

 

For more readable version, you can redirect the output to a text file using the following command.

 

C:\>php -i > php_info_test.txt

 

Our PHP seems to be configured correctly. At least from configuration point of view and try running the following command.

 

C:\>php-cgi -v

 

This should print the PHP version if run from command prompt.

 

 

Configuring IIS to Parse PHP files/extensions using FastCGI

 

Next, let configure IIS so that it will recognize and parse any PHP files. Open IIS snap-in, select the Default Web Site > right-click mouse > select Properties menu. This task will sets up IIS to actually respond to requests for php files. Until now, IIS hadn't known what to do with php files, we just told it to pass them through php-cgi.exe (previously using the DLL. We have tested using php5isapi.dll however it failed!)

 

Invoking the Default Web Site property page

 

Select Home Directory tab and click Configuration button.

 

The Default Web Site property page of IIS - the Home Directory page

 

In the Mappings page, click Add button.

 

The Default Web Site property page of IIS - the Application Configuration page

 

Click the Browse button to select the DLL/EXE.

 

The Default Web Site property page of IIS - Adding the application extension mapping for .PHP

 

Select php-cgi.exe executable file and click Open button.

 

The Default Web Site property page of IIS - selecting the php-cgi executable for the .PHP mapping

 

In the Extension field, fill in .php for PHP file/extension and in Verbs group box, select Limit to: and type GET, POST, HEAD. You can select All Verbs which should tally with your needs. The GET, POST and HEAD verbs (HTTP methods) will give us the most basic functionalities. Click OK button.

 

The Default Web Site property page of IIS - a complete addition of the application extension mapping for .PHP parsing by IIS web server

 

Now, IIS should 'understand' file with PHP extension. Click OK button.

 

The Default Web Site property page of IIS - the .PHP file was mapped to be parsed by php-cgi.exe

 

Restart the IIS service.

 

The Default Web Site property page of IIS - restarting the IIS server and related services

 

Testing the IIS Web Server with PHP Files

 

Let test the PHP engine. Create an index.php file with the following code and save it in ANSI format.

 

<?php
phpinfo();
?>

 

Or the index.html file (with PHP code) with the following code.

 

<html>

<head>

<title>PHP Test Page</title>

</head>

<body>

<?php phpinfo(); ?>

</body>

</html>

 

<? phpinfo(); ?> doesn't work because short_open_tag parameter was off by default in php.ini.

 

Creating sample index.html and index.php test pages

 

Blank Webpage Problem

 

Open the page from Internet browser. Well, we have some problem with both IE and Firefox, an empty or blank page. Take note that the default first web page should be index.html in this case.

 

Testing the PHP code from Internet browser on IIS web server - blank page

------------------------------------------------------------

 

 

 

 

 

 

---------------------------------------------------------------------------

Testing the PHP code from Internet explorer (IE)r on IIS web server - also blank page

 

Let check the source.

 

Testing the PHP code from Internet browser on IIS web server - blank page - viewing the source page

 

The source was not stripped.

 

 

 

 

 

The index.html source file content was not stripped

 

Let check the World Wide Web Service (W3SVCx) log file.

 

Viewing the IIS log file for world wide web service

 

The returned code is 200 (200 means OK. The client request has succeeded) and this should be fine. Then, what is the problem?

 

The log file shows the index.html page was loaded successfully with 200 returned code

 

Let add the .html mapping to php-cgi executable in IIS so that the php-cgi can parse the html file. Repeat the previous steps and used .html as the extension instead of .php.

 

Adding another mapping to IIS

 

Use .html as the extension.

 

Adding the mapping so that the .HTML file also can be parsed by php-cgi.exe (PHP engine)

 

Now, php-cgi.exe can parse both .HTML and .PHP files. Click OK button.

 

The IIS web server application mapping for PHP and HTML files

 

Restart the IIS service.

 

Re-restarting the IIS web server

 

Re-check the default first web page.

 

VErifying that the first default web page to be served by IIS is index.html

 

Working PHP Engine Example

 

Reload the web page through Internet browser. Well, it works!

 

Loading the  PHP  page which extracting the PHP info (php -i) successfully using Firefox browser

 

Then, test the index.php file. It also works!

 

Loading the  PHP  page which extracting the PHP info (php -i) successfully using Internet Explorer browser

 

We can test the web page directly from IIS snap-in as shown in the following snapshot.

 

Reloading the web page from IIS Admin console

 

 

 


< PHP 3.5.2, Windows XP Pro SP2 and IIS 5.1 | Java & Friends  | PHP and PEAR/PECL on Windows XP Pro SP2 >