Installing software from its source has its advantages: you can check out newly developed features, have access to bug fixes before new binary packages are released, and get to get a glimpse of the internals of the project. This is a step-by-step guide to installing Obyx on your Mac, running Mac OS X 10.5 or newer.

Getting started

First of all, if you haven't already, you need to install the Mac developer tools. You can get the developer tools from your OS X DVD, or you can download it from Apple here. While you are installing it, you also need to download the following prerequisite libraries on which Obyx depends (download the source tarballs for them): You should extract all of these somewhere easy to locate. You also need a basic installation of MySQL to use the database features of Obyx. MySQL can be downloaded as a package from here: MySQL Be sure to download a version which matches your computer's architecture! (ie. 32-bit/64-bit/PPC/Intel) Alternatively, you may wish to use PostgreSQL as your database engine.

Building the libraries

Once you have finished downloading and extracting the prerequisite libraries, you need to fire up Terminal.app, (if you're not sure where this is, you can find it in Applications/Utilities). Your first job is to build the Xerces library, which is used in Obyx for XML validation. To build it, you need to type the following commands:
cd Download Directory/xerces-c-3.1.0/
./configure
make
sudo make install
This will take some time, once it's done, you can build XQilla, which is used for Obyx's XPath support. To do that, type the following:
cd Download Directory/XQilla-2.2.0/
./configure
make
sudo make install
You must also follow the same process for cURL:
cd Downloads/curl-7.2.0/
./configure
make
sudo make install
Finally, you must build PCRE, which Obyx uses as it's regular expression engine. This is built similarly to the other libraries, however, note the difference in the configure script. This enables use of the UTF-8 character set in Obyx.
cd Downloads/pcre-7.9/
./configure --enable-utf8
make
sudo make install

Building Obyx

You are now ready to build Obyx! You can either download the files from http://www.obyx.org/obyxdownloads.obyx, or you can check out the very latest version of the files by using svn. If you wish to use svn, type the following commands in your terminal:
cd Download Directory
svn checkout http://svn.obyx.org/obyx/supported/version1 obyx

This will create a folder called obyx in your download directory.

Either way you download Obyx, to proceed with the installation, go to the Obyx folder in you download directory. You will see a file named 'obyx.xcodeproj'. Double click this to open it in xcode.

You should now see the xcode window. On the left of the window is a list of files and folders in the Obyx project. Right click the topmost icon in this list (a blue icon labeled 'obyx') and click 'Get Info'.

Click the 'Build' tab at the top of this window. Click on the value column of the item labeled 'Architectures' and select 'Native Architecture of Build Machine'. Likewise, for Base SDK, select Current Mac OS.

Close this window and go to "Project"->"Edit active target obyx.cgi", click the Build tab again and enter the search term 'mysql' into the search bar.

You should see a number of results, among them, two named 'Other C Flags' and 'Other C++ Flags'. Double click 'Other C Flags' and remove the second occurence of '-D' and the occurence of 'ALLOW_POSTGRESQL' using the minus button, assuming you are using only MySQL. If you are using only PostgreSQL, remove the ALLOW_MYSQL and first occurrence of '-D'. If you have installed both database engines, no change is required. After you have made the appropriate changes, click 'Ok'.

Close the project info box, and click the Build icon (the hammer). After a short time, you should see the text 'Succeeded' at the bottom right of the window. If so, congratulations! You have successfully built Obyx.

Setting up Apache

The final step is to configure Apache to work with Obyx.

Firstly, ensure that you have web sharing enabled. To do this, open System Preference, click Sharing, and ensure that 'Web Sharing' is checked. Keep this window open.

We are going to create a quick addition to your apache configuration to enable obyx files to run. Firstly, open a text editor, and paste the following into it:

If using a .cf ensure you do not reference it using a symlink
 ScriptAlias	/x						/Library/WebServer/CGI-Executables
 AddType		application/obyx+xml	.obyx            
 Action			application/obyx+xml		/x/obyx.cgi

SetEnv OBYX_ROOT_DIR          /Library/WebServer
SetEnv OBYX_PUBLIC_DIR        Documents
SetEnv OBYX_SCRIPTS_DIR       scripts
SetEnv OBYX_SQLSERVICE        mysql
SetEnv OBYX_SQLDATABASE       obyx
SetEnv OBYX_SQLHOST           localhost
SetEnv OBYX_SQLPORT           3306
SetEnv OBYX_SQLUSER           obyx
SetEnv OBYX_SQLUSERPW         obyx

#set the following, if debugging or using breakpoints in obyx files.
SetEnv OBYX_DEVELOPMENT       true

#if using Mac OS X, or using custom paths for shared libraries..
#Mac OS X uses dylib suffix
SetEnv OBYX_LIBCURLSO         /usr/lib/libcurl.dylib
SetEnv OBYX_LIBPCRESO         /usr/local/lib/libpcre.dylib

#Mysql Library location 
SetEnv OBYX_LIBMYSQLCRSO      /usr/local/mysql/lib/libmysqlclient_r.dylib
SetEnv OBYX_LIBZIPSO          /usr/lib/libz.dylib

#PostgreSQL Library Location
#SetEnv OBYX_LIBPQSO           /opt/local/lib/postgresql84/libpq.dylib

Note that the database connection details will be incorrect, unless you have set up a user and database with these credentials. You should change this to something else if you have already set up your database.

Save this file as obyx.conf to the directory /private/etc/apache2/other/ (You may have to enter your password to do this).

Go back to your System Preferences window. Uncheck the 'Web Sharing' checkbox, and check it again.

Your Obyx installation should now be fully installed. Try placing the following Obyx file in /Library/WebServer/Documents/hello_world.obyx

<instruction xmlns="http://www.obyx.org">
   <input wsstrip="true">
       <instruction note="load view">
           <output space="store" value="v" />
           <input space="file" value="hello_world.html" />
       </instruction>
       <iteration operation="sql" note="get model">
           <output space="store" value="v#//*[@id='msg']/text()" />
           <control>select "Hello World! If you can see this then Obyx is working." as message</control>
           <body space="field" value="message" />
       </iteration>
       <instruction note="display view">
           <input space="store" value="v" />
       </instruction>      
   </input>
</instruction>
and the following HTML file in /Library/WebServer/Documents/hello_world.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<title>Hello World View</title>
</head>
<body><div id="msg">Message</div></body>
</html>

Go back to your 'System Preferences' window again and Click the second blue link link ("Your computer's website is available at this address"). This should open your browser. Change the address to include hello_world.obyx at the end.

If you see the words "Hello World! If you can see this then Obyx is working." Your installation was successful, congratulations!

If you have run into problems, please contact the Obyx usergroup at ...




Last Modified: Thu, 15 Jan 2015