Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
    
add output "ls -al /usr/bin/php-cgi" –  ooshro Feb 25 '11 at 14:05

2 Answers 2

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
share|improve this answer
    
you have missunderstood me. I want jetty to be able to run php code not only java –  Woho87 Feb 25 '11 at 12:51
    
For run PHP code you need install PHP –  ooshro Feb 25 '11 at 12:53
    
yeah I've already done that. But configuring the servlet and server is the next step which I'm in –  Woho87 Feb 25 '11 at 12:55
    
add output "ls -al /usr/bin/php-cgi" and what your OS? –  ooshro Feb 25 '11 at 12:57
    
I'm conifguring the server on my mac. but the php is working I think. It is the server who isn't –  Woho87 Feb 25 '11 at 13:05

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.