Apache,MySQL&php - have I got it wrong

  badgermansix 10:28 13 Jan 06
Locked

WinXPHE SP2

I've done it again, typed in a question and then lost it somehow:-((
So I may duplicate this somewhere?

A couple of Basic questions which I just cannot seem to understand.
If somewone can answer these I will be very grateful..

I want to build and test my Website on my PC before uploading to my ISP
I have installed PHP, Apache and MySQL.
These appear to have installed o.k., in my task bar I have a green traffic light and a red feather(?) telling me
Apache services are running.
When I go online to click here or click here,
I can get the WinMySQLadmin page, and the PHPinfo page showing, but sometimes I am
told the pages are not available.sometimes they will not open.

As I understand it:-
Apache acts as a server on my PC?
MySQL is where my database is stored, on my server, on my PC?
PHP is the the programme where I create and move my imput to MySQL which is on Apache?

So all of this can be done on My PC?
Therefore, I ask, why must I go online to get a result?

When I installed MySQL it required me to create a username and password.
I have not been asked for these since, why is this?

When I installed Apache it required my network domain name, and server name,
I inserted the details of my Domain name and server name which I have with my ISP host Web-Mania
Is this correct?

If the above is correct, why must I go online to create a database on my PC?

I installed "phpinfo.php" into htdocs and it works o.k. (most times), however, when I create a test page like
?php echo "Hello Web!": ?> with Notepad, placed in into htdocs, it will not run.
Why could this be?

This is driving my mad, I just cannot get through these elementary stage.

What am I doing / what have I done wrong?

  badgermansix 17:06 13 Jan 06

when I create a test page like
?php echo "Hello Web!": ?> with Notepad

Should read -

<?php echo "Hello Web!": ?>

  PurplePenny 21:49 13 Jan 06

You don't have to be online: 'localhost' is the server on your PC, you get to it using your browser but it isn't online. To prove this to yourself go to 'localhost' with the phone line unplugged.

That server info is for if you be use the server as a live server (i.e. accessible from outside) but you are using it for local testing so for the server name use the local 'loopback' IP address 127.0.0.0 .

What file extension are you giving the 'Hello web' test page? Is it .php?

  PurplePenny 22:00 13 Jan 06

What do you see when you go to 'localhost'?

  badgermansix 22:53 13 Jan 06

PurplePenny,

Thank you so much for replying.

This may sound silly, but I am feeling great about this! I have done something wrong:-)
but at least I was thinking correctly :-))
(up to a point).

i.e. I don't have to be on line.

<You don't have to be online: 'localhost' is the server on your PC, you get to it using your
<browser but it isn't online. To prove this to yourself go to 'localhost' with the phone
<line unplugged.

I have tried opening up IE and "Working offline", typing in http:slantslocalhost, but I just get the message "The Web page you requested is not available offline etc."

The IP address showing in the hppt doc is 127.0.0.1

<What file extension are you giving the 'Hello web' test page? Is it .php?
Yes, the same as the phpinfo.php file which opens up o.k.
I have checked and checked the Hello code and I am sure it is correct

What is odd is that the phpinfo.php file is saved as a webbuilder document because the
file would not run if saved in notepad
I tried to save the Help file in webbuilder format but could not ( I don't even know where that has come from).

<What do you see when you go to 'localhost'?
When I go online and enter http:slantslocalhost I get the default Apache page.
When I add /phpinfo.php I get the phpinfo window o.k. but I have to be on line?

While I was looking through the WinMySQLAdmin at the myini setup I saw that the Port was
showing as 3306, I changed this to 127.0.0.1 and things seem to be running a bit better i.e. I get to localhost every time now rather than every now and then??

Once again, thanks for your help.

  Forum Editor 08:40 14 Jan 06

and type: http//localhost

What happens?

  Taran 10:55 14 Jan 06

Changing MySL to run on 127.0.0.1 should not be necessary. In fact altering any of the defaults could cause potential issues - you can run MySQL by binding it to the loopback address but let's not get into that just yet.

Start by answering Forum Editor's question above on what happens if you type in http ://localhost in your Internet Explorer address bar then click Go or press your Enter key - make sure you remove the space between http and ://localhost

Apache is the web server that serves pages to the browser requesting it/them. For normal HTML pages you don't need the web server since the browser can render HTML all on its own. Apache processes PHP and presents the output of the PHP scripts as HTML to the web browser.

You can tell Apache to accept page requests from the outside world but for the moment it listens internally (locally) on your own PC for local page requests. Once the page request is detected Apache processes and serves the page back to the browser requesting it (yours).

The DevArticles site has one of the best introductory tutorials on how to install and configure Windows with Apache, MySQL and PHP and reading through it could help: click here

If you get really adventurous you could read the follow up article click here

That second link can be a bit scary to those new to Apache and is not really necessary for a testing server on your own PC.

If the pages you request do not display this is usually because of a problem with Apache, or the location you have saved your files. Apache may not be running, or you may not have put your PHP files into the correct location for Apache to be able to process them.

If the localhost address brings up the "Test Page for Apache Installation" and if your phpinfo.php file is working then the only thing that is likely to be wrong is where you have saved your files. They should go into the Apache2\htdocs folder.

  badgermansix 15:24 14 Jan 06

FE,
PurplePenny asked me this,

I have tried opening up IE and "Working offline", typing in http:slantslocalhost, but I just get the message "The Web page you requested is not available offline etc."

Taran

<If the localhost address brings <up,the "TestPage for Apache Installation" and if your phpinfo.php file is working then the only thing that is likely to be wrong is where you
<have saved your files. They should go into the <Apache2\htdocs folder.


when I created a test page like
?php echo "Hello Web!": ?> with Notepad and saved as "first.php" in htdocs next to "phpinfo.php", local host (while I am on line) will open phpinfo.php but not first.php?

Could I have inadvertantly made an error while while installing (following instructions from my Manual) the Apache Server details, concerning "Network Domain " "Server Name" etc?

Looking at my manual again concerning these

There are two radio buttons;
1. For all users on Port 80 as a service.
2. Only for the current user on port 8080

The manual told me to leave it on 1. is this correct, as I only want this as a test site?

TIA

  badgermansix 15:26 14 Jan 06

when I created a test page like
?php echo "Hello Web!": ?>

This s/b <?php echo "Hello Web!": ?>

sorry.

  Taran 15:48 14 Jan 06

OK, why don't we take a step back and take one point at a time ?

Make a cup of something, take a breath and:

If your phpinfo.php file is showing up in your browser as a long table of information about the server environment then we can assume that Apache is running OK, or at least it was at the time of testing your page.

Can you double check one point for me please, and I hope this doesn't come over as entirely obvious, but you'd be surprised at how many people are caught out by this:

Notepad saves files with the .txt extension by default. Are you absolutely sure that when you saved the file as first.php it wasn't actually named by Notepad as first.php.txt ?

It's an extremely easy mistake to make and you certainly wouldn't be the firt person to make it.

When you open up your htdocs folder in Windows Explorer can you see the file extensions of ALL the files in there ?

If not, go to Tools, click on Folder Options, click on the View tab, remove the tick where it says "Hide extensions for known file types" then click Apply then OK.

Go back to your htdocs folder and take another look at your test page and check its file extension.

That will eliminate the most obvious cause of any problems without getting into the headaches of swapping ports, bindings and so on.

T

  Taran 15:53 14 Jan 06

Your test page code should read:

<?php

echo 'Hello Web!';

?>

Your code looks like it could be a colon and not a semi-colon at the end of your 'Hello Web!' text, which would break things from the outset.

If it is a semi-colon then my apologies - my eyes are sore from a long night working with a very unruly server and I'm pooped.

This thread is now locked and can not be replied to.

AMD Ryzen release date, specifications and features: Three CPUs from the Ryzen 7 range now…

1995-2015: How technology has changed the world in 20 years

Glassworks Barcelona shows how it captured the artistic imagination of Conor in A Monster Calls

Best iPhone games 2017 | Best iPad games 2017: 162 fantastic iOS games that you need to play right…