Installing WSO2 WSF PHP on Ubuntu

回覆文章
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Installing WSO2 WSF PHP on Ubuntu

文章 yehlu »

http://www.cloud-corporate.com/index.ph ... tent&id=57

Getting Started with Web Services in PHP with Ubuntu 8.04
September 15th, 2008 · 2 Comments · php, wsfphp, wso2
What is a Web Service?

W3C define Web Service as "a software system designed to support interoperable machine-to-machine interaction over a network. It has an interface described in a machine-processable format (specifically WSDL). Other systems interact with the Web service in a manner prescribed by its description using SOAP messages, typically conveyed using HTTP with an XML serialization in conjunction with other Web-related standards.".

Communication between Web Service and Web Service client are done by exchanging XML messages. Those XML message formats are defined using XML Schema. And SOAP is the standard way of packaging actual payload inside standard XML format which consists of SOAP Envelop, Header and the SOAP Body. SOAP Body carries the actual payload and SOAP Headers are used for carrying information related to quality of service stuff. WSDL describes the API exposed by Service providing party in standard and interoperable manner using messages, operations, port types, bindings and service elements.

There are so many things to read about those standards if anyone want to thoroughly understand the Web Services and it's standards. I believe that's the main point behind people are using some other protocols and standards in the scenarios that Web Services are more suitable.
Why PHP is so important?

This is the era of Dynamic Languages. Use of Dynamic Languages in day to day programming has increased during last couple of years and PHP is the language of Web even though there is rise of Ruby usage. There are lot of content management systems and web based application written using PHP and lack of interoperability among them is major concern over the years even though normal web programmer don't feel it.

If we can have APIs exposed in awesome web applications out there which will help others to collaborate between those web applications and there own web or desktop applications, that will be a huge advantage.

For example, Microsoft Sharepoint has a Web Services layer that will help all other Microsoft products to collaborate with Sharepoint. If we can have something like that for PHP applications put there it will give us more opportunities, capabilities and flexibility in using them.

So WSF/PHP is a effort to break the barriers in conventional PHP based web applications and I believe that it will help us to make more collaborative, inter operable and standardize web applications in the future.

From this point onwards I'll guide you to getting started with WSF/PHP.

Installing Apache Web Server and PHP in Ubuntu

You can use following command to install Apache Web Server:

sudo apt-get install apache2

To install development headers for Apache 2 you can use following command:

sudo apt-get install libapr1-dev apache2-prefork-dev

Command to install PHP:

sudo apt-get install libapache2-mod-php5 php5 php5-dev php5-xsl

The above commands install development packages because of we need them when compiling WSF/PHP from the source.
Installing WSF/PHP 2.0

First you have to download the newly released version 2.0 source package from http://wso2.org/downloads/wsf/php.After download is finished, extract the source and run following commands while you are in the root directory of the WSF/PHP source.

./configure
make
sudo make install

After installing the WSF/PHP using above commands, you have to enable WSF/PHP module and XSL module by adding following lines to php.ini located at /etc/php5/apache2/php.ini(This is default location of th php.ini when you install php and apache using aptitude).

# configuration for php XSL module
extension=xsl.so
#Enabling WSF/PHP Extension
extension=wsf.so

After enabling the WSF/PHP module you have to set the include_path variable in php.ini. Add the path to the scripts folder located at WSF/PHP source distribution to include_path like following example.

;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;

; UNIX: "/path1:/path2"
include_path = ".:/home/milinda/projects/wso2-wsf-php-src-2.0.0/scripts"
;
; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"

; The root of the PHP pages, used only if nonempty.
; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root
; if you are running php as a CGI under any web server (other than IIS)
; see documentation for security issues. The alternate is to use the
; cgi.force_redirect configuration below
doc_root =

After this step you have to copy the 'samples' directory located at WSF/PHP source directory to '/var/www' directory. After copying the samples run following command to restart the apache server.

sudo /etc/init.d/apache2 restart

After restarting the Apache server you can go to http://localhost/samples using your prefered browser and try the available samples. Also you will be able to examine the source of the samples and WSDLs using link provided by that page.

You can try samples available with WSF/PHP or you can try to write your own PHP web services and clients by reading documentation available with WSF/PHP distribution. Also you can find interesting articles in http://phpwebservices.blogspot.com. This is no the end, in the next post of WSF/PHP series I'll show you how to do some nice things with WSF/PHP.

PS
還要裝 apt-get install pkg-config
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Re: Installing WSO2 WSF PHP on Ubuntu

文章 yehlu »

http://www.cloud-corporate.com/index.ph ... tent&id=57

Installing WSO2 WSF PHP on Ubuntu 9.04

The official Installation instructions are split across these 2 documents here and here but I found them a bit confusing so here are the steps I followed to install WSF PHP on Kubuntu 9.04, the Jaunty Jackalope!

sudo apt-get install apache2 php5 libapache2-mod-php5 libxml2 libxml2-dev php5-xsl

cd /usr/src

## #check the latest stable version avaliable here http://wso2.org/downloads/wsf/php then download it
wget http://dist.wso2.org/products/wsf/php/2 ... 0.0.tar.gz

tar -xzvf wso2-wsf-php-src-2.0.0.tar.gz

./configure
make
sudo make install

### edit php.ini with your favourite editor

sudo kate /etc/php5/apache2/php.ini

### add the lines below
### I like to keep all my logs under /var/log but you choose your favourite location
### log_level2 shows warnings and errors

include_path = ".:/usr/share/php:/usr/lib/php5/20060613+lfs/wsf_c/scripts"
extension=wsf.so
extension=xsl.so

[wsf]
wsf.home="/usr/lib/php5/20060613+lfs/wsf_c"
wsf.log_level=2
wsf.log_path="/var/log/wsf"

sudo cp -rf /usr/src/wso2-wsf-php-src-2.0.0/samples /var/www

### I thought I shouldn't need to do this but on my system the install script did not do this
sudo cp -rf /usr/src/wso2-wsf-php-src-2.0.0/scripts/usr/share/php:/usr/lib/php5/20060613+lfs/wsf_c/

/etc/init.d/apache2 restart

Then I was able to go to http://localhost/samples and run the examples

If you have any questions email faqs [at] cloud-corporate.com
回覆文章

回到「PHP」