Sunday, October 18, 2009

Configuring and Deploying PHP

Hi Friends.
Let’s get started. Since you are installing on a Windows computer, you will most likely be using IIS for a web server, however, it is not required. You must have some web server running however, and you are quite welcome to use Apache or another web server of your choice, however, since that falls outside the scope of this topic i will leave that discussion for another day.

Here i have used php-5.3.0-nts-Win32-VC9-x86.msi setup file for PHP and IIS for server.
You can install from this link.
Include Files:
  • PHPphp5isapi.dll
  • php5ts.dll

Some things to know about IIS:
IIS v5.1 is included with Windows 2000 Professional, and Windows XP Professional, but is not installed by default. (*note – IIS 5.1 is not included with XP Home edition and is not available as a stand alone download from Microsoft. If you are an XP Home user, you will need to look for an alternative web server solution.) Windows 2000 server includes IIS 5.1, and Windows 2003 server includes IIS 6.

If you haven’t already done so begin by installing IIS. To do this go to Control Panel Add/Remove Programs Add/Remove Windows Components. In the dialogue box that comes up, check the option for Internet Information Services(IIS) and click the “Details” button. Select any additional features that would like to have installed and click OK. Click OK again to begin the installation. This will install IIS and start the web server service automatically. You should not need to reboot. To test your installation open your web browser and type in http://localhost/ . This should bring up the default IIS page. If it does, your installation was a success and you can immediately get started on installing PHP.


PHP Installation & Settings:
The first step is to extract all of the files from the downloaded zip file or install the PHP setup into C:PHP (create the folder if it doesn’t already exist).
You may choose a different location, although it is not recommended. The path must NOT have spaces, for example, you cannot use C:Program FilesPHP. Some web servers may not be able to handle the path name and will fault. PHP 5 includes a CGI executable, a CLI executable as well as the server modules. The DLLs needed for these executables can be found in the root of the PHP folder (C:PHP). php5ts.dll needs to be available to the web server. To do this, you have 3 options:

1. Copy php5ts.dll to the web server’s directory (C:inetpubwwwroot).
2. Copy php5ts.dll to the Windows system directory (C:windowssystem32).
3. Add the PHP directory path to the environment variables PATH.

We will go with option 3, because we would like to keep all of our PHP install files in the same location, for easier cleanup later, if needed. Let’s proceed…

Instructions on how to put C:php in environment variables PATH:
First we want to open System Properties. There are two ways to get to System Properties. Either way will work.
1. Right-Click on My computer and choose “properties”.
2. Go to Control Panel, and select “System”.

Once here, we want to select the Advanced tab. In the Advanced tab, click the “Environment Variables” button. There are two sections in the Environment Variables window, User Variable and System Variables. We will be using System Variables. Scroll down in System Variables until you find the variable PATH. Highlight that line and the select Edit below the System Variables window. We will only be adding to the Variable Value. BE CAREFUL HERE. You do not want to delete anything on this line. Simply find the end of the line and add a semi-colon ( ; ) if there is not one already. After the semi-colon, type: C:PHP and then hit OK. Now click OK on the Environment Variables window. Finally click OK on the System Properties window and we are done with this part.

Now we must restart the computer to make the Environment Variables changes come into play. We cannot simply log off and log on, you must restart.

The next step is to set up a config file for PHP, php.ini. In C:PHP you will find two files named php.ini-dist and php.ini-recommended. We will use php.ini-recommended for this install, and all you need to do is rename it from php.ini-recommended to php.ini.

1. doc_root = C:inetpubwwwroot
2. cgi.force_redirect = 0

Now PHP is installed, lets move on to preparing our IIS to use PHP.

Configure IIS to use PHP:
1. Open IIS
2. Under Home Directory: Set “Execute Permissions” to “Scripts Only”
3. Click on configuration..
a. Click Add
b. Set “executable” to C:PHPphp5isapi.dll
c. Set “extension” to .php (don’t forget to include the . )
d. Click OK
e. Click Apply, then OK.

Under ISAPI Filters:
a. Click “Add”
b. Set Filter Name to PHP
c. Set Executable to C:PHPphp5isapi.dll
d. Click OK.
e. Click Apply, then OK.

Restart the Web Server
Now we want to test PHP on our system. To do this, we will create a file called phpinfo.php and it will be used to display all of the PHP info from our system in our web browser.

1. Open Notepad and type:
2. Save the file as phpinfo.php and select the file type ‘All Files’ (Important: do not save the file as .txt, as it will not work).
3. Move the file into C:inetpubwwwroot
4. Open your web browser and type: http://localhost/phpnfo.php
5. Your browser should display a lot of PHP information.

(Note: Store the files to C:\inetpub\wwwroot. If you have to store the files in a separate folder, then change the path in system variables.)

@Friends: Hope this helps you to install and configure PHP and IIS. All the best !

No comments:

Post a Comment