Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Thttpd and PHP

146 views
Skip to first unread message

Marc Grégoire

unread,
Jul 16, 2004, 11:50:13 AM7/16/04
to
I would like to run a PHP script I found to generate some pages for my website. At present, the site is hosted on thttpd. Looking through dselect, there seem to be two implementations of PHP packaged: an Apache module, and php4-cgi which doesn't require Apache. So I installed php4-cgi, and then opened up index.php from the script. All that happened was that Mozilla displayed the contents of that file.

Further investigation revealed the solution to two problems:
1. thttpd was set up by default not to run cgi scripts except in cgi-bin. I changed this to include the directory in which my script was located. I proved that the directory permissions were now ok by running a perl cgi script in that location.
2. I also turned off cgi-force-redirect in php.ini, which seems to be deisgned for use with Apache.
But despite making these changes, index.php still loads as a text file.

Looking at the thttpd website, I see that it is possible to run it with PHP, but there's no description of how to do so. I've also found various instructions on the web for compiling thttpd with php as a module. But I would prefer to use the standard packages with modified config files, rather than compile from scratch.

Has anyone successfully set up PHP to run with thttpd, using the Debian packages? How about using PHP with another non-Apache webserver?

I have never used PHP before, so I may be making some very obvious mistake. My system runs Debian testing (Sarge).

Please keep me CC'd, as I am not a subscriber to this mailing list. Thanks for your help.

Marc Grégoire

Jacob S.

unread,
Jul 16, 2004, 12:20:18 PM7/16/04
to
On Fri, 16 Jul 2004 07:26:14 -0700
Marc Grégoire <mpjgr...@theanvil.ca> wrote:
<snip>

> Has anyone successfully set up PHP to run with thttpd, using the
> Debian packages? How about using PHP with another non-Apache
> webserver?
>
> I have never used PHP before, so I may be making some very obvious
> mistake. My system runs Debian testing (Sarge).

I'm afraid I'm not familiar with thttpd, but here are some things I
would check.

1) Is there anything in the config file that tells thttpd what file
extensions should be treated as .cgis? You will probably want to add php
to this list.

2) Secondly, does your php file have "#!/bin/php" as the first line? If
not, you will need to add this.

HTH,
Jacob

--
GnuPG Key: 1024D/16377135

Random .signature #47:
Windows, the yo-yo operating system; it goes up... it goes down... it
goes up...

John Summerfield

unread,
Jul 16, 2004, 8:40:06 PM7/16/04
to
Jacob S. wrote:

>I'm afraid I'm not familiar with thttpd, but here are some things I
>would check.
>
>1) Is there anything in the config file that tells thttpd what file
>extensions should be treated as .cgis? You will probably want to add php
>to this list.
>
>
>

This might work::

cgipat=*.php


--

Cheers
John

-- spambait
1aaa...@computerdatasafe.com.au Z1aa...@computerdatasafe.com.au
Tourist pics http://portgeographe.environmentaldisasters.cds.merseine.nu/


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Micha Feigin

unread,
Jul 16, 2004, 10:40:06 PM7/16/04
to
On Sat, Jul 17, 2004 at 08:30:48AM +0800, John Summerfield wrote:
> Jacob S. wrote:
>
> >I'm afraid I'm not familiar with thttpd, but here are some things I
> >would check.
> >
> >1) Is there anything in the config file that tells thttpd what file
> >extensions should be treated as .cgis? You will probably want to add php
> >to this list.
> >
> >
> >
> This might work::
>
> cgipat=*.php
>

I don't think that php can run as cgi. I seem to recall though some php
support through cgi (you run the php page through a cgi to process
it). You should look at that option.

>
> --
>
> Cheers
> John
>
> -- spambait
> 1aaa...@computerdatasafe.com.au Z1aa...@computerdatasafe.com.au
> Tourist pics http://portgeographe.environmentaldisasters.cds.merseine.nu/
>
>
> --
> To UNSUBSCRIBE, email to debian-us...@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact
> listm...@lists.debian.org
>
>

> +++++++++++++++++++++++++++++++++++++++++++
> This Mail Was Scanned By Mail-seCure System
> at the Tel-Aviv University CC.

Jacob S.

unread,
Jul 16, 2004, 11:30:08 PM7/16/04
to
On Sat, 17 Jul 2004 05:08:27 +0300
Micha Feigin <mi...@post.tau.ac.il> wrote:

> On Sat, Jul 17, 2004 at 08:30:48AM +0800, John Summerfield wrote:
> > Jacob S. wrote:
> >
> > >I'm afraid I'm not familiar with thttpd, but here are some things I
> > >would check.
> > >
> > >1) Is there anything in the config file that tells thttpd what file
> > >extensions should be treated as .cgis? You will probably want to
> > >add php to this list.
> > >
> > This might work::
> >
> > cgipat=*.php
> >
>
> I don't think that php can run as cgi. I seem to recall though some
> php support through cgi (you run the php page through a cgi to process
> it). You should look at that option.

I'm sorry? Do you mean it can't run as a cgi when the webserver is
thttpd?

Because php can definitely run as a cgi - which is why there is a
package in Debian called php4-cgi. I've found it to be great for testing
an occasional script on my desktop, before uploading it to the server.
I've also seen others mention using it for the purpose of having scripts
run under a different username from apache, using Apache's SuExec
feature.

I may be misunderstanding what you were trying to say though.

HTH,
Jacob

--
GnuPG Key: 1024D/16377135

Random .signature #36:
Double your disk space - delete Windows!
http://www.linux.org

Micha Feigin

unread,
Jul 17, 2004, 9:50:08 AM7/17/04
to
On Fri, Jul 16, 2004 at 10:20:02PM -0500, Jacob S. wrote:
> On Sat, 17 Jul 2004 05:08:27 +0300
> Micha Feigin <mi...@post.tau.ac.il> wrote:
>
> > On Sat, Jul 17, 2004 at 08:30:48AM +0800, John Summerfield wrote:
> > > Jacob S. wrote:
> > >
> > > >I'm afraid I'm not familiar with thttpd, but here are some things I
> > > >would check.
> > > >
> > > >1) Is there anything in the config file that tells thttpd what file
> > > >extensions should be treated as .cgis? You will probably want to
> > > >add php to this list.
> > > >
> > > This might work::
> > >
> > > cgipat=*.php
> > >
> >
> > I don't think that php can run as cgi. I seem to recall though some
> > php support through cgi (you run the php page through a cgi to process
> > it). You should look at that option.
>
> I'm sorry? Do you mean it can't run as a cgi when the webserver is
> thttpd?
>

Looks like I misunderstood you. I though you meant to run the php page
itself as cgi, not the php support. What you need is to run php support
as cgi and then run the php pages through that.

IIRC thttpd doesn't have support for doing that double redirection
directly though, I think you will need to setup the link properly in the
first place (Its need about 4 years since I messed around with thttpd
though so don't take my word for it).

> Because php can definitely run as a cgi - which is why there is a
> package in Debian called php4-cgi. I've found it to be great for testing
> an occasional script on my desktop, before uploading it to the server.
> I've also seen others mention using it for the purpose of having scripts
> run under a different username from apache, using Apache's SuExec
> feature.
>
> I may be misunderstanding what you were trying to say though.
>
> HTH,
> Jacob
>
> --
> GnuPG Key: 1024D/16377135
>
> Random .signature #36:
> Double your disk space - delete Windows!
> http://www.linux.org

0 new messages