Jul 20, 2008

Running Php Web Scripts On A Local Machine

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

Running Php Web Scripts On A Local Machine

switch
hi all

I'm VERY new to PHP and I'm having a slight problem... I want to be able to run PHP scripts on my computer without installing a web browser. Let's say I have this code....

myScript.php
CODE

<HTML>
  <HEAD>
    <TITLE>PHP Example</TITLE>
  </HEAD>
  <BODY>
[color=#009900]    <?php
      print "This is an awesome scripting example.";
    ?>[/color]
  </BODY>
</HTML>


ok. if I open this with Firefox or IE or any other Browser, I will get a blank document titled "PHP Example". I know that this is because the browser simply ignores the script between the <? tags.
So, what I want to do, is find a way to run/execute 'myScript.php' and open the result in a browser.

I tried using the php-cgi.exe program included in the download from the PHP website, running the script with that, then copy-pasting the output into an HTML file and opening that in the Browser, but the problem is, for really long output, the console clips off the earliest part of the output.

So yeah, If anyone has any ideas I would be greatly appreciative to hear them.

Thanks alot!

 

 

 


Reply

BuffaloHELP
Please search the forum and you'll find Set Up Own Hosting for an idea how to run php scripts in your own pc.

I had the same question and I recently completed this task. You have to install Apache and PHP in your system to run php scripts in your local computer. Even though you're not running a web server from your computer, PHP only works if a webserver is set to your system. Read Apache installation procedure and add these lines at the end of httd.txt
QUOTE
LoadModule php5_module "c:\php\php5apache2.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:\php"
Again, instructions are on Apache's site.

Then install PHP and follow the php.net Apache installation documentation. And then restart your computer.

I originally installed IIS instead of Apache on my laptop but it did not work well. I guess fooling XP Home to install IIS (which is not possible but I hacked it to work it) caused more trouble than installing Apache. Apache installation was smooth and it worked right away.

PHP installation was bit tricky but if you take the time to read the documentation, you'll get it right away.

Finally, running your php script will be http://localhost/*directory/script_in_php where *directory is optional.

 

 

 


Reply

Tyssen
You need to set up your machine to run as a web server. If you've got XP Pro, you can do it under IIS - just add your script to a folder in Inetpub/wwwroot/ and then in your browser go to http://localhost/nameOfTheFolder/nameOfFile.php. (If IIS isn't already installed, go to Control Panel/Add Remove Programs/Add Windows Components.)
Alternatively, you can download something like XAMPP and install PHP, Apache and MySQL on your machine.
Edit: BuffaloHelp beat me to it.

Reply

DeveloperX
I understand your problem.
You must install any webserver software with cgi support.

For example: Apache, IIS and other...

As for me, I use Apache 2 webserver software for execute my scripts on my local computer.

Apache webserver software you can download at http://www.apache.org.
And IIS you can install from Windows 2000/XP/2003 installation disk in Control Panel/Add or Remove Software section.

After installation of any webserver software you must config it to execute php scripts.

For example: Apache - in configuration file in Conf directory; IIS - in special settings dialogs in Control Panel of Windows.

This is very real way to running php scripts locally.
And your php-html output on your computer will be such as on your hosting server where installed Apache (*nix based hosting) or IIS (Windows based hosting)

For executing your 'myScript.php' you must put it into special webserver directory:
/inetpub/www/ - IIS
/Apache/htdocs/ - Apache.

And type in your browser address bar url like:
http://localhost/myScript.php
or
http://127.0.0.1/myScript.php

After it press Enter and your script will load in your browser like on your webhosting server.

Good luck!

Reply

switch
thanks alot guys. sorry it took me a while to get back to ya.
i'll see if it works, as an inbetween, i've been using PHP designer, which has an interface that can do the basics. actually it's great software. if you're interested, check it out: www.mpsoftware.dk.

thanks again guys, all the best.

Reply

masugidsk8r
QUOTE(switch @ Apr 23 2006, 11:19 PM) *
hi all

I'm VERY new to PHP and I'm having a slight problem... I want to be able to run PHP scripts on my computer without installing a web browser. Let's say I have this code....

myScript.php
CODE
<HTML>
  <HEAD>
    <TITLE>PHP Example</TITLE>
  </HEAD>
  <BODY>
