1

I want to configure so that jetty runs PHP files, but have been unsuccessful so far. I have Jetty WTP tools installed in my Eclipse IDE.

When I start up the Jetty server. I got the exception: java.lang.ClassNotFoundException org.mortbay.servlet.CGI: org.mortbay.servlet.CGI and javax.servlet.UnavailableException: org.mortbay.servlet.CGI. I put a simple php file(index.php) under my WebContent folder. I also downloaded this library and added it to the classpath(Eclipse: build path and add external jar). I have no clue now what I've done wrong. I also compiled php with:

./configure --with-fastcgi=/usr/local
make
sudo make install

And my web.xml file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>Sample PHP Application</display-name>
    <servlet>
        <servlet-name>PHP</servlet-name>  
        <servlet-class>org.mortbay.servlet.CGI</servlet-class>
        <init-param>
            <param-name>commandPrefix</param-name>
            <param-value>/usr/local/bin/php-cgi-fix</param-value>
        </init-param>
    </servlet>

    <servlet-mapping>
        <servlet-name>PHP</servlet-name>
        <url-pattern>/index.php/*</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>index.php</welcome-file>
    </welcome-file-list> </web-app>

It could be my php-cgi-fix file, I got the followig text i terminal when i open it:

$ /usr/local/bin/php-cgi-fix ; exit;
/usr/local/bin/php-cgi-fix: line 3: /usr/bin/php-cgi: No such file or directory
logout

Shouldn't be /usr/local/php-cgi instead? Ok I tried that now, but still I got the same ecxeptions when I launch the server.

(I really don't like to use maven too

ooshro
  • 11,134
  • 1
  • 32
  • 31
einstein
  • 119
  • 1
  • 3

2 Answers2

0

Install php-cgi(contain /usr/bin/php-cgi).

Ubuntu/Debian:

sudo apt-get install php5-cgi

CentOS/Red Hat/Fedora:

yum install php-cli

In Mac OS try create symlink:

sudo ln -s /usr/bin/php /usr/bin/php-cgi
ooshro
  • 11,134
  • 1
  • 32
  • 31
0

If your php-cgi-fix script comes from Jetty and PHP then it is no longer required, you can just call php-cgi directly.

22 days after you asked the question but if you are still not there then I'd suggest getting this running outside of Eclipse first. Enable debugging and look for lines in the log containing "CGI" and also set init_param "ignoreExitState" to "true".

Questions about Jetty and PHP come up about once a year on the mailing list so my guess is very few people are doing this. You may well be the first to do this on a Mac with a particular version of Jetty.