954,591 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

LOCALHOST-PHP in browser

HELP- I need to view my php files in the browser. I am running Apache server.

I know only this much to put in the browser
http://localhost/ /filename.php

thanks

wavyaquaeyes
Newbie Poster
20 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 

umm do you have PHP installed and configured?

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 

yes to both

wavyaquaeyes
Newbie Poster
20 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 

so the files are in the directory on the web server? (usually /var/wwwroot on linux)

if so you should just do:

http://localhost/pagename
or

http://127.0.0.1

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 

Install wamp server and then try it. WAMP is really easy to use.

desiguru
Junior Poster in Training
63 posts since Aug 2006
Reputation Points: 10
Solved Threads: 1
 

thanks a;; appreciate it

wavyaquaeyes
Newbie Poster
20 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 
thanks a;; appreciate it


Also if you want to learn more about php you should watch Lynda.com's php beginner's tutorial. It's amazing.

desiguru
Junior Poster in Training
63 posts since Aug 2006
Reputation Points: 10
Solved Threads: 1
 

Hello, Concerning the files, you need to put your files in a folder called "htdocs" where you installed the apache webserver
for example my files are in c:/program files/apache group/apache2/htdocs/folder name/
so I on my browser I type
http://localhost/foldername/filename

but first check if the server is running.

omesa
Newbie Poster
21 posts since Jun 2006
Reputation Points: 10
Solved Threads: 0
 

or if its linux then its usually /var/www

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 

I have my index.php file in folder aldo on drive D. here is the detail
D:\PHP\www\aldo\index.php. what should i write on address browser to run this index, or should I need to create new folder ?? should I set the server (appserv) ??
Your assistance really much appreciated

Regards
Leonardo

2easy4bee
Newbie Poster
1 post since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

localhost/aldo/index.php should suffice.

Ezzaral
Posting Genius
Moderator
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 

If the page only shows the code that's because the PHP interpreter isn't running. Look at your httpd.conf (Apache configuration file) and look if the line that says 'LoadModule php5_module' isn't commented with # sign.

Also, look for 'Listen' should say 'Listen 80' so you can put simply http://localhost/ on the browser. If the server is running on another port instance e.g. the line shows 'Listen 8080', put on the browser http://localhost:8080/ . This is a more uncommon issue.

If that doesn't make any change, maybe the PHP module isn't installed. I suggest to use a pre-configured package software with Apache/PHP/MySQL like xampp or mamp.

Make a new file on the root folder of your web server, 'test.php'. Add on the content:

<?php
echo phpinfo();
?>


Then on the browser access to http://localhost/test.php
It should display the PHP version and installed modules.

Well this is to manage sort of troubles with PHP, I haven't seen the previous page and the year :D

martin5211
Posting Whiz in Training
271 posts since Aug 2007
Reputation Points: 52
Solved Threads: 23
 

Install wamp or easy php, that will give you full package and easy to use.

BzzBee
Posting Whiz
327 posts since Apr 2009
Reputation Points: 16
Solved Threads: 48
 

You can also use XAMPP or PHPEASY
Both are easy
In Xampp Save your pages to Htdocs
for example your page is my.php and save in htdocs
then you have to write in browser
http://localhost/my.php
great
Maark this thread as solved.

ayesha789
Posting Pro in Training
496 posts since Jun 2009
Reputation Points: 17
Solved Threads: 7
 

I have my index.php file in folder aldo on drive D. here is the detail D:\PHP\www\aldo\index.php. what should i write on address browser to run this index, or should I need to create new folder ?? should I set the server (appserv) ?? Your assistance really much appreciated

Regards Leonardo

Some background... (I use Apache on a Windows box) In the conf subdirectory of your Apache directory is a file named httd.conf and in that is your setting for Apache's "DocumentRoot". Mine is set to:

# -refa- Current doc root is on D: on win200pro 10/12/2006
DocumentRoot "d:/Apache/htdocs/refrost/www"

I create directories under this location, resulting in, say,

"d:/Apache/htdocs/refrost/www/webapp1"
"d:/Apache/htdocs/refrost/www/webapp2"

Then I put/create the index.php and other app files in the webapp1 or webapp2 directories and call them from the browser via: http://127.0.0.1/webapp1/index.php

In your case, Leonardo, if you set your DocumentRoot to "D:/PHP/www" then you would call it via:

http://127.0.0.1/aldo/index.php

Clear as mud?

Ralph Frost

refrost
Newbie Poster
2 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

what is localhost.php file & why it is used?

shivanisaxean
Newbie Poster
1 post since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

Hi just place your file in the root directory i.e., if u have installed "xampp" then place your file in htdocs folder or if u have installed wampp then place your file in www folder.
like
C:/xampp/htdocs/newfolder/index.php
or
C:/wampp/www/newfolder/index.php
then to access that file enter this url in browser address bar
http://localhost/htdocs/newfolder
or
http://localhost/www/newfolder

i think this will help u...!

Layerphp
Newbie Poster
17 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

hey it's
http://localhost/newfolder
no need to enter root folder name

Layerphp
Newbie Poster
17 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

Install Xampp will work then.
Go through this tutorial on Installing Xampp and Run PHP Codes on Windows

http://planetghost.com/run_php_code

dineshnbhatia
Newbie Poster
1 post since Oct 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You