Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Running Php Web Scripts On A Local Machine
switch
post Apr 24 2006, 04:19 AM
Post #1


Premium Member
********

Group: Members
Posts: 178
Joined: 13-October 04
From: NSW, Australia
Member No.: 1,713



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!
Go to the top of the page
 
+Quote Post
BuffaloHELP
post Apr 24 2006, 04:46 AM
Post #2


Desperately seeking "any key" to continue...
Group Icon

Group: Admin
Posts: 3,434
Joined: 23-April 05
From: Trap17 storage box
Member No.: 6,042



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.
Go to the top of the page
 
+Quote Post
Tyssen
post Apr 24 2006, 04:49 AM
Post #3



***********

Group: Members
Posts: 1,161
Joined: 9-May 05
From: Brisbane, QLD
Member No.: 6,818



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.

This post has been edited by Tyssen: Apr 24 2006, 04:50 AM
Go to the top of the page
 
+Quote Post
DeveloperX
post Apr 24 2006, 04:57 AM
Post #4


Advanced Member
*******

Group: Members
Posts: 130
Joined: 21-December 05
Member No.: 15,990



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!
Go to the top of the page
 
+Quote Post
switch
post Jun 12 2006, 09:23 AM
Post #5


Premium Member
********

Group: Members
Posts: 178
Joined: 13-October 04
From: NSW, Australia
Member No.: 1,713



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.
Go to the top of the page
 
+Quote Post
masugidsk8r
post Feb 22 2007, 12:12 AM
Post #6


Premium Member
********

Group: Members
Posts: 168
Joined: 21-February 07
Member No.: 38,999



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"

This post has been edited by masugidsk8r: Feb 22 2007, 12:13 AM
Go to the top of the page
 
+Quote Post
cwconline
post Feb 25 2007, 05:49 PM
Post #7


Member [Level 1]
****

Group: Members
Posts: 60
Joined: 25-February 07
From: Somewhere Your Not! Well... Maybe your here. Who Knows?
Member No.: 39,197



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
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. No Mysql When Running Phpinfo.php?(3)
  2. Php, Some Easy Scripts(3)
  3. Misc Cool Scprits(8)
  4. Php Programmers, How Long To Finish Your Scripts?(23)
  5. Php Scripts(2)
  6. Executing Scripts Without Include() Function(3)
  7. Uploading From Url(9)
  8. Need Scripts For Testing Server's Limitation(6)
  9. I Need Free Scripts(21)
  10. Good Scripts(10)
  11. Parse: Error Unexpected T_lnumber(4)
  12. Good Free Php Scripts(10)
  13. Php Scripts Free For Every One(12)
  14. Query Not Running When Submitting A Form(3)
  15. Php Error When Running Script(3)
  1. Password Strength / User Availablity Scripts ?(2)
  2. Running Php And Asp On The Same Machine(4)
  3. How Do Scripts Select To Be Placed In Fantastico(2)
  4. Free Web Forum Scripts?(7)
  5. Releasing Wap/php Scripts?(3)
  6. Papular Wap Scripts 4 Your Sites(3)
  7. Phpbb Customization?(7)
  8. Themed Scripts (weekly)(0)
  9. Wamp Packages Needed To Test Scripts(1)
  10. Scripts(5)
  11. Downloading Scripts(2)