A simple way to get PHP working within Sun Web Server 7 on Solaris / RHEL
By sriram on Aug 05, 2009
Some time back, I wrote this blog on how to leverage the PHP runtime integrated within OpenSolaris and use it to run PHP applications within Sun Java System Web Server 7. Well, if you are currently using Sun Web Server 7 on Solaris 10 or RedHat / CentOS Linux and wondering if there is a more simplified way to get PHP working within Sun Web Server 7, then my today's topic might be of more use to you.
Installing Sun Web Server
Now, if you are new to Sun Web Server 7 and wonder why you need this beast, please do check out some of these performance benchmark blogs within our wiki. You can download and install the latest version of Sun Java System Web Server from here .
If you are adventurous, you can also build the open sourced version of this beast (available under BSD license) by following the instructions provided here.
If you would like a little hand holding in installing our product, check out this nice demo . Hope, you are able to successfully install Sun Web Server 7 with the help of this demo. If not, you can always post your questions in our forums - where we developers will be happy to help you out !.
Installing Sun GlassFish Web Stack PHP
If you haven't yet heard of Sun Web Stack or more confusingly known as Sun GlassFish Web Stack - is an open source project within OpenSolaris - known as Web Stack project - offers free download and production support (as part of Sun GlassFish Portfolio) for open source web tier components like Apache Web Server, PHP, MySQL, Tomcat, Hudson etc on Solaris 10 Update 5 (or above) and RedHat Enterprise Linux 5.2 (or above).
Here is a quick way to get Web Stack PHP installed on your Solaris 10 or RHEL 5. If you prefer a little hand holding, please refer to my earlier blog on the different ways to install Sun Web Stack (along with some screenshots to guide you along the way).
Here is a quick walk through on how to get your PHP runtime installed
- Visit our Sun Web Stack 1.5 download web page and download 'click on IPS based Packaging' link for your respective OS.
- Now, you will need to unzip the downloaded tar ball and either fire up the update tool GUI for installing PHP runtime (as shown in this blog) or simply install it in the command line as shown below:
sriramn@sriramn:~$ unzip webstack-image-1.5-b09-redhat-i586.zip
sriramn@sriramn:~$ cd webstack1.5
sriramn@sriramn:~/webstack1.5$ ./pkg/bin/pkg install sun-php52 sun-php52-apc
Note: If you are interested in other PHP optional packages like PHP MySQL connector or MySQL community package etc, you could get the list of packages available either from GUI or CLI. From CLI, you could do some thing like as shown below
sriramn@sriramn:~/webstack$ ./pkg/bin/pkg list -a -> to list all the component available from our repository
Note: Unlike OS native packages, IPS based installation (that you just did here) does not verify or warn if you do not have installed any underlying dependent libraries that Web Stack 1.5 stack requires. So, we strongly recommend you to visit our System Package dependency link to ensure that you have these packages installed on your system.
How to get Web Stack PHP working within Sun Web Server 7 ?
Ok, Assuming you have successfully installed Web Server 7 and Sun Web Stack PHP on your system, here is a simple one liner configuration script that you can run to successfully configure Web Server 7 to execute PHP scripts .
sriramn@sriramn:~/webstack1.5$ ./php/5.2/samples/scripts/configure-sun-webserver --installroot=/home/sriramn/ws7 --instancename=
Note: On Linux, because of a bug with the above script, please download this script and overwrite it over the default.
cp /tmp/configure-sun-webserver ~/webstack1.5/php/5.2/samples/scripts/
That is all there to it.
Now, you should be able to run php scripts under your web server's document root directory (which is typically <ws7-install-root>/https-<hostname>/docs/).
Note: In the above example, I have assumed that you will be installing both
Web Server 7 and Web Stack PHP as the same user and you wanted to configure PHP runtime with the default instance (https-<hostname>) created by Web Server 7
installer. If in case, you would like to configure a separate instance for Web Server 7 then you could do the same either using Web Server 7 Administration CLI /GUI. Here is a simple example of how to do so with CLI :
sriramn@sriramn:~/webserver7$ ./bin/wadm create-config --user=admin --http-port=80 --server-name=<ĥostname> php
sriramn@sriramn:~/webserver7$ ./bin/wadm disable-java --user=admin --config=php
sriramn@sriramn:~/webserver7$ ./bin/wadm create-instance --config=php <hostname.domainname>
sriramn@sriramn:~/webserver7$ ~/webstack1.5/php/5.2/samples/scripts/configure-sun-webserver --installroot=~/webserver7 --instancename=