Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > PHP

Reply
 
LinkBack Thread Tools Display Modes
Old 08-24-2005, 09:35 PM   #1 (permalink)
smckittr
Scott
 
Join Date: Aug 2005
Posts: 29
smckittr is on a distinguished road
Php on home computer

WHat do I need to do to be able to test my php files on my home computer. I still want it to work normally, just with the added ability of reading php files.
I have windows 2k.
Thanks
Scott
smckittr is offline   Reply With Quote
Old 08-24-2005, 11:02 PM   #2 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 598
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
You need to download a copy of apache and mod_php for windows, and then preview the files by ponting your browser at local host instead of clicking on them.
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 08-25-2005, 03:47 AM   #3 (permalink)
markj
Registered User
 
markj's Avatar
 
Join Date: Jan 2003
Location: Wales, UK
Posts: 2
markj is on a distinguished road
Send a message via AIM to markj Send a message via MSN to markj Send a message via Yahoo to markj
The easiest way to do it is to install this http://www.wampserver.com It installs apache, php, mysql and phpMyAdmin for you.
markj is offline   Reply With Quote
Old 08-25-2005, 08:22 AM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,529
sde is on a distinguished road
i think the easiest, no non-sense way is to use IIS (windows' native web server) & PHP if it is windows based. i configure/re-configure IIS nearly everyday switching between PHP versions for work.

the only reason not to is if you want to use Apache features.

question: do you want to install mysql too? you just mentioned PHP.

i will post instructions a little later. i need to get to work.
__________________
Mike
sde is offline   Reply With Quote
Old 08-25-2005, 09:59 AM   #5 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,529
sde is on a distinguished road
Ok, you could try to just install IIS ( as instructed below ) and download the installer version of PHP. It might work, but below is detailed instructions on how to configure everything manually.

If you do choose to do the installer, and something doesn't work, just go down this list and make sure all these settings are configured correctly.

This write-up turned out longer than I anticipated. Should be helpful for someone in the future though.

Prepare PHP

1. Download PHP ( i recommend PHP5 if you don't have any reason to use PHP4 ). Get the Zip package and not the installer.

2. Extract the files to your hard drive to C:\PHP5\ .

3. rename C:\PHP5\php.ini-recommended to php.ini


Configure IIS

1. Install IIS if it hasn't been installed already. start->control panel->add/remove programs->windows components->Internet Information Services (IIS). You will probably need your win2k disk.

2. Open your website properties:
- start->control panel->administration tools->internet information services
- expand the tree on the left till you see Default Website
- Right click on Default Website and left click on Properties

3. Select the home directory tab. Here you can browse to the directory where your web files will be stored.

4. Map your php executable to the .php extension
- Click Configure
- Click Add
- Browse to C:\PHP5\php-cgi.exe
- All verbs and Script Engine Checked
- Press OK and Press OK again.

(we should now be back on the default web site properties page)

5. Setup index.php as a defult page.
-Click Documents
- Click Add
- enter index.php
- Press OK and Press OK again.

6. Restart IIS
- start->run
- type: cmd and press enter.
(you should now see the command prompt)
- type: iisreset and press enter
- close command prompt

.... take a breath, almost there.

Add the PHP path to your PATH environment variable

This step is really optional, but if you don't do it, you need to copy your php.ini file to your C:\WINDOWS ( or WINNT ) directory. I like to keep all my PHP stuff in the same place, so I do it this way.

1. start-> (right click on my computer and left click on properties)
2. Click the Advanced tab.
3. Click the Environment Variables button.
4. in the bottom on System Variables click on Path and click Edit
5. at the end of the variable value add C:\PHP5; (make sure there is a semi colon before your entry and the last path.
6. press OK and press OK again.




Configure Permissions

At this point, the only thing that would prevent PHP from working is the internet user on your local machine not having permissions to access the C:\PHP5 directory. For this next step you need to know the internet user's name on your computer. Usually it's iusr_<COMPUTER NAME>.

1. Open windows explorer. right click start, left click explorer
2. Right Click C:\PHP5 and Left Click Properties
3. Click the Security Tab.
4. Click Add
5. Type in the internet user's name and press OK
6. Click on this user and give them Read & Execute permissions.
7. Press OK.

.. now the fun part. let's test PHP
open your favorite text editor copy/paste this text:
PHP Code:
<?php
phpinfo
();
?>
Save the file as phpinfo.php in your web directory ( remember, from the IIS configuration )

now open your favorite browser and type in: http://localhost/phpinfo.php

If you followed or verified that all the steps I went through are correct, then you should have no problem seeing a nice long page with all the PHP settings.
__________________
Mike
sde is offline   Reply With Quote
Old 08-25-2005, 11:51 AM   #6 (permalink)
smckittr
Scott
 
Join Date: Aug 2005
Posts: 29
smckittr is on a distinguished road
Thanks for all the info guys.
sde,
on step 3 of configure iss, i do go to the directory that the pages will be stored in right? Just want to make sure.
And yes i would like mysql. I forgot to mention that.
thanks
Scott
smckittr is offline   Reply With Quote
Old 08-25-2005, 12:03 PM   #7 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,529
sde is on a distinguished road
correct.. if you select: c:\www

then you would put your phpinfo.php ( or any php or html file you wanted to view ) file in c:\www

and you would access it in the browser by typing: http://localhost/phpinfo.php
__________________
Mike
sde is offline   Reply With Quote
Old 08-25-2005, 12:08 PM   #8 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,529
sde is on a distinguished road
ok, for mysql:

download and install mysql from here: http://dev.mysql.com/downloads/

to setup mysql support for PHP, you will need to modify your php.ini file. ( C:\PHP5\php.ini )

1. un-comment the php_mysql.dll extension.

find: ;extension=php_mysql.dll and delete the semi-colon at the beginning: extension=php_mysql.dll

2. set your php extension dir in the same file
; Directory in which the loadable extensions (modules) reside.
extension_dir = "C:\PHP5\ext"


note: anytime you modify the php.ini file, you will need to restart IIS. ( by opening the command prompt and typeing iisreset as i posted above.
__________________
Mike
sde is offline   Reply With Quote
Old 08-25-2005, 12:11 PM   #9 (permalink)
smckittr
Scott
 
Join Date: Aug 2005
Posts: 29
smckittr is on a distinguished road
Ok, will do.
Thanks very much
Scott
smckittr is offline   Reply With Quote
Old 08-25-2005, 12:12 PM   #10 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,529
sde is on a distinguished road
** i added step 2 to the mysql instructions.
__________________
Mike
sde is offline   Reply With Quote
Old 08-25-2005, 12:37 PM   #11 (permalink)
smckittr
Scott
 
Join Date: Aug 2005
Posts: 29
smckittr is on a distinguished road
I did everything as you said but when i go to http://localhost/phpinfo.php i get this:
Code:
<p>This PHP CGI binary was compiled with force-cgi-redirect enabled.  This
means that a page will only be served up if the REDIRECT_STATUS CGI variable is
set, e.g. via an Apache Action directive.</p>
<p>For more information as to <i>why</i> this behaviour exists, see the <a href="http://php.net/security.cgi-bin">manual page for CGI security</a>.</p>
<p>For more information about changing this behaviour or re-enabling this webserver,
consult the installation file that came with this distribution, or visit 
<a href="http://php.net/install.windows">the manual page</a>.</p>
and if i just access http://localhost/ i get access denied, not authorized

thanks
Scott
smckittr is offline   Reply With Quote
Old 08-25-2005, 12:50 PM   #12 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,529
sde is on a distinguished road
oops.. close.

in php.ini, look for this area
Quote:
; cgi.force_redirect is necessary to provide security running PHP as a CGI under
; most web servers. Left undefined, PHP turns this on by default. You can
; turn it off here AT YOUR OWN RISK
; **You CAN safely turn this off for IIS, in fact, you MUST.**
; cgi.force_redirect = 1
you need to uncomment the cgi.force_redirect line and make it = 0

cgi.force_redirect = 0

then restart iis .. let me know if it works.
__________________
Mike
sde is offline   Reply With Quote
Old 08-25-2005, 12:51 PM   #13 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,529
sde is on a distinguished road
getting access deined when trying to access: http://localhost is expected if you don't have a page that is in your default list in that directory. ( i.e. index.php index.htm etc.. )

there is an IIS setting to allow directory browsing if you wanted to be able to view items in a directory. i think it's in the security tab of the properties area .. but i would definately not recommend it for a public site.
__________________
Mike
sde is offline   Reply With Quote
Old 08-25-2005, 01:00 PM   #14 (permalink)
smckittr
Scott
 
Join Date: Aug 2005
Posts: 29
smckittr is on a distinguished road
now i get a error code 500 and a page cannot be displayed page. says it's due to an internal server error
thanks
scott
smckittr is offline   Reply With Quote
Old 08-25-2005, 01:02 PM   #15 (permalink)
smckittr
Scott
 
Join Date: Aug 2005
Posts: 29
smckittr is on a distinguished road
fixed that but i'm getting the same page as before i did the cgi.force_redirect thing. i'll check the php.ini file again
smckittr is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP 5.0.4 and 4.3.11 Released sde Code Newbie News 0 04-20-2005 11:56 AM
PHP vs .NET Redline Lounge 1 11-24-2004 07:10 AM
PHP Comes of Age sde Code Newbie News 0 04-14-2004 12:41 PM
I need to learn PHP Nitro PHP 9 06-28-2003 12:24 PM


All times are GMT -8. The time now is 02:21 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting