WSO2 for PHP installation on Centos 6

WSO2 for PHP is a Web Services framework that works as a PHP extension and provides support for key WS-* specifications. Using this framework one can easily create server and client side Web Service applications that can easily integrate with Java or .NET systems (which are both the most common languages used for building Web Services).

Installation of this framework on most linux systems used to be easier on earlier versions of WSO2 when rpm and deb packages were available for download. This is not the case anymore.

So to install the latest stable version (2.1.0 at the time of writing this post) on linux you have to compile from sources. On Centos 6 this is fairly easy as all required packages are included in the default Centos 6 repositories and no external sources are required.

First you have to install some prequisities (all commands provided until the end of this how-to should be run as the root user):

yum -y install php php-xml gcc php-devel openssl-devel libxml2-devel

My test system was a Centos 6 Base Server installation which already includes httpd and openssl. If this is not the case for your system then do this:

yum -y install httpd openssl

Now you are ready to install the framework so download the sources. I recommend downloading the tar.gz file which is smaller in size.

wget http://wso2.org/products/download/wsf/php/2.1.0/wso2-wsf-php-src-2.1.0.tar.gz
tar xvzf wso2-wsf-php-src-2.1.0.tar.gz
cd wso2-wsf-php-src-2.1.0
./configure
make
make install
cp -R ./scripts/* /usr/share/php

Everything should go well and no errors should appear after the ./configure , make , make install commands. If there was any error you can google it or send me a message.

Now a new module has been created and copied to the php modules folder and all we have to do is include it in our php configuration so we create a new file for this purpose:

touch /etc/php.d/wsf.ini
echo "extension=wsf.so" > /etc/php.d/wsf.ini
service httpd restart

Lastly you have to open the appropriate firewall ports (if they are not open laready):

system-config-firewall-tui -> customize -> check "WWW" and "Secure WWW" -> close -> ok -> yes

and (re)start the web server:

service httpd restart
chkconfig httpd on

To see if everything went as planned we can test the WSO2 installation using the samples provided with the sources. So we copy the samples folder to the root of our web server (the name of the folder should not be altered or the examples will not work!):

cp -R ./samples /var/www/html

Now you can use your web browser and open the URL http://<server>/samples where <server> is of course the IP address or hostname of the server on which you have installed the framework. From there you can select to run the first client sample (echo client) and an XML containing “Hello World!” should appear. If you get an error 505 or any other error try restarting your web server:

service httpd restart

Please keep in mind that this how-to does not work for Centos 5 as the default php version for Centos 5 is 5.1.x and WSO2 requires php version 5.2.0 or later. Centos 6 has php 5.3 in the base repositories. There is a solution for Centos 5 but you should really know what you are doing before procceeding with that!

EDIT (24 Mar 2012):

For WSDL generation to work properly you have to copy the contents of the scripts folder to a folder contained in php.ini’s include path entry (or add another entry for the include_path directive).

The easiest way to do this is copy these files to the /usr/share/php folder which is already included in the path entry on CentOS 6.

cp -R ~/wso2-wsf-php-src-2.1.0/scripts/* /usr/share/php

3 thoughts on “WSO2 for PHP installation on Centos 6

    1. I believe the WSO2 people have decided to terminate support for this product. Not only do all links found on the web return either 403 or 404, the product is not listed on their main page.

      I am going to see if I can get SOAP to work.

Leave a comment