Feb 17 2008
Installing GlassFish v2 with PHP5 on Port 80
Welcome to my first blog entry. It’s about installing GlassFish v2 on Opensuse 10.1 with support for PHP5 and running on Port 80.
Note:
Download-links to all files are available at the end of this posting.
Install Java
First you need an installed Java SE Development Kit. I prefer the current version 6. Download JDK6 from: http://java.sun.com/javase/downloads/?intcmp=1281
Opensuse has very old versions in its repository. You can uninstall it using yast or if you have a virtual server, using plesk or confixx.
To check which version is currently installed, open a shell and run the command: java -version.
I will now continue with the installation of a brand new JDK. After you have downloaded the new JDK, switch to the directory and make it runable:
chmod 777 jdk-6u4-linux-i586.bin”
Now start the file:
./jdk-6u4-linux-i586.bin”
You see a License Agreement. Press Q and type yes to agree to the license. Now your JDK is unpacking. After this operation, move the new JDK-folder to /opt
Now change to /usr/lib/jvm
Run: ln -s /opt/jdk-6u4-linux-i586 java
Next, you will have to create an environment variable.
Edit the file /etc/profile
I recommend to use the midnight commander. Open the file and search for export PATH. After this line, insert:
JAVA_HOME="/usr/lib/jvm/java" export JAVA_HOME PATH="$PATH:/usr/lib/jvm/java/bin" export PATH
To check if everything is alright, type java -version.
![]()
Install GlassFish2
Ok, first step is finished, now let’s go to the second step - installing GlassFish2!
Download Glassfish here: https://glassfish.dev.java.net/
Give it the needed rights:
chmod 777 glassfish-installer-v2ur1-b09d-linux.jar
and start the installer:
java -Xmx256m -jar glassfish-installer-v2ur1-b09d-linux.jar
You will see a license message. If you are using KDE or Gnome, watch for a small window popup.
When the unpacking is finished, change to the created directory: cd glassfish
Run: ./lib/ant/bin/ant -f setup.xml
If you have errors, uninstall any existing ANT-versions. GlassFish2 is delievered with an own ANT-version.
So, installation of GlassFish2 is nearly finished. You can start GlassFish2 with the command:
./bin/asadmin start-domain domain1
and stop it with:
./bin/asadmin stop-domain domain1
To see the Glassfish2 Testpage, just browse to:
To access the Server Admin Console, browse to:
http://localhost:4848
Change Port from 8080 to 80
Login to the Server Admin Console
http://localhost:4848
User Name: admin
Password: adminadmin
Navigate to:
Configuration->HTTP Service->HTTP Listeners->http-listener-1
change the Listener Port from 8080 to 80.
Shutdown Glassfish2 and restart it. That’s it!
Install PHP5 Support
Download Qercus 3.1.3 Binary from: http://quercus.caucho.com/
Extract the included JAR’s (quercus.jar, resin-util.jar, script-10.jar)
and move them to: /opt/glassfish/domains/domain1/lib/
![]()
Now create a test-application with your favourite IDE. I prefer Netbeans 6. You need a special WEB.XML :
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<description>Caucho Technology's PHP Implementation, Running on GlassFish Java EE 5</description>
<servlet>
<servlet-name>Quercus Servlet</servlet-name>
<servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Quercus Servlet</servlet-name>
<url-pattern>*.php</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.php</welcome-file>
</welcome-file-list>
</web-app>
Deploy the WAR in the Server Admin Console. Navigate to: Applications->Web Applications->Deploy
Finished!
![]()
Downloads
Hellophp sample application: download
Quercus libs: download



Very nice tutorial, and blog! Even though I am not a Java programmer(yet), you have some excellent posts and tutorials here! I’m actually going to try this one out! Thanks!
mary
[...] first entry shows how to run GlassFish v2 with Quercus (i.e. PHP5) on OpenSUSE 10.1. Given the earlier news on Frank and Ted, this seemed [...]
[...] 10.1 上で GlassFish v2 と Quercus (i.e. PHP5) [...]
[...] 처음 엔트리는 GlassFish v2 와 Quercus를 (예를 들어 PHP5) OpenSUSE 10.1에서 실행하는 방법에 관한 것입니다. Frank [...]
[...] GlassFish v2 与 Quercus (i.e. PHP5) 在 OpenSUSE 10.1上. 给一些更早些的新闻在Frank 和 Ted上, [...]
Did you try to install some common PHP apps, e.g. Wordpress ?
I tried only my own PHP-Webpages. When i have time, i will write a blog-entry about using GlassFish with common PHP apps.
Quercus should work with Wordpress, Mediawiki, and Drupal.
Sir I don’t know from the above para that how could I install php in Glass Fish with jdk-6
It is very useful to us and think that it would be use ful to other
Hello Ganeswar,
first extract the quercus-jar files into the GlassFish-directory and than try to run my example. You can download all files from the “Download”-section of this blog.
Hey, great tutorial, but you forgot the m in your java -Xmx256 -jar glassfish_installer line. should be like java -Xmx256m -jar glassfish_installer….
Hello Danny,
thank you for this special note, i have updated this blog. Without the “m” you will get this error:
Exception in thread “main” java.lang.OutOfMemoryError: Java heap space
WOW! This is great. The download links seem to be broken….any chance of fixing that?
Thanks,
Brad
Thanks for the info Brad, i have fixed the downloads!
I have one question .
Now with Qercus 3.1.3 Java library, is PHP file converted into Java bytecode file that is *.class file?
Is converted Java Bytecode executed on JRE?
Second is I am using Zend Framework 1.5 library with Apache server.Now I am rethinking about my system with GlassFish server because i am java programmer.Then if I put Qercus 3.1.3 Java library and Zend library 1.5(zip file) and mysql_pdo.so(shared object file ) in glass fish library directory then will Zend Framework run correctly? or any other suggestion?
Pls help me .
There is a big bug in article, the servlet-name _must_ be QuercusServlet - without a space! - or glassfish will die. Tested with GlassFish v2.1
Anyway, i got heap space exception too… so i using java-php-bridge.