Build a RPM Package of the WSO2 WSF/PHP 2.1 for Zend Server 5
By Antonio Musarra
- 1 Jun, 2011
- Creating the RPM package WSO2 WSF/PHP
- Installing the package WSO2 WSF/PHP
In this tutorial we will see how to build the RPM package of WSO2 WSF / PHP 2.1 or later to be installed Zend application server. Following are the main requirements to build the RPM package for WSO2 WSF/PHP.
- A development machine with the installation of Linux development tools
- Zend Server 5.x (Community Edition or Enterprise Edition)
- RPM Spec file for WSO2 WSF/PHP 2.1
To build this package, it's a good idea to use one of the distributions suggested by Zend, which supports the RPM format. Refer to the document Choosing Which Distribution to Install which gives a complete table of the Linux distributions that supports the installation of RPM packages. I recommend you to use the same Linux distribution (suggested by Zend) for both test and production environments.
Creating the RPM package WSO2 WSF/PHP
My setup for this tutorial is as below:
- Linux Distribution CentOS 5.6 x86_64 on VirtualBox 4.0.6
- Zend Server 5.1 Community or Enterprise Edition (PHP 5.2)
Build the RPM package with the follwing steps:
1. Download the source WSO2 WSF/PHP 2.1
# cd /usr/src/redhat/SOURCES # wget https://dist.wso2.org/products/wsf/php/2.1.0/wso2-wsf-php-src-2.1.0.tar.gz
2. Checkout RPM spec file wsf-zend-server.spec
# cd /usr/src/redhat/SPECS # svn export https://svn.wso2.org/repos/contrib/wsf/php/trunk/build/packaging/rpm/wsf-zend-server.spec
3.Build the RPM package
# cd /usr/src/redhat # rpmbuild -bb SPECS/wsf-zend-server.spec
The last command, rpmbuild, performs all actions shown on the spec file, generating the end of the RPM package by placing it in the build /usr/src/redhat/RPMS/x86_64/. The generated package is called WSO2-wsf-php-2.1.0-1.x86_64.rpm, you can test a range of information on the package you just created using the command:
# cd /usr/src/redhat # rpm -qp RPMS/x86_64/wso2-wsf-php-2.1.0-1.x86_64.rpm
The command output should be similar to this:
Name : wso2-wsf-php Relocations: (not relocatable) Version : 2.1.0 Vendor: WSO2 Inc. https://wso2.org Release : 1 Build Date: Tue 03 May 2011 06:55:34 PM CEST Install Date: (not installed) Build Host: shirus-fe-testlab.localdomain Group : Development/Tools Source RPM: wso2-wsf-php-2.1.0-1.src.rpm Size : 24598922 License: Apache License V2.0 Signature : (none) Packager : Antonio Musarra <[email protected]> URL : https://wso2.com/products/web-services-framework/php/ Summary : WSO2 WSF/PHP 2.1 Web Services Framework for PHP (Build for Zend Server 5.1) Description : WSO2 Web Services Framework for PHP (WSO2 WSF/PHP), a binding of WSO2 WSF/C into PHP is a PHP extension for providing and consuming Web Services in PHP. WSO2 WSF/PHP supports SOAP 1.1, SOAP 1.2, WSDL 1.1, WSDL 2.0, REST style invocation as well as some of the key WS-* stack specifications such as: SOAP MTOM, WS-Addressing, WS-Security,WS-SecurityPolicy and WS-ReliableMessaging.
Installing the package WSO2 WSF / PHP
The package you created earlier is now ready to be installed on the target machine, in our case the target machine is the same one used to build the package. Follow the steps below to install the package:
- Install the software in to the directory /opt/wso2
- Install the code samples and documentation in the document root of the web server
- Install the module in wsf /usr/local/zend/lib/php_extensions/
- Create and install in /etc/profile.d/ the file that sets the necessary environment variables
- Create and install in /usr/local/zend/etc/conf.d/wsf.ini the file that contains the module configuration wsf/php
- Runs through the configuration of the Dynamic Linker ldconfig
- Runs the restart Zend Server to load the module wsf.so
To install the package simply run the command shown below, you can still perform an audit installation using the command rpm with --test option.
# cd /usr/src/redhat # rpm -ihv RPMS/x86_64/wso2-wsf-php-2.1.0-1.x86_64.rpm
The installation performs all the steps listed above, the output from the installation phase should be similar to the following:
Preparing... ############################# [100%] 1:wso2-wsf-php ############################# [100%] Running ldconfig... Restart Zend Server... Restarting Zend Server 5.1.0 .. Stopping Zend Server Monitor node [OK] Stopping httpd: [ OK ] Stopping Session Clustering daemon [OK] Stopping JobQueue [OK] Stopping Zend Server GUI [Lighttpd] [OK] Starting Zend Server Monitor node [OK] [ 06.05.2011 14:12:54 SYSTEM] watchdog for monitor is running. [ 06.05.2011 14:12:54 SYSTEM] monitor is running. Starting httpd: [ OK ] Starting Session Clustering daemon [OK] [ 06.05.2011 14:12:56 SYSTEM] watchdog for scd is running. [ 06.05.2011 14:12:56 SYSTEM] scd is running. Starting JobQueue [OK] [ 06.05.2011 14:12:57 SYSTEM] watchdog for jqd is running. [ 06.05.2011 14:12:57 SYSTEM] jqd is running. spawn-fcgi: child spawned successfully: PID: 29907 Starting Zend Server GUI [Lighttpd] [OK] [ 06.05.2011 14:12:59 SYSTEM] watchdog for lighttpd is running. [ 06.05.2011 14:12:59 SYSTEM] lighttpd is running. Zend Server started... Copied samples folders in /opt/wso2/wsf_php to your Web Root /var/www/html Added directory /opt/wso2/wsf_php/scripts/ to include_path directory eg. include_path = ".:/opt/wso2/wsf_php/scripts/"
A quick verification of proper installation can be done by running the command php, for sure that the WSF/PHP module is loaded correctly (see the full command below).
# /usr/local/zend/bin/php -i|grep wsf /usr/local/zend/etc/conf.d/wsf.ini, wsf wsf support => enabled wsf version => 2.1.0 wsf.attachment_cache_dir => /tmp => /tmp wsf.enable_attachment_caching => 0 => 0 wsf.home => /opt/wso2/wsf_c => /opt/wso2/wsf_c wsf.log_level => 4 => 4 wsf.log_path => /tmp => /tmp wsf.rm_db_dir => /tmp => /tmp
The command output shows the version of the form (in this case 2.1) and configuration, the latter defined within file /usr/local/zend/etc/conf.d/wsf.ini. Is possible to run the same test using the console offered by Zend Server, the console can be reached at https://localhost:10081/ (see Figure 1)
The contents of the file /usr/local/zend/etc/conf.d/wsf.ini (shown below) sets the configuration of the module wsf, as well as overwrite the current parameter setting include_path adding the directory /opt/wso2/wsf_php/scripts/. Advisable to check the parameter in order to avoid any malfunctions on your current configuration.
include_path = ".:/usr/local/zend/share/ZendFramework/library:/usr/local/zend/share/pear:/opt/wso2/wsf_php/scripts/" [wsf] extension=wsf.so wsf.home="/opt/wso2/wsf_c" wsf.log_path="/tmp" wsf.rm_db_dir="/tmp"
The manual of the framework and the code samples were installed in the document root of the web server, both within their respective addresses, and https://localhost/docs https://localhost/samples. In Figure 2 shows the examples page installed, while in Figure 3 shows an example of a calculator that uses the web services created with WSF/PHP to do the arithmetic operations.
I think it will be useful for all of you to have the Virtual Appliance I used for the preparation of this tutorial. I exported the Virtual Appliance formats OVF and published at the following address:
- Cent OS 5.6 OVF https://rapidshare.com/files/461521692/centos5.6-wsfphp2.1-zde5.1-1.tar.gz
- MD5 Hash: https://rapidshare.com/files/461518340/centos5.6-wsfphp2.1-zde5.1-1.md5.txt
The community edition of Zend Server is installed into the Virtual Appliance.
Here are some necessary info for using the Virtual Appliance (in Figure 4 it shows the desktop icons including the Virtual Appliance Zend and WSO2 Server):
- Username / Password: wso2/linuxwso2
- Password root user: linuxwso2
- Zend Server 5.1
- Installed in /usr/local/zend
- Web Console: https://localhost:10081
- Web Console Password: zend
- Init scripts in /etc/init.d/zend-server
- WSO2 WSF/PHP
- Installed in /opt/wso2
- Sample in /var/www/samples
- Docs in /var/www/docs
- Configuration /usr/local/zend/etc/conf.d/wsf.ini
- Module in /usr/local/zend/lib/php_extensions/
Using the Virtual Appliance with virtualization software like VirtualBox is fast and easy. To understand the necessary steps to import/export and also for more information, please read the Importing and exporting virtual machines guide. If you need to import the Virtual Appliance to VMWare, you can use the VMware OVF Tool.
In this tutorial we have seen all the steps necessary to implement the RPM package containing the binary framework of the WSO2 WSF/PHP. The procedure is simple and straightforward, the RPM package is ready to be installed on your Zend Server 5.x.
Senior Consultant in Altran Italia S.p.A,.
Antonio is doing business consulting for projects in the enterprise application development using web-oriented technologies such as J2EE, Web Services, ESB and PHP.