Installing PHP 5 on IIS in 5 simple steps

Categories:

2. Set Your Environment Variables

For this step we'll need to use the Windows GUI, so rather than just write out all the steps I'll use images to do most of the talking.

  • Right click on the My Computer icon and select the properties menu item. You should be presented with a window as shown below in figure 1. Select the Advanced tab and then click the Environment Variables button at the bottom.


Figure 1

  • Scroll through the System variables list at the bottom until you come to the path variable. Select it and then click the edit button as shown below in figure 2.


figure 2

  • Move to the end of the text in the Variable value field and type in the path to the PHP directory you created earlier in step 1 (e.g. D:\PHP). Make sure that there is a semi colon (;) separating the new value you're entering and the previous one, and also place another semi colon (;) after as shown below in figure 3. Once you have added the path click on the ok button to save it and return to the previous window.


figure 3

  • This time we need to create a new environment variable. From the Environment Variables window click on the New button towards the bottom as shown below in figure 4.


figure 4

  • You should now see the New System Variable window as shown below in figure 5. In the Variable name field type in PHPRC, and in the Variable value field type in the path to your PHP install directory (e.g D:\PHP) as shown below. Once done click the ok button to create and save the variable. This PHPRC variable tells Windows where to look for your php.ini file, and if it doesn't find it there or if this variable is not set then IIS will look though your Windows system path.


figure 5

Comments

Anonymous's picture

failed to open stream: No such file or directory in

Hi, i followed your guide and I installed fine (good guide), I can see the phpinfo.
but when i run my proyect i recieved

Warning: include(ayto_gestion/SqlFun.php) [function.include]: failed to open stream: No such file or directory in C:\Archivos de programa\PHP Designer 2005\webs\ayto_gestion\login.php on line 36

Warning: include() [function.include]: Failed opening 'ayto_gestion/SqlFun.php' for inclusion (include_path='.;C:\php5\pear:/docroot') in C:\Archivos de programa\PHP Designer 2005\webs\ayto_gestion\login.php on line 36

Fatal error: Class 'SqlFun' not found in C:\Archivos de programa\PHP Designer 2005\webs\ayto_gestion\login.php on line 37

Obviously i put these files in this direction, but i suppose i have to change anything in the php.ini could you help me?

Brashquido's picture

Glad the guide helped! First

Glad the guide helped! First thing to check will be your NTFS permissions. Ensure you IUSR account has read permissions to all your application directories and files. Using the incude() function will also mean you will need to add the directories which contain the files referenced by your include statement to the "include_path" directive in php.ini.
----------------
Dominic Ryan
3 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

Anonymous's picture

Hi again;

I set my route in include_pat (C:\Archivos de programa\PHP Designer 2005\webs), and I'm sure that i have permission because i use administrator, but i recieve the same.
I have read that i have to change doc_root and set the path, but it doesn´t work. You can see that it is a page for login, and after this I try to connect to mysql, could it be a problem?
sorry I'm very lost with it.

thank a lot.

Brashquido's picture

You have spaces in your

You have spaces in your path. Did you ensure you enclosed the path with ""? Sp the include_path would look something like;

include_path = "C:\Archivos de programa\PHP Designer 2005\webs"

----------------
Dominic Ryan
3 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

Anonymous's picture

thanks

thanks for your help...
It was bizarre, because I was using php 4, and when i upgrade to 5, the path sttoped working, so i added a "/", it started working again.
bye and good work

Anonymous's picture

First ,thanks for your tutorial,but for connecting to mysql ?

Hi,
Thanks for your help.
I used your guides and i can see information of phpinfo() function in my browser ,but when i want connect to mysql i receive this error :
Fatal error: Call to undefined function mysql_connect()
is there any help?
Thanks
Jamshid

Brashquido's picture

Is the MySQL extension loaded?

When using the phpinfo() function is the MySQL extension loaded?
----------------
Dominic Ryan
3 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster

Anonymous's picture

PHP IIS W2003 HTTP 500 Internal Server Error on subdirectories

I am getting the
HTTP 500 Internal Server Error
on tested working php scripts
in sub directories only !

They work fine in the root of the website.

PHP Version 5.2.5
Windows 2003 server
IIS

Permissions are the same in the sub directories.

Any ideas?

Cheers
Alex

Anonymous's picture

the page cannot be displayed

Hi,
After I carefully follow your instructions, still the page cannot be displayed. Im running at win xp, iis 5.1 with asp.net 2.0 installed. I try to install PHP 5.2.5

HTTP 403.1 Forbidden: Execute Access Forbidden
Internet Information Services

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

You have attempted to execute a CGI, ISAPI, or other executable program from a directory that does not allow programs to be executed.

Need your help. Thanks!

Mark

Brashquido's picture

PHP HTTP 500 error

Hi Alex,

Have you had a look through the article I wrote on troubleshooting the PHP HTTP 500 error?

Mark,

Can you look at the "home directory" tab in your IIS admin manager and let me know what your execute permission is set to?
----------------
Dominic Ryan
3 x Microsoft IIS MVP, MCSE, MCSA
IIS Aid owner/webmaster