[Glastonbury] (no subject)

Martin WHEELER glastonbury at mailman.lug.org.uk
Mon Jul 14 00:49:00 2003


On Sun, 13 Jul 2003, tom hayward wrote:

> I am learning PHP from a site and it told me to type something in PHP and
> save it.
> When i opened it, it said choose a program toopen it with. What do i do?

[ I feel a long session coming on. ]

OK.  There are two ways of installing PHP -- one installs an
interpreter, which means you can type in a PHP program and then run it
from a command line.  This is unusual, and virtually never used these
days.
The other way installs a module in your local web server (http) driver
-- usually Apache -- which allows it to process any php script content
encountered in a web page.  This is almost always the default
installation.

I am going to assume you have the latter -- it's more usual.

(BTW, you don't tell us what distribution you're using, nor what kernel
version you're running.  You can get the name & version of the
distribution from the label on the CD; and the kernel version number by
typing in:

     uname -a

at the command line.
Err .. if your system boots straight into a graphical interface, get to
a command line interface by hitting Ctrl/Alt/F1 or Ctrl/Alt/F2 ... all
the way up to Ctrl/Alt/F6.
To get back to the X interface, hit Ctrl/Alt/F7.  Or Ctrl/Alt/F8.  Or
Ctrl/Alt/F9.
And yes, you can have six different command line interfaces plus three
different X interfaces open simultaneously, and constantly switch
between all nine of them -- I work like that all the time.)

Back to where we were.

Opening up a web page containing php code is done by pointing your web
browser at it.  The page name usually ends in .php3 or simply .php
And you must look at the page by having it served up to your browser by
the local web page server, NOT the file viewer.
(i.e. use  http://...  to call up the file, not  file:///... )

For this to work, you must:
a) have Apache (or other http driver) installed;
b) have it configured to accept php pages for processing.

Is this the case with your installation?
(If not, we're in deep doo-doo, and going down fast.)

To check whether you've got Apache or other httpd installed and
running, point your web-browser at:

     http://localhost/

and you should get a holding page, or other indication that Apache is
installed and capable of serving up web pages.
If you get an error message, try entering:

     apachectl start

at a command line prompt.
If you still get an error message, you should check that you have in
fact got both Apache, *and* PHP installed.  And running.


Did you open your php file with a web-browser?
Because if it's asking you how to process it, that's a pretty sure sign
you haven't got Apache installed.


What editor are you using to create your text (.php or .html) files?
Any old editor is sufficent -- from the command line, use nano, or joe,
or ae, or ee (I suspect vi will cause you immense grief, so avoid it);
in X, nedit, kedit -- whatever your system offers.  It doesn't matter --
php script is just plain old ASCII text.

Remember also to save your .php file in your web server's document root
directory (usually something like /var/www or /html or somesuch.
That's the top directory of where all your web pages live, locally.)
And its permissions must be set so that it's readable.


In general, when asking for help, it's usually better to state:
  distribution + version; kernel version; name & version
of all software involved.
For example, on my machine, I'm using:
  Debian 3.0 (sarge); kernel 2.4.19-686; Apache 1.3.27; PHP 4.1.2;
  mozilla 1.0.0
(This helps others tell you where to go on your system to find stuff.)

How easily you find this information depends a lot on the distribution
you're using.

HTH,
-- 
Martin Wheeler   -   StarTEXT / AVALONIX - Glastonbury - BA6 9PH - England
mwheeler@startext.co.uk                http://www.startext.co.uk/mwheeler/
GPG pub key : 01269BEB  6CAD BFFB DB11 653E B1B7 C62B  AC93 0ED8 0126 9BEB
      - Share your knowledge. It's a way of achieving immortality. -