Re: PHP4/Apache: .php files OK, <?php fails
| From: | The Big Ugly | Date: | Sun, 07 Jan 2001 20:57:40 +0000 |
| Subject: | Re: PHP4/Apache: .php files OK, <?php fails | ||
| References: | 1 | Groups: | php.general php.install |
| Request: | Send a blank email to php-general+get-33117@lists.php.net to get a copy of this message | ||
Thanks to everyone who replied. Adding the .htm and .html extensions to
the AddType line for x-httpd-php did the trick. It's working now.
This would be a good thing to add to the INSTALL file that comes with PHP
4.0.4 and also the online PHP FAQ. They both mention the AddType line but
only suggest the PHP-specific extensions like .php and .php3. I guess
it's obvious now, but for a first-time Linux/Apache/PHP installer it sure
had me going for a while.
The annotated online PHP manual at www.php.net/manual/introduction.php has
a comment by jwatt@email.unc.edu saying you need to have 2 lines:
AddType text/html .html
AddType application/x-httpd-php .php .html
but I found this did not work. After adding the first line for the
text/html MIME type, I got a parse error from PHP for the first line of
index.html. If I take out the first AddType line so there is no explicit
extension mapping for text/html, it all works. Very strange!
Well, what the heck, it's working. Thanks everyone!
Terry McKiernan
Ugly Software
On Mon, 8 Jan 2001, Nat Sakimura wrote:
> That's what I am pointing out.
>
> Either
>
> (1) Change the extention from .htm to .php
>
> or
>
> (2) add .htm to AddType application/x-httpd-php line
> in httpd.conf so that .htm extention will actually be
> processed by mod_php.
>
> Regards,
>
> Nat Sakimura
>
> ----- Original Message -----
> From: "bill" <bmoore@mooreinternet.com>
> To: "Nat Sakimura" <sakimura@gosoudan.com>
> Sent: Monday, January 08, 2001 12:39 AM
> Subject: Re: [PHP-INST] PHP4/Apache: .php files OK, <?php
> fails
>
>
> > In your .htm file you have php inline code. Therefore if
> you wish it to be
> > processed by the php interpreter, you must change the
> extension name from
> > .htm to .php
> >
> > Hope this helps.
> >
> > Bill Moore
> > http://www.biz-webhost.com
> >
> > ----- Original Message -----
> > From: "Nat Sakimura" <sakimura@gosoudan.com>
> > To: "The Big Ugly" <terry@uglysoftware.com>
> > Cc: <php-install@lists.php.net>
> > Sent: Sunday, January 07, 2001 9:28 AM
> > Subject: Re: [PHP-INST] PHP4/Apache: .php files OK, <?php
> fails
> >
> >
> > > I am not sure if I am getting it correctly, but
> > > what you have to do probably is to write the page
> > > with .php extention or to add the .htm to
> > > AddType application/x-httpd-php
> > > line in httpd.conf .
> > >
> > > Regards,
> > >
> > > Nat Sakimura
> > >
> > > ----- Original Message -----
> > > From: "The Big Ugly" <terry@uglysoftware.com>
> > > To: <php-install@lists.php.net>
> > > Sent: Sunday, January 07, 2001 8:13 PM
> > > Subject: Re: [PHP-INST] PHP4/Apache: .php files OK,
> <?php
> > > fails
> > >
> > >
> > > > Sorry to reply to my own post, but if anyone wants to
> take
> > > a look at my
> > > > web site, the problem code is demonstrated on the main
> > > page:
> > > >
> > > > http://www.uglysoftware.com
> > > >
> > > > There's an inline script, which does nothing, and a
> link
> > > to a separate
> > > > .php file, which works correctly.
> > > >
> > > > Thanks for any help!
> > > >
> > > > Terry McKiernan
> > > > Ugly Software
> > > >
> > > > On Sun, 7 Jan 2001, The Big Ugly wrote:
> > > >
> > > > > I just installed PHP 4.0.4 on Apache 1.3.14 running
> on
> > > RH Linux 7.0 (i386)
> > > > > and it's all looking pretty good, except that the
> inline
> > > <?php tags don't
> > > > > work. A file ending in .php is recognized just fine
> by
> > > Apache and
> > > > > executed properly.
> > > > >
> > > > > That is, if I write a little PHP script and put it
> in a
> > > file with
> > > > > extension .php, and load that into my browser, then
> it
> > > runs just like it
> > > > > should.
> > > > >
> > > > > If I have an HTML file with some of what I'll call
> > > "inline" PHP, using the
> > > > > <?php ?> construct, the server & browser completely
> > > ignore it. I can view
> > > > > the page source and see the PHP code; it is just
> getting
> > > ignored as if it
> > > > > were an unknown HTML tag.
> > > > >
> > > > > For example, this (test1.htm) does not work:
> > > > >
> > > > > <html>
> > > > > <head><title>Inline PHP</title><head>
> > > > > <body>
> > > > > Some stuff before the PHP<br>
> > > > > <?php echo("a line printed by PHP"); ?><br>
> > > > > </body>
> > > > > </html>
> > > > >
> > > > > All I get in the browser is the "Some stuff before
> the
> > > PHP" line.
> > > > >
> > > > > This, on the other hand, does work when saved as
> > > test2.php and loaded
> > > > > into the browser:
> > > > >
> > > > > <?php
> > > > > $html = <<<ENDH
> > > > > <html>
> > > > > <head><title>PHP from Script</title></head>
> > > > > <body>
> > > > > <h1>Groovy PHP</h1>
> > > > > </body>
> > > > > </html>
> > > > > ENDH;
> > > > > echo $html;
> > > > > ?>
> > > > >
> > > > >
> > > > > So, I'm mystified. PHP and Apache seem to be
> talking
> > > together to some
> > > > > extent, since the .php files work. Is there
> something I
> > > need to do to
> > > > > enable the <?php ?> tags? I have tried the short <?
> ?>
> > > and long <script
> > > > > language="php"> variations with the same results.
> > > > >
> > > > > Thanks for any help!
> > > > >
> > > > > Terry McKiernan
> > > > > Ugly Software
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > PHP Install Mailing List (http://www.php.net/)
> > > > To unsubscribe, e-mail:
> > > php-install-unsubscribe@lists.php.net
> > > > For additional commands, e-mail:
> > > php-install-help@lists.php.net
> > > > To contact the list administrators, e-mail:
> > > php-list-admin@lists.php.net
> > > >
> > > >
> > >
> > >
> > > --
> > > PHP Install Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail:
> php-install-unsubscribe@lists.php.net
> > > For additional commands, e-mail:
> php-install-help@lists.php.net
> > > To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
> > >
> >
> >
>
>
>