by Cezar Andrei, May 13th, 2011
These steps were checked on Ubuntu 10.10. Send us email with the results you had on diffrent platforms.
$ sudo apt-get install apache2
Once the web server installation is done, PHP5 needs intalled also.
$ sudo apt-get install php5 php5-dev libapache2-mod-php5 php5-curl php5-gd \
php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ps \
php5-pspell php5-recode php5-snmp php5-tidy php5-xmlrpc php5-xsl php5-common
Let's create a new PHP file to ensure everything is working:
$ sudo pico /var/www/test.php
Add this code to the file:
<?php phpinfo(); ?>
Restart Apache so all the prior changes get applied:
$ sudo /etc/init.d/apache2 restart
Now using a web browser point it to: http://localhost/test.php
Check if php works corectly.
Get Zorba sources and follow Build Instructions.
Check Zorba is working.
$ zorba -q '2+1' <?xml version="1.0" encoding="UTF-8"?> 3
Check php test is working.
$ ctest -R php Start processing tests Test project /tmp/zorba-1.2.0/build 1188/1188 Testing php Passed 100% tests passed, 0 tests failed out of 1
Passing the php test means that PHP5 is instlled corectly and there is a succesfull build that includes the PHP swig binding.
Copy Zorba extension library files to /usr/local/lib/php/.
zorba/build$ cp swig/php/zorba_api.so swig/php/zorba_api_wrapper.php /usr/local/lib/php/
Add the folowing lines to /etc/php5/apache2/php.ini file.
include_path="/usr/local/lib/php/"
extension=/usr/local/lib/php/zorba_api.so
Restart Apache Http server
$ sudo /etc/init.d/apache2 restart
Refresh browser: http://localhost/test.php
Check if zorba_api is in the list of php known extensions.
Add the following content to /var/www/zorba.php:
<html> <title>Zorba test</title> <body> <?php // include Zorba API require_once 'zorba_api_wrapper.php'; // create Zorba instance in memory $ms = InMemoryStore::getInstance(); $zorba = Zorba::getInstance($ms); try { // create and compile query string< $queryStr = '1+2'; $query = $zorba->compileQuery($queryStr); // execute query and display result $result = $query->execute(); echo $result; // clean up $query->destroy(); $zorba->shutdown(); InMemoryStore::shutdown($ms); } catch (Exception $e) { die('ERROR:' . $e->getMessage()); } ?> </body> </html>
Point your browser to http://localhost/zorba.php and see the result.
For more details on how to use Zorba API in PHP go to Building XQuery-powered applications with PHP and Zorba article by Vikram Vaswani.
Install PHP 5, Apache 2 and MongoDB on Ubuntu 10.10