944,091 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 3681
  • PHP RSS
Dec 3rd, 2005
0

Installation of PHP on Windows - Tutorial by Herong

Expand Post »
Introduction and Installation of PHP

Intro

This tutorial describes:

What is PHP.
Download PHP binary version for Windows.
Writing the first PHP script.
Installing PHP on IIS as CGI.
What Is PHP?

PHP stands for PHP: Hypertext Preprocessor, a recursive acronym. It is mainly a Web server side scripting language. But it can also be used for other purposes.

PHP was originally created by Rasmus Lerdorf in 1995 as a simple Web page generation tool named as PHP/FI (Personal Home Page/Forms Interpreter). Today it becomes the number one of server side scripting languages. Here is a comparison of number of matches on Google for key words: "PHP script", "Perl script", and "ASP script":
PHP Syntax (Toggle Plain Text)
  1. Key words Number of matches
  2.  
  3. PHP script 13,600,000
  4. Perl script 11,900,000
  5. ASP script 8,650,000

Downloading PHP 5.0.4 for Windows

1. Go to http://www.php.net, and download PHP 5.0.4 binary for Windows. You will get a file called php-5.0.4-Win32.zip of 7488 KB.

2. Unzip php-5.0.4-Win32.zip to \php directory.

3. Open a command window, and try the following commands:

PHP Syntax (Toggle Plain Text)
  1. >\php\php -v
  2. PHP 5.0.4 (cli) (built: Mar 31 2005 02:45:48)
  3. Copyright (c) 1997-2004 The PHP Group
  4. Zend Engine v2.0.4-dev, Copyright (c) 1998-2004 Zend Technologies
  5.  
  6. >\php\php-cgi -v
  7. PHP 5.0.4 (cgi-fcgi) (built: Mar 31 2005 02:45:43)
  8. Copyright (c) 1997-2004 The PHP Group
  9. Zend Engine v2.0.4-dev, Copyright (c) 1998-2004 Zend Technologies

Cool, both Command Line Interface (CLI) and Common Gateway Interface (CGI) are working!

My First PHP Script - Hello.php

Use any text editor, and enter the first PHP script, Hello.php:
PHP Syntax (Toggle Plain Text)
  1. Hello <?php echo "world!"; ?>

Let's run it PHP CLI first:
PHP Syntax (Toggle Plain Text)
  1. >\php\php Hello.php
  2. Hello world!

Now run it PHP CGI:
PHP Syntax (Toggle Plain Text)
  1. >\php\php-cgi Hello.php
  2. Content-type: text/html
  3. X-Powered-By: PHP/5.0.4
  4.  
  5. Hello world!

As expected, PHP CGI did generate the HTTP response header for me.

Installing PHP with IIS as CGI

1. Add \php to the PATH environment variable. I assume you know how to do this.

2. Set up PHP configuration file. First rename \php\php.ini-recommended to \php\php.ini. Then edit \php\php.ini to set the following values:
PHP Syntax (Toggle Plain Text)
  1. cgi.force_redirect = 0
  2. doc_root = "c:\inetpub\wwwroot"
  3. cgi.redirect_status_env = ENV_VAR_NAME

3. Create a new environment variable PHPRC with \php. This is needed to access php.ini.

4. Now we need to change IIS configuration to run PHP scripts as CGI scripts. Run Control Panel, Internet Information Service, Default Web Site, and Properties. On the Directory tab, first set Execute Permissions to "Scripts only". Then click Configuration to add a new Application Mapping with Executable=\php\php-cgi.exe, Extension=.php, and Script engine checked.

5. Stop and start Default Web Site.

6. Copy Hello.php to \inetpub\wwwroot.

7. Run Internet Explorer (IE) with http://localhost/Hello.php. You should see:
PHP Syntax (Toggle Plain Text)
  1. Hello world!

Congratulation, you have installed PHP with IIS as CGI correctly!

Conclusion

Installation PHP on Windows IIS as CGI seems to be simple.

Of course, you can also install PHP with IIS as a server module, using php5isapi.dll.

For additional installation instructions, please read \php\install.txt.
Last edited by happygeek; Oct 28th, 2006 at 11:13 am. Reason: Formatting
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mark1048 is offline Offline
12 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: hit another brick wall, mysql :S
Next Thread in PHP Forum Timeline: howto: expire cookie at end of session?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC