Page 1 of 2

Time for Headaches

Posted: Thu Nov 19, 2009 8:45 am
by KostaKondra
Okay, I'm ready to start bursting my head open. In my fact I haven't even started but I just know something is going to go wrong. So...

I have installed Apache Server.
I have installed SQL (I have a MySQL Command Line client and everything).

Now I want to do something crazy. I want to make a web page with a simple PHP command making connection with my test database. I know this is going to be a headache, something is going to go wrong.

Q1. How do I know if my Apache server is running correctly, it's dissapeared from my task bar and when I click on it in Start menu it says "It's all ready running".
Q2. Where do I put my web page so that it can run on the client (realspeak: on my computer without having to upload it).

Regards
Please make this simple.

Re: Time for Headaches

Posted: Thu Nov 19, 2009 8:53 am
by papa
Q1. Open your brower, type "localhost" in the address and see if Apache is running.

Q2. When installing Apache you set your root folder which is under your Apache installation if you didn't change it, called www probably. You can take a look in Apache's httpd.config and see where it is if you don't know.

Re: Time for Headaches

Posted: Thu Nov 19, 2009 9:01 am
by KostaKondra
papa wrote:Q1. Open your brower, type "localhost" in the address and see if Apache is running.

Q2. When installing Apache you set your root folder which is under your Apache installation if you didn't change it, called www probably. You can take a look in Apache's httpd.config and see where it is if you don't know.
Typed localhost in my Chrome web browser and it went to Google localhost, you know how you type stuff and they just show you the results from Google. So no succes there.

How would I look into Apache's httpd.config? Is that even a file? Where is Apache, when I installed it I would assume I would have kept all the default settings. More clarification needed. Cheers.

Re: Time for Headaches

Posted: Thu Nov 19, 2009 9:05 am
by papa
Try http://127.1.0.0

Apache is located where you installed it. Maybe program files.

Re: Time for Headaches

Posted: Thu Nov 19, 2009 9:16 am
by KostaKondra
papa wrote:Try http://127.1.0.0

Apache is located where you installed it. Maybe program files.
It works!! Haha I like it. So Open Source. Okay so I'm in Apache there's a bunch of Notepad files and folders. What do I do here? How do I make a web page simply echoing that a connection has been made between my SQL Databases and the browser? Where must I put this web page on my local computer?

Re: Time for Headaches

Posted: Thu Nov 19, 2009 9:28 am
by papa
You might want to do some reading before starting with databases:
http://us2.php.net/manual/en/

If you have found your www folder you can either edit the index.php file or create a folder which you can work in. Then your url would be:
http://127.1.0.0/project/

A simple php test is

<?php
phpinfo();
?>

Safe file as index.php in your project folder.

Posted: Thu Nov 19, 2009 9:54 am
by Jonah Bron
You can't just type "localhost", you have to tell the super-bar that you're giving it an address: "http://localhost/"

The httpd.config is probably somewhere like "C:\Program Files\Apache Software Foundation\Apache2.2\conf\"

On Windows, that is.

Just do a "find" in the file for the phrase "DocumentRoot".

Re:

Posted: Thu Nov 19, 2009 6:18 pm
by KostaKondra
Jonah Bron wrote:You can't just type "localhost", you have to tell the super-bar that you're giving it an address: "http://localhost/"

The httpd.config is probably somewhere like "C:\Program Files\Apache Software Foundation\Apache2.2\conf\"

On Windows, that is.

Just do a "find" in the file for the phrase "DocumentRoot".
Great, so I confirmed Apache works (tick). Now, I'm in the httpd.config file (what does the 'd' in httpd stands for I know Open Source would not make things needlessly complicated).

So this document is LOOOOOONG. But it's mostly comments, so that's ok. Ok, first line of code:
ServerRoot "C:/Program Files/Apache Software Foundation/Apache2.2"

So that means I'm going to save my files in that particular location? Ok, so I've made a folder in that directory called test_project. And I'll create a file in that folder with Dreamweaver and save it with a .php extension (don't worry I know how to do the basic things).

Then I typed in the php code suggested by papa (in the body section). Save it.

Open it in a web browser and this is what I see: nothing.

I assume it should say something like "PHP Version 3.2" etc. But there's nothing.

Cheers

Posted: Thu Nov 19, 2009 9:03 pm
by Jonah Bron
NNNNNNNOOOOOOOOOOOO!!!!!!!!!!

DON'T TOUCH THE SERVER ROOT!

Ahem, *regains composure*

I said "DocumentRoot", not "ServerRoot". "DocumentRoot is where you will end up if you type "http://localhost/" into your browser.

Re:

Posted: Thu Nov 19, 2009 9:16 pm
by KostaKondra
Jonah Bron wrote:NNNNNNNOOOOOOOOOOOO!!!!!!!!!!

DON'T TOUCH THE SERVER ROOT!

Ahem, *regains composure*

I said "DocumentRoot", not "ServerRoot". "DocumentRoot is where you will end up if you type "http://localhost/" into your browser.
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"

That's the line I found in the httpd.config file or whatever.

So I put my test_project folder in htdocs/, I will give you the code of the document here:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
<title>Untitled Document</title>
</head>
 
<body>
<?php
phpinfo();
?>
</body>
</html>
This is what I see on the resulting page: nothing.

So what do I do now? See, I knew this was going to be a headache before i started. I just know. It's just the way it has to be, because Apache won't say "Hey, why don't we make things easy".

Posted: Thu Nov 19, 2009 9:45 pm
by Jonah Bron
Things are easy, as long as you know what you're doing.

Are you sure the Apache service is running?

Lets make this easy: make a file called index.php, that contains the following:

Code: Select all

<?php
phpinfo();
?>
Put that file into C:/Program Files/Apache Software Foundation/Apache2.2/htdocs

Type "http://localhost/index.php" in your browser.

Voila! It should work, but we'll see.

Re:

Posted: Thu Nov 19, 2009 10:01 pm
by KostaKondra
Jonah Bron wrote:Things are easy, as long as you know what you're doing.

Are you sure the Apache service is running?

Lets make this easy: make a file called index.php, that contains the following:

Code: Select all

<?php
phpinfo();
?>
Put that file into C:/Program Files/Apache Software Foundation/Apache2.2/htdocs

Type "http://localhost/index.php" in your browser.

Voila! It should work, but we'll see.
Nope. Even worse. When I renamed the file in Windows Explorer from .html to .php it turned into an icon that said 'PHP Script' on it (like in Dreamweaver, I think it's one of Dreamweaver's icons).

Now when I open up the http://localhost/index.php by typing that in the web browser I actually see the code!! Like everything the <head> the <body> tags everything. What am I doing wrong?

Re: Re:

Posted: Fri Nov 20, 2009 3:27 am
by Weiry
KostaKondra wrote:What am I doing wrong?
You didnt install wamp :lol: :wink:

This will be happening because i dont think you have PHP installed.
PHP doesn't come pre-installed with apache or mysql. its another thing all together.
http://www.php.net

If you install wamp server, then it handles mysql, php and apache all in one :D Not to mention, i think using WampServer is actually about 100% easier than using the command line version of the apps. But i like GUI's :D

Re: Re:

Posted: Fri Nov 20, 2009 4:24 am
by Grizzzzzzzzzz
Weiry wrote:
KostaKondra wrote:What am I doing wrong?
If you install wamp server, then it handles mysql, php and apache all in one :D Not to mention, i think using WampServer is actually about 100% easier than using the command line version of the apps. But i like GUI's :D
yep,

get wamp http://www.wampserver.com/en/ or xampp http://www.apachefriends.org/en/xampp.html

and the majority of your problems will float away

Posted: Fri Nov 20, 2009 12:05 pm
by Jonah Bron
Nope. Even worse.
Sounds like an improvement, to me. A Dreamweaver icon is not bad. It just means that when you double-click it, it will open in Dreamweaver for editing. You don't want a PHP file to open in a browser anyway, because it's useless there without PHP executing it.