13 Replies Latest reply on Apr 14, 2009 11:23 AM by peterj

    Deploying PHP application in JBoss Portal

    ernitingoel

      Hi,

      Can some one help me to find out the steps needed to deploy a PHP application in JBoss Portal?

      The all the links which I have found talks about jbossweb.sar, which itself is not there in Jboss Portal. I am using JBoss Portal 2.6.4.

      Thanks,
      Nitin Goel

        • 1. Re: Deploying PHP application in JBoss Portal
          peterj

          Yes, if you install JBoss Native, you can run PHP applications within JBossAS. But Java-based portals have very specific APIs which are not available in PHP. That is, you cannot write a portlet using PHP. Your only hope is to use an iframe portlet (the portlet swap web site has one) to host a PHP site.

          • 2. Re: Deploying PHP application in JBoss Portal
            ernitingoel

            Hi Peter,

            Thanks for your quick response. I am new to JBoss. I am having a PHP application which I want to deploy in JBoss Portal and then develop the portlet which will communicate with the PHP application and show the web pages of PHP application. Could you please let me know whether this is possible or not in the latest version? If yes then what are the steps I need to perform for that.

            I have not found jbossweb.sar any where, could you please also let me know where can I find that and the steps needed to setup JBoss so that PHP application can run under it? I can use Linux (Ubuntu) or Windows Vista platform for that.

            Thanks,
            Nitin Goel

            • 3. Re: Deploying PHP application in JBoss Portal
              peterj

              To add PHP suppport to JBossAS:

              1) Download and install JBoss Native for your OS: http://www.jboss.org/jbossweb/downloads/jboss-native/?action=a&windowstate=maximized
              2) Download and install the PHP servlet for your OS: http://www.jboss.org/jbossweb/downloads/php/?action=a&windowstate=maximized

              Also see some of the discussions at:
              http://www.jboss.com/index.html?module=bb&op=viewtopic&t=125437
              http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4123263

              The best way to use a PHP app within the portal is to use the IFrame portlet, which you can download from http://www.jboss.org/portletswap/portlets_misc.html

              (You do not need jbossweb.sar for hosting PHP apps in JBossAS.)

              • 4. Re: Deploying PHP application in JBoss Portal
                ernitingoel

                Thanks a lot Peter. I will try that and get back to you in case I will be having any problem.

                Thanks,
                Nitin Goel

                • 5. Re: Deploying PHP application in JBoss Portal
                  ernitingoel

                  Hi Peter,

                  I am able to deploy PHP application on JBoss on Windows. To help out others, I am mentioning here the steps I have performed.

                  1. Download and install JBoss Native for your OS: http://www.jboss.org/jbossweb/downloads/jboss-native/?action=a&windowstate=maximized

                  2 Download and install the PHP servlet for your OS: http://www.jboss.org/jbossweb/downloads/php/?action=a&windowstate=maximized

                  3. Download PHP 5.2:
                  http://www.php.net/downloads.php

                  4. Copy JBoss Native into JBoss Portal directory, confirm whether you have JBOSS_PORTAL_HOME/bin/native directory

                  5. Set the php5servlet\bin & php5servlet\bin\ext in PATH variable.

                  6. Download php5servlet.dll from

                  http://members.cox.net/ocjohnsons/php5servlet.zip

                  Replace it with php5servlet\bin

                  7. Copy php5servlet\webapps\php-examples.war into JBOSS_PORTAL_HOME\server\default\deploy.

                  8. Modify php5servlet\webapps\php-examples.war\web.xml
                  Replace
                  <servlet-class>org.apache.catalina.servlets.php.Handler</servlet-class>
                  with
                  <servlet-class>org.jboss.web.php.Handler</servlet-class>
                  and
                  Replace <servlet-class>org.apache.catalina.servlets.php.Highlight</servlet-class>
                  with
                  <servlet-class>org.jboss.web.php.Highlight</servlet-class>

                  9. Add



                  in JBOSS_PORTAL_HOME\server\default\deploy\jboss-web.deployer\server.xml

                  10. Download jbossweb-extras.jar for php http://anonsvn.jboss.org/repos/jbossreflex/trunk/php/jbossweb-extras.jar

                  Copy to JBOSS_PORTAL_HOME\server\default\deploy\lib

                  11. Start the server and access http://localhost:8080/php-examples/index.php

                  Thanks,
                  Nitin Goel

                  • 6. Re: Deploying PHP application in JBoss Portal
                    sii

                    Hi,

                    Can some experts out there please help me out on this error: java.lang.UnsatisfiedLinkError: C:\jboss-4.2.3.GA\bin\native\php5servlet.dll: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem, no libphp5servlet in java.library.path(C:\jdk\jdk1.6.0_07\bin;C:\mysql5\bin;C:\jboss-4.2.3.GA\bin;C:\jboss-4.2.3.GA\bin\native;C:\php5\bin;C:\php5\ext;)

                    OS: Windows XP (not install any .NET framework)
                    ANT version: Ant 1.7.1
                    JDK version: jdk1.6.0 update 07
                    Database: mysql-5.0.67
                    Web server: jboss-4.2.3.GA (unpack jboss-portal-2.7.0.GA-bundled.zip)
                    Mysql connector/J: mysql-connector-java-5.1.6
                    PHP version: php-5.2.6-Win32
                    PHP servlet version: php5servlet-windows-i586-SP1
                    JBoss native: jboss-native-2.0.6-windows-x86-ssl

                    ANT_HOME=C:\ant-1.7.1
                    JAVA_HOME=C:\jdk\jdk1.6.0_07
                    JBOSS_HOME=C:\jboss-4.2.3.GA
                    CLASSPATH=.;C:\jdk\jdk1.6.0_07\lib\tools.jar;C:\jboss-4.2.3.GA\bin\run.jar;C:\jboss-4.2.3.GA\server\default\lib\mysql-connector-java-5.1.6-bin.jar;
                    PATH=C:\ant-1.7.1\bin;C:\jdk\jdk1.6.0_07\bin;C:\mysql5\bin;C:\jboss-4.2.3.GA\bin;C:\jboss-4.2.3.GA\bin\native;C:\php5;C:\php5\ext;

                    Steps
                    1. Unpack apache-ant-1.7.1-bin.zip to c:\ant-1.7.1
                    2. Install jdk-6u7-windows-ia64.exe at c:\jdk\jdk1.6.0_07
                    3. Install mysql-5.0.67-win32.zip at c:\mysql5
                    4. Unpack jboss-portal-2.7.0.GA-bundled.zip to c:\jboss-4.2.3.GA
                    5. Edit c:\jboss-4.2.3.GA\bin\run.bat, set -Xms1024m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m
                    6. Unpack mysql-connector-java-5.1.6.zip, copy mysql-connector-java-5.1.6-bin.jar to c:\jboss-4.2.3.GA\server\default\lib\
                    7. Configure c:\jboss-4.2.3.GA for mysql datasource
                    8. Unpack php-5.2.6-Win32.zip to c:\php5
                    9. Unpack php5servlet-windows-i586-SP1.zip to c:\php5servlet
                    10. Copy missing .dll files from c:\php5servlet\bin\ext to c:\php5\ext
                    11. Copy missing .dll files from c:\php5servlet\bin to c:\php5
                    12. Copy php5servlet.dll downloaded at http://members.cox.net/ocjohnsons/php5servlet.zip to c:\php5
                    13. Copy c:\php5\php.ini-recommended to c:\windows
                    14. Edit c:\windows\php.ini, change extension_dir="c:/php5/ext"
                    15. Add to c:\jboss-4.2.3.GA\server\default\deploy\jboss-web.deployer\server.xml
                    16. Add to c:\jboss-4.2.3.GA\server\default\deploy\jboss-web.deployer\conf\web.xml as below:

                    <servlet-name>php</servlet-name>
                    <servlet-class>org.jboss.web.php.Handler</servlet-class>
                    <init-param>
                    <param-name>debug</param-name>
                    <param-value>0</param-value>
                    </init-param>
                    <load-on-startup>6</load-on-startup>


                    <servlet-name>phps</servlet-name>
                    <servlet-class> org.jboss.web.php.Highlight</servlet-class>


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

                    <welcome-file-list>
                    <welcome-file>index.html</welcome-file>
                    <welcome-file>index.htm</welcome-file>
                    <welcome-file>index.jsp</welcome-file>
                    <welcome-file>index.php</welcome-file>
                    </welcome-file-list>

                    17. Download jboss-native-2.0.6-windows-x86-ssl.zip at http://www.jboss.org/jbossweb/downloads/jboss-native/?action=a&windowstate=maximized
                    18. Unpack jboss-native-2.0.6-windows-x86-ssl.zip to c:\jboss-native-2.0.6-windows-x86-ssl
                    19. Copy *.dll from jboss-native unpack folder to c:\jboss-4.2.3.GA\bin\native
                    20. Copy php5servlet.dll downloaded at http://members.cox.net/ocjohnsons/php5servlet.zip to c:\jboss-4.2.3.GA\bin\native
                    21. Append to c:\jboss-4.2.3.GA\bin\run.conf as below:
                    LD_LIBRARY_PATH=c:/jboss-4.2.3.GA/bin/native
                    export LD_LIBRARY_PATH
                    22. Create mysql db=testdb, create table=users, create column=user_id, first_name, last_name
                    23. Create index.php at c:\jboss-4.2.3.GA\server\default\deploy\jboss-web.deployer\ROOT.war\index.php as below:
                    <?php
                    $username = "root";
                    $password = "mysqlpassword";
                    $hostname = "localhost";
                    $dbh = mysql_connect($hostname, $username, $password)
                    or die("Unable to connect to MySQL");
                    print "Connected to MySQL";
                    $selected = mysql_select_db("testdb",$dbh) or die("Could not select testdb");
                    if (mysql_query("insert into users values('1','fname_user1','lname_user1')")) {
                    print "successfully inserted record";
                    }
                    else {
                    print "Failed to insert record";
                    }
                    mysql_close($dbh);
                    ?>

                    24. Create index.php at c:\jboss-4.2.3.GA\server\default\deploy\jboss-web.deployer\ROOT.war\fetch.jsp as below:
                    <%@ page import="java.sql.*" %>
                    <%
                    String connectionURL = "jdbc:mysql://localhost/testdb";
                    Connection connection = null;
                    Statement statement = null;
                    ResultSet rs = null;
                    %>


                    <%
                    Class.forName("com.mysql.jdbc.Driver").newInstance();
                    connection = DriverManager.getConnection(connectionURL, "root", "mysqlpassword");
                    statement = connection.createStatement();
                    rs = statement.executeQuery("SELECT * FROM users");
                    while (rs.next()) {
                    out.println(rs.getString("first_name"));
                    }
                    rs.close();
                    %>



                    25. At command prompt, type 'cd c:\jboss-4.2.3.GA\bin'
                    26. Then, run.bat -c default -b 0.0.0.0
                    27. Browse to http://localhost:8080/index.php prompt error as below:
                    java.lang.UnsatisfiedLinkError: C:\jboss-4.2.3.GA\bin\native\php5servlet.dll: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem, no libphp5servlet in java.library.path(C:\jdk\jdk1.6.0_07\bin;C:\mysql5\bin;C:\jboss-4.2.3.GA\bin;C:\jboss-4.2.3.GA\bin\native;C:\php5\bin;C:\php5\ext;)
                    28. Browse to http://localhost:8080/fetch.jsp show 'fname_user1' on screen.

                    Can some expert out there help me out to compile a php5servlet.dll which is compatible with above scenario:

                    I am sure others out there also having the same problems. Would appreciate if some experts out there can help me out on this for few days.

                    Thanks a lot,
                    Eunice

                    • 7. Re: Deploying PHP application in JBoss Portal
                      peterj

                      This topic, and the ones I refer to, contain probably all of the information I know about about getting PHP to work.

                      Most likely the the phpservlet.dll is missing a dependency. To check this out, get a copy of the Dependency Walker (it comes with the XP support tools available of the XP installation CD, or google for it). Load the phpservlet.dll into the Dependency Walker and see if it reports anything missing.

                      Another possibility is that the phpservlet.dll is once again using the wrong class name (as mentioned in one of the topics I linked to above), in which case you will have to compile it from source (looks like the windows download is still outdated).

                      Oh, and you are not running a 64-bit XP by any chance? If so, you will have to use a 32-bit JVM or the php5servlet.dll will not load.

                      • 8. Re: Deploying PHP application in JBoss Portal
                        sii

                        Hi Peter,

                        Thanks a lot for the reply. PHP finally work.
                        Run dependency walker to check php5servlet.dll, found msvcr80.dll missing. After install .net framework 3.5 SP1 the problem is fix. Also, added to step 20.5. added jbossweb-extras.jar for php downloaded at http://anonsvn.jboss.org/repos/jbossreflex/trunk/php/jbossweb-extras.jar to
                        c:\jboss-4.2.3.GA\server\default\deploy\lib.

                        However, dependency walker show 'Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.'

                        Thanks alot,
                        Eunice

                        • 9. Re: Deploying PHP application in JBoss Portal
                          peterj

                          Yes, you will get that warning even when you have everything you need to run PHP. There is one DLL missing (gpsvc.dll - it is never used) and a few entry points are missing from two other DLLs). But the C runtime DLL (msvcr80.dll) is critical!

                          • 10. Re: Deploying PHP application in JBoss Portal
                            txue

                            Hi Nitin Goel

                            I have a very similar project you had experienced before. I have a couple of PHP applications which I want to deploy in JBoss Portal and then develop the portlets which will communicate with the PHP application and show the web pages of PHP application. Could you please let me know If you have successfully done this and then what are the steps I need to perform for that and expecially how to develop portlet to communicate with the php application. If you can send me some sample code that will be great. I appreciate your help and time.

                            Thanks.

                            tina

                            • 11. Re: Deploying PHP application in JBoss Portal
                              valatharv

                              Hi,

                              I am trying to configure php first time on Jboss4.2.3-GA on Win-32 bit, you all seems to be expert... I need suggestion for point 19..

                              I already have jboss4.2.3.GA configured.
                              ------------------------------------------------------------------
                              17. Download jboss-native-2.0.6-windows-x86-ssl.zip at http://www.jboss.org/jbossweb/downloads/jboss-native/?action=a&windowstate=maximized : OK
                              18. Unpack jboss-native-2.0.6-windows-x86-ssl.zip to c:\jboss-native-2.0.6-windows-x86-ssl :OK

                              19. Copy *.dll from jboss-native unpack folder to c:\jboss-4.2.3.GA\bin\native
                              a) There is no native directory under "c:\jboss-4.2.3.GA\bin", so I can create one ?
                              b) After unzipping I get the following structure, I need to copy all dlls under
                              C:\jboss-native-2.0.6-windows-x86-ssl\bin\META-INF\lib\windows\x86 to c:\jboss-4.2.3.GA\bin\native

                              C:\jboss-native-2.0.6-windows-x86-ssl>
                              ├───bin
                              │ │ jbosssvc.exe
                              │ │ jbossweb.exe
                              │ │ jbosswebw.exe
                              │ │ README-service.txt
                              │ │ service.bat
                              │ │
                              │ └───META-INF
                              │ ├───bin
                              │ │ └───windows
                              │ │ └───x86
                              │ │ openssl.exe
                              │ │
                              │ └───lib
                              │ └───windows
                              │ └───x86
                              │ libapr-1.dll
                              │ libaprutil-1.dll
                              │ libeay32.dll
                              │ libtcnative-1.dll
                              │ ssleay32.dll
                              │
                              └───licenses
                              │ JBossORG-EULA.txt
                              │
                              ├───apr
                              │ LICENSE
                              │ NOTICE
                              │
                              ├───apr-iconv
                              │ LICENSE
                              │ NOTICE
                              │
                              ├───apr-util
                              │ LICENSE
                              │ NOTICE
                              │
                              ├───httpd
                              │ LICENSE
                              │ NOTICE
                              │
                              ├───info-zip
                              │ LICENSE
                              │
                              ├───openssl
                              │ LICENSE
                              │
                              └───zlib
                              README

                              • 12. Re: Deploying PHP application in JBoss Portal
                                valatharv

                                Sorry, don't know how tree structure was corrupted... just missed to preview before posting.

                                • 13. Re: Deploying PHP application in JBoss Portal
                                  peterj

                                  a) Yes
                                  b) Yes

                                  Here is what happened. Earlier versions of JBoss Native included all of their DLLs in a 'native' directory. The run.bat file in JBoss AS 4.2.x looks for the 'native' directory and if it finds it adds it to the PATH. So the whole point is to match up the DLL locations in JBoss Native with the PATH location coded into run.bat. And you can do that either by copying the DLLs to native, or changing the run.bat to look for the DLLs elsewhere.