Jump to content
xisto Community
Sign in to follow this  
switch

Running Php Web Scripts On A Local Machine

Recommended Posts

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

<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!

Share this post


Link to post
Share on other sites

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

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 LOCALHOST/*directory/script_in_php where *directory is optional.

Share this post


Link to post
Share on other sites

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 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.

Edited by Tyssen (see edit history)

Share this post


Link to post
Share on other sites

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:

LOCALHOST/myScript.php

or

http://forums.xisto.com/no_longer_exists/

 

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

 

Good luck!

Share this post


Link to post
Share on other sites

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: http://www.mpsoftware.dk/.

thanks again guys, all the best.

Share this post


Link to post
Share on other sites

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

<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. https://www.apachefriends.org/download.html?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 "LOCALHOST/yourpage.php"
Edited by masugidsk8r (see edit history)

Share this post


Link to post
Share on other sites

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

<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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.