How do I view my PHP pages in a browser?


#1

Noob question coming at ya’.

I’m a programmer, but am new to web development.

I want to build a web site using PHP and MySQL.

I just downloaded and installed WinLAMP under Windows 7 (I’ll be using a service when the site goes live, I just want to develop it locally).

I then wrote a simple PHP page like this, and put it in [tt]C:/Apache2/htdocs:[/tt]

[php]

Hello


<?php echo 'Hello' ?>


[/php]

My question is this: where do I have to put this PHP code file and/or what do I have to set in Apache so that I can type ‘localhost’ in my browser and see my page?

Thanks for any help you can give me :slight_smile:


#2

http://localhost/ should be the default location.


#3

Thanks, but that doesn’t answer my question. [tt]http://localhost/[/tt] isn’t a folder on my hard drive, lol. I can type localhost in my browser, and I get a page telling me that Apache is running successfully. So that’s not the problem.

Where, on my hard drive, do I put my PHP file? I saved it as [tt]index.php[/tt] in [tt]C:/Apache2/htdocs[/tt] but Apache is still serving its Success page, instead of my test page :frowning: Or what setting to I change in Apache to make Apache point to my PHP page?


#4

http://winlamp.sourceforge.net/?module=tips

open the apache config file and make sure the document root is set to the right location.


#5

This is the parm in [tt]httpd.conf[/tt]:

[tt]#

DocumentRoot: The directory out of which you will serve your

documents. By default, all requests are taken from this directory, but

symbolic links and aliases may be used to point to other locations.

DocumentRoot “C:/Apache2/htdocs”[/tt]

This is how it was installed. I didn’t change it.

In [tt]C:/Apache2/htdocs[/tt] are the three documents and nothing else:

[tt]index.htm
index.html
index.php[/tt]

All three are my test page. When I type localhost, I get the page that says: WinLAMP, she installed successfully…

I’m fairly computer savvy, but I’m baffled. I know my problem must be something stupid that I’m overlooking, but being an Apache noob, I haven’t a clue…


#6

copy your page to C:/Apache2/htdocs
and delete index.htm and index.html so there will be just index.php (assuming your page is called so)
or http://127.0.0.1/your_page_name.php


#7

btw. what kind of a programmer doesnt know what this means?

# # DocumentRoot: The directory out of which you will serve your # documents. By default, all requests are taken from this directory, but # symbolic links and aliases may be used to point to other locations. # DocumentRoot "C:/Apache2/htdocs"

#8

I know what it means, moron!

Why don’t you go back to elementary school to learn to read so you can understand my question!


#9

You have to delete index.html and index.htm or acces directly http://localhost/index.php or http://127.0.0.1/index.php and restart Apache or WinLamp.

Apache is looking allways (standard configuration) for a .html or .htm file, does he not find any .html or .htm index file than he looks after a .php file.

Do you feel the need to offend someone?
I just asked because i thought a programmer will know such stuff :slight_smile:

Please excuse my english, im romanian and im trying to help you!


#10

Fredashay - stop while you’re ahead. All he was doing was expanding on my post - no need to get like that.

Do what he said and either delete or rename the other 2 index files, or create a folder for that particular project (which is what i do) and put everything in there. You can directly access the php also.


#11

If you dont get it to work this way neither, create a new folder in C: called www and edit httpd.conf
DocumentRoot “C:/www”
Good luck :slight_smile:


#12

Thanks! That worked.

I typed [tt]http://localhost/index.php[/tt] and it displayed my page. Yay!

That’s all I needed to know…

But saying “what kind of programmer doesn’t understand what that means?” was rude and not appreciated, especially in my already frustrated state of mind.

The docs said to type merely [tt]localhost[/tt] into my browser. Nowhere in the docs did I see where I had to type [tt]http://localhost/index.php[/tt].

I am a developer, but I can’t read minds, guys :slight_smile:


#13

ok, my bad, glad we could helped you :wink:


#14

Okay. You’re forgiven :slight_smile:

I didn’t know about your english.

Sorry that I overreacted, but that was kind’a insulting to say that, just so you know.