PHP servlet for Jetty

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

PHP servlet for Jetty

Greg Kopff
G'day Jetty-heads :-)

I was asked to post this to this list, and ask for comments.  If you
could CC Gary Kopff <[hidden email]> on any responses,
that would be hugely appreciated. :-)

Thanks everyone.

regards,

Greg.


-------- Original Message --------
Subject: PHP servlet for Jetty
Date: Wed, 01 Jun 2005 11:50:39 +1000
From: Gary Kopff <[hidden email]>
Organization: Wildcard Innovations Pty. Ltd.
To: Greg Kopff <[hidden email]>

Hi Greg,

Wondered if you could do me a favour?

Further to our discussion of PHP support for Jetty, I found this
phpservlet http://tools.herberlin.de/phpservlet/index.shtml
which I then installed into Jetty using the instructions on the above
web site and on this one - http://jetty.mortbay.org/jetty/tut/Server.html

Though the servlet is archived as a war file which Jetty can apparently
unpack on the fly, I found it more convenient to extract the contents
using jar into  my webapps directory. I then configured its
WEB-INF/web.xml file to point to our php executable (/usr/bin/php)

Jetty fires up OK -

11:46:43.890 EVENT  Started WebApplicationContext[/,./webapps/phpservlet]

... and delivers a static page (index.html) from the phpservlet
directory.  However, when I then try to click on any of the php
examples, the browser opens a new window and the status line says
"waiting for gazelle" (our server) and the Mozilla icon just spins. The
Jetty console says -

Jun 1, 2005 11:47:54 AM de.herberlin.phpservlet.PhpServlet init
INFO: PHPServlet/1.1

and the servlet appears to have hung at that point. I know the servlet
tries to execute /usr/bin/php because if you change the path to, say,
/usr/bin/crap you will get a "executable not found" message in
the window. It could be that I have not configured something else quite
right, but I can't see it.

The place I got the servlet from makes no mention of Jetty (just
Tomcat).  The spirit of how one might add PHP support is there (i.e. by
way of a servlet), I am now just looking for a solution that works.

All this is a long-winded way of asking whether you could post a
question on the Jetty forum, does any one know of or recommend a
reliable PHP servlet for Jetty or has anyone ever got the
phpservlet from tools.herblin.de to run on Jetty?

Best Regards

Gary



-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: PHP servlet for Jetty

lwoggardner
Greg/Gary ??,

The CGI servlet that comes with Jetty 5 gets PHP 5.0.3 working for me under Windows XP with the following config fragment.

   <Call name="addContext">
     <Arg>/</Arg>
     <!-- resource base must match php.ini doc_root -->
     <Set name="ResourceBase">C:/unison/web</Set>
     <Call name="addServlet">
       <Arg>Common Gateway Interface</Arg>
       <Arg>*.php</Arg>
       <Arg>org.mortbay.servlet.CGI</Arg>
      <Put name="commandPrefix">C:/PHP/php-cgi.exe</Put>
      <Put name="ENV_REDIRECT_STATUS">200</Put>
      <Put name="ENV_SystemRoot">C:/WINDOWS</Put>
     </Call>
     <Call name="addWelcomeFile">
       <Arg>index.php</Arg>
     </Call>
     <Call name="addHandler">
       <Arg>
         <New class="org.mortbay.http.handler.ResourceHandler">
             <Set name="minGzipLength">8192</Set>
         </New>
       </Arg>
     </Call>
   </Call>

I have not tried a wide variety of PHP apps, and I'm not doing anything production strength, just running dokuwiki and a
few other bits and pieces.

I have previously had a similar thing working for Jetty 4 and an older version of PHP but I had to hack the CGI servlet
to get that to work for both windows and linux.

I'm not sure whether it is PHP5 or Jetty 5 that made it easier now, and I haven't tried this approach on linux as yet.

Hope this helps,
        Grant.

Greg Kopff wrote:

> G'day Jetty-heads :-)
>
> I was asked to post this to this list, and ask for comments.  If you
> could CC Gary Kopff <[hidden email]> on any responses,
> that would be hugely appreciated. :-)
>
> Thanks everyone.
>
> regards,
>
> Greg.
>
>
> -------- Original Message --------
> Subject:     PHP servlet for Jetty
> Date:     Wed, 01 Jun 2005 11:50:39 +1000
> From:     Gary Kopff <[hidden email]>
> Organization:     Wildcard Innovations Pty. Ltd.
> To:     Greg Kopff <[hidden email]>
>
> Hi Greg,
>
> Wondered if you could do me a favour?
>
> Further to our discussion of PHP support for Jetty, I found this
> phpservlet http://tools.herberlin.de/phpservlet/index.shtml
> which I then installed into Jetty using the instructions on the above
> web site and on this one - http://jetty.mortbay.org/jetty/tut/Server.html
>
> Though the servlet is archived as a war file which Jetty can apparently
> unpack on the fly, I found it more convenient to extract the contents
> using jar into  my webapps directory. I then configured its
> WEB-INF/web.xml file to point to our php executable (/usr/bin/php)
>
> Jetty fires up OK -
>
> 11:46:43.890 EVENT  Started WebApplicationContext[/,./webapps/phpservlet]
>
> ... and delivers a static page (index.html) from the phpservlet
> directory.  However, when I then try to click on any of the php
> examples, the browser opens a new window and the status line says
> "waiting for gazelle" (our server) and the Mozilla icon just spins. The
> Jetty console says -
>
> Jun 1, 2005 11:47:54 AM de.herberlin.phpservlet.PhpServlet init
> INFO: PHPServlet/1.1
>
> and the servlet appears to have hung at that point. I know the servlet
> tries to execute /usr/bin/php because if you change the path to, say,
> /usr/bin/crap you will get a "executable not found" message in
> the window. It could be that I have not configured something else quite
> right, but I can't see it.
>
> The place I got the servlet from makes no mention of Jetty (just
> Tomcat).  The spirit of how one might add PHP support is there (i.e. by
> way of a servlet), I am now just looking for a solution that works.
>
> All this is a long-winded way of asking whether you could post a
> question on the Jetty forum, does any one know of or recommend a
> reliable PHP servlet for Jetty or has anyone ever got the
> phpservlet from tools.herblin.de to run on Jetty?
>
> Best Regards
>
> Gary
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by Yahoo.
> Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
> Search APIs Find out how you can build Yahoo! directly into your own
> Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005



-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: PHP servlet for Jetty

peakeyed
I run mediawiki (a php app) on gentoo with jetty 4.2.19 with php5.0.3 in cgi
mode with grant's code (modified for linux).



-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss
Reply | Threaded
Open this post in threaded view
|

Re: PHP servlet for Jetty - patch to CGI servlet to prevent Status: 404 errors

lwoggardner
In reply to this post by lwoggardner
Hi all,

I recently discovered that with my suggested PHP-cgi configuration under Jetty (see below) I was getting Status: 404
headers even though the scripts were parsing successfully and producing perfectly usable text/html output.

PHP-cgi seems to have some historical mess to do with some of the CGI variables and exactly which ones are used to
determine what script is to be parsed and which ones are used to set the 404 header.

The simple fix is for the CGI servlet to pass an extra cgi variable SCRIPT_FILENAME (being the realPath() of the
existing SCRIPT_NAME)

I've attached a patch request to sourceforge
http://sourceforge.net/tracker/index.php?func=detail&aid=1222642&group_id=7322&atid=307322

Cheers,
        Grant.

Grant Gardner wrote:

> Greg/Gary ??,
>
> The CGI servlet that comes with Jetty 5 gets PHP 5.0.3 working for me
> under Windows XP with the following config fragment.
>
>   <Call name="addContext">
>     <Arg>/</Arg>
>     <!-- resource base must match php.ini doc_root -->
>     <Set name="ResourceBase">C:/unison/web</Set>
>     <Call name="addServlet">
>       <Arg>Common Gateway Interface</Arg>
>       <Arg>*.php</Arg>
>       <Arg>org.mortbay.servlet.CGI</Arg>
>      <Put name="commandPrefix">C:/PHP/php-cgi.exe</Put>
>      <Put name="ENV_REDIRECT_STATUS">200</Put>
>      <Put name="ENV_SystemRoot">C:/WINDOWS</Put>
>     </Call>
>     <Call name="addWelcomeFile">
>       <Arg>index.php</Arg>
>     </Call>
>     <Call name="addHandler">
>       <Arg>
>         <New class="org.mortbay.http.handler.ResourceHandler">
>             <Set name="minGzipLength">8192</Set>
>         </New>
>       </Arg>
>     </Call>
>   </Call>
>
> I have not tried a wide variety of PHP apps, and I'm not doing anything
> production strength, just running dokuwiki and a few other bits and pieces.
>
> I have previously had a similar thing working for Jetty 4 and an older
> version of PHP but I had to hack the CGI servlet to get that to work for
> both windows and linux.
>
> I'm not sure whether it is PHP5 or Jetty 5 that made it easier now, and
> I haven't tried this approach on linux as yet.
>
> Hope this helps,
>     Grant.
>



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
jetty-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-discuss