[color=#009900]    <?php
      print "This is an awesome scripting example.";
    ?>[/color]
  </BODY>
</HTML>


ok. if I open this with Firefox or IE or any other Browser, I will get a blank document titled "PHP Example". I know that this is because the browser simply ignores the script between the <? tags.
So, what I want to do, is find a way to run/execute 'myScript.php' and open the result in a browser.

I tried using the php-cgi.exe program included in the download from the PHP website, running the script with that, then copy-pasting the output into an HTML file and opening that in the Browser, but the problem is, for really long output, the console clips off the earliest part of the output.

So yeah, If anyone has any ideas I would be greatly appreciative to hear them.

Thanks alot!


Yo man, here's the link to a web server called XAMPP. http://www.apachefriends.org/download.php?...0-installer.exe

Install it and paste all your php files under XAMPP directory's "htdocs". Then, you should run XAMPP services -Apache- and -mySQL-
Lastly, you should link to your page using "http://localhost/yourpage.php"

Reply

cwconline
QUOTE(switch @ Apr 23 2006, 11:19 PM) *
hi all

I'm VERY new to PHP and I'm having a slight problem... I want to be able to run PHP scripts on my computer without installing a web browser. Let's say I have this code....

myScript.php
CODE
<HTML>
  <HEAD>
    <TITLE>PHP Example</TITLE>
  </HEAD>
  <BODY>
[color=#009900]    <?php
      print "This is an awesome scripting example.";
    ?>[/color]
  </BODY>
</HTML>


ok. if I open this with Firefox or IE or any other Browser, I will get a blank document titled "PHP Example". I know that this is because the browser simply ignores the script between the <? tags.
So, what I want to do, is find a way to run/execute 'myScript.php' and open the result in a browser.

I tried using the php-cgi.exe program included in the download from the PHP website, running the script with that, then copy-pasting the output into an HTML file and opening that in the Browser, but the problem is, for really long output, the console clips off the earliest part of the output.

So yeah, If anyone has any ideas I would be greatly appreciative to hear them.

Thanks alot!


Hi Guy... firt of all print is a CGI function you need to use echo instead of print... also you need to download a php apache program which should be installed in
C:/PHP or such... secondly you need to get you a PHP editor like DzSoft Dreamweaver doesnt work even though you can edit it and such...

ok man hope this helps at all

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. php on local computer - 11.12 hr back. (1)
  2. test php script on computer - 16.24 hr back. (1)
  3. php not executing on local server - 20.82 hr back. (1)
  4. run php on local machine - 21.25 hr back. (1)
  5. run php local machine - 26.53 hr back. (2)
  6. testing php script on local xp - 34.09 hr back. (1)
  7. test php script on local machine - 33.91 hr back. (2)
  8. running php scripts on a local computer - 38.57 hr back. (1)
  9. test php on a local machine - 45.27 hr back. (1)
  10. how to run a php file on my local machine - 45.66 hr back. (1)
  11. running website on local machine - 46.56 hr back. (1)
  12. getting ip of local machine php - 47.88 hr back. (1)
Similar Topics

Keywords : running php web scripts local

  1. Parse: Error Unexpected T_lnumber - php parse error when running script (4)
    Hi. I've just created a php script. The main object of the script is to delete some old files
    and replace it with a new file with some new content, effectively moving the contents from one file
    to another. These are the first 50 lines of the file: /* Calculate For The "A" Group - The
    Latest Games ID */ $a_B = 002; while(file_exists("a_" . $a_B . ".dat")) {
    $a_B++; } $new_page_contents = " " . $_POST . " " . $_POST . "
    include \"/home/cmatcme/public_html/footer.php\"; ?> "; $a_stream = fopen(&...
  2. Releasing Wap/php Scripts? - (3)
    I have created two great scripts one a wap download/ftp-upload script, the other a wapCHAT. How can
    i stop them removing my copyright?...
  3. Downloading Scripts - scripts need (2)
  4. I Need Free Scripts - PhP or ASP (21)
    I need some where i can get Ip traking system, Autosurf or Autotraffic, and such other challenging
    scripts. Where can I get them ? i saw some in Hotscripts.com. /blink.gif' border='0'
    style='vertical-align:middle' alt='blink.gif' /> /unsure.gif' border='0'
    style='vertical-align:middle' alt='unsure.gif' /> ...
  5. Good Scripts - post Good Scripts name here (10)
    Hi dears I want make good sciprs list here i need your help , plz post good scripts name here i
    know vb , IPB , PHPnuke, Postnuke, phpbb , Xoops, mambo , wordpress plz post all kind of php
    scripts here like upload manager , file manager , image manager , blog manager , time , date ,
    portal , shoping manager , forum , shoutbox , chat , adv , counter , topsite , download area ,
    upload area , Calculators , Auctions script , Multi-Level Marketing script , Click Tracking , News
    Publishing script , blogs , Polls and Voting script , Database script (like phpmyadmin) , Search...
  6. Scripts - For Hosting (5)
    Does anybody knows where I can obtain scripts for opening my own hosting provider web-site?...
  7. Wamp Packages Needed To Test Scripts - Set up Apache, PHP, etc on your machine (1)
    In order to test php scripts on your localhost machine, you require a system that includes php
    parsing. A WAMP set-up 'usually' includes a database server, and a database manager, too.
    For Windows machines, theses are usually referred to as WAMP because they include Apache, Mysql, and
    PHP for Windows, hence the acronym WAMP. Wikipedia has a listing of the available packages with
    details about the included versions and often a link to the wikipedia article describing them. The
    list can be found at http://en.wikipedia.org/wiki/Comparison_of_WAMPs Personally, I...
  8. Themed Scripts (weekly) - the theme changes each week (0)
    ok the way this is gonna work is ... from monday to saturday you will be asking for scripts that go
    along with the theme... then on sunday every one will vote on a new theme for the next week... any
    one can ask for a script... any one can post a script... the script DOESN'T NECESSARILY NEED
    TO BE ASKED FOR inorder for you to post it... just make sure it goes along with the theme... or you
    will loose all respect /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0"
    alt="biggrin.gif" /> any ways this weeks theme is SECURITY So for the fir...
  9. Php Scripts Free For Every One - list of the best php scripts sites (12)
    so what's you favourites php scripts sites? mine are : 1- hotscript 2- phpbuilder 3-
    developershed 4- internet so what's yours? /biggrin.gif" style="vertical-align:middle"
    emoid=":D" border="0" alt="biggrin.gif" />...
  10. Phpbb Customization? - wappy is not so great with web scripts :-) (7)
    ok i feel a little silly posting this as im sure the answers are simple but im really not used to
    working with pre-made web scripts that have so many files: Q1. I have added a real cool army theme
    to my phpBB with a matching smiley set and its looking good, i also have the matching rank icons but
    where on earth do i upload them in the script? Q2. Which file in my template/style/script do i need
    to edit to place some extra links at the bottom of my index page, for example a link back to my main
    site or some link exchange links/web partners?...
  11. Papular Wap Scripts 4 Your Sites - collection of WAP scripts (3)
    Redirect script webbrowser from wap to web and wapbrowser from web to wap. CODE <?
    $htmlredirect = "http://kralj.frih.net"; $wmlredirect =
    "http://kralj.r8.org";
    if(strpos(strtoupper($HTTP_ACCEPT),"VND.WAP.WML") > 0){
    header("Location: ".$wmlredirect);} else{ header("Location:
    ".$htmlredirect); exit;} ?>
    ================================================================== Graphic counter. !!!
    Dont forget to create count...
  12. How Do Scripts Select To Be Placed In Fantastico - Question (2)
    hi all i write famp3 in hotscripts. i want continue next version of this script or an other but i
    have one question How do Scripts Select To be placed in fantastic ? cpanel search in scripts website
    and Select ? or cpanel choise top rate scripts ? some scripts is new and they are not popular !
    if my script take top rate or popular cpanel choise it for fantastic or not ? my next Question is
    fantastic 2 is true or not ? somewhere i heard fantastic 2 or hot fantastic ! is it true ?
    thanks all /smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="sm...
  13. Free Web Forum Scripts? - Question on web forum scripts (7)
    Can someone please tell me which of the free forum scripts is the best and why? I like these forums
    but i notice the script is not free lol ;-)...
  14. Uploading From Url - any scripts? (9)
    Is there any scripts that allows user to upload files from a certain url to your server?...
  15. Php, Some Easy Scripts - Just wanted to say i learned alot (3)
    Yo fella's i made some easy to use php scripts. If you need a specific script you can always
    ask me. /laugh.gif' border='0' style='vertical-align:middle' alt='laugh.gif' /> Sry i made
    them in dutch but i will translate them /rolleyes.gif' border='0' style='vertical-align:middle'
    alt='rolleyes.gif' /> ...
  16. Running Php And Asp On The Same Machine - how to? (4)
    hello dudes, i was asking me if i can install and run php and asp on the same machine and how to do
    that, i'm migrating to asp.net but actually i need to test some php files, but i installed
    recently asp.net and don't know how to run my old php files, so i will be grateful if someone
    tells me how. thanks in advance!...
  17. Good Free Php Scripts - (10)
    Hi I found this nice script here descriptions: An automated script submission tool would be
    great, but because every script directory's submission process is so unique, automation is
    nearly impossible. So we built Script Promotion Wizard, a free tool you can add to your web site or
    use on a local server that will help you manage script promotion to script directories. With Script
    Promotion Wizard, you can save script profiles, and add addition script directories as you learn
    about them. The script is very easy to install and use, is completely free and contai...
  18. Password Strength / User Availablity Scripts ? - (2)
    many of u guys would already have noticed that now a days , on most of the websites , when some one
    sign in...as he puts his desired username in the textbox , the page shows that it is not available
    or it is available...without pushing any button etc.. and the second thing , when some one writes
    the password , on the same screen , it shows that password is weak or password is strong... i think
    it is done with php ... can some one give me a link to any page where i can access these scripts ?
    or some one can help me regarding this ?? Thanks for helping always....
  19. Php Error When Running Script - Php error when running script (3)
    Hello, I get the following error: Parse error: syntax error, unexpected T_STRING in
    /usr/local/psa/home/vhosts/club-amigos.co.uk/httpdocs/contact.php on line 44 when l run the
    following script: Any help would be appreciated. CODE <?php /* PHP Form Mailer -
    phpFormMailer v2.1, last updated 30th Nov 2005 - check back often for updates! (easy to use
    and more secure than many cgi form mailers) FREE from: www.TheDemoSite.co.uk Should work
    fine on most Unix/Linux platforms */ // ------- three variables you MUST change below
    -------------...
  20. Query Not Running When Submitting A Form - (3)
    Im having trouble getting my PHP to work. Basically i have a form with a button linking to a php
    file. When i click submit it calls this file and is suppost to add the data to a database. Im using
    a my sql databse and it connects fine. Unfortunately when i click submit all i get is the
    "Inspection did not add". From this i know i have made a connection with the database and im
    absolutely 100% sure that all field names are correct on the forms and database. Any ideas? Heres
    the script.... PHP Code: CODE <html> <head> <meta http-equiv="C...
  21. Need Scripts For Testing Server's Limitation - (6)
    There are lots of web hosting provider and some of them are free. How can you know what problem
    your PHP scripts would involved in when you get a web hosting which supports PHP. I have found 2
    problems. One is about the function mail(), the other is about safe mode. Of course, there may be
    others problems, I hope someone can adds the problem in this thread for more detail discussion. The
    first question is how I can know the function mail() work properly. If you use function mail() in
    your PHP scripts, error message may be shown if the server does not support sendmail....
  22. Executing Scripts Without Include() Function - php function to execute a script w/o showing html markup (3)
    Hi guys. I have another newbish PHP question. /laugh.gif' border='0' style='vertical-align:middle'
    alt='laugh.gif' /> Today, I decided to make a new navigation bar for my site. It doesn't look
    good because I just started learning Flash today, so I was basically feeling my way around the
    application. Anyways, if you use Flash and you try to validate your site at http://w3.validator.org
    , you get a lot of errors for some weird reason. So I was thinking about separating the markup for
    embed Flash from the rest of the site's source code. The problem with that i...
  23. Php Scripts - (2)
    Hwo nows, when can i get free php scripts? /rolleyes.gif' border='0' style='vertical-align:middle'
    alt='rolleyes.gif' /> ...
  24. Php Programmers, How Long To Finish Your Scripts? - time spent on creating php scripts (23)
    Hello. I am currently working on kShoutBox 0.5 which has many new features. Now I realize that
    it's really really and i mean really difficult to create a PHP script because it really do takes
    your time. Example when I don't know what to do or what function to use, i check out the php
    manual, and you know, i use the old tradition "Trial and Error"....
  25. Misc Cool Scprits - I'm looking for some cool scripts (8)
    Well I'm looking for some cool php scirpts to spruce up my website a little and make it more
    interactive. Does anyone have some scripts that are easy to apply and customise? I would be
    enternally greatful, since all the pre-installed scipts on the trap17 cpanel take up loads and loads
    of webspace. Thanks....
  26. No Mysql When Running Phpinfo.php? - (3)
    Hi I am running apache 2/Mysql/PHP5 on XP pro. I took my first steps with a tutorial sending sql
    queries via a PHP script and I got an error message in the browser. So I ran phpinfo.php and there
    is no sign of mysql at all. I have searched the web and found a lot of PHP 5 users having problems
    with the installation. Some dropped back to PHP 4 as it was easy to install, others deleted it all
    and reinstalled some bundled software with apache/mysql/PHP which was easy to install too, others
    got it fixed and moved on. I have spent a lot of time on this and am a little frustr...
  27. No Mysql When Running Phpinfo.php? - (1)
    Hi I am running apache 2/Mysql/PHP5 on XP pro. I took my first steps with a tutorial sending sql
    queries via a PHP script and I got an error message in the browser. So I ran phpinfo.php and there
    is no sign of mysql at all. I have searched the web and found a lot of PHP 5 users having problems
    with the installation. Some dropped back to PHP 4 as it was easy to install, others deleted it all
    and reinstalled some bundled software with apache/mysql/PHP which was easy to install too, others
    got it fixed and moved on. I have spent a lot of time on this and am a little frustr...
  28. Some Scripts.. - (1)
    I got some scripts i been wanting.. see im making a SubProfile for AIM and i want to make it myself
    b/c i had ads and i did a vistor counter but i cant get IP Logger and i want the ip to show in
    profile and crap then i wanted to make a guestbook sort of thing can ne1 help...



Looking for running, php, web, scripts, local, machine

Searching Video's for running, php, web, scripts, local, machine
advertisement



Running Php Web Scripts On A Local Machine



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE