How do I view my PHP pages in a browser?

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:

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

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?

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

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

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…

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

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"

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!

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!

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.

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:

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:

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

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.

Sponsor our Newsletter | Privacy Policy | Terms of Service