This HTML5 document contains 38 embedded RDF statements represented using HTML+Microdata notation.

The embedded RDF content will be recognized by any processor of HTML5 Microdata.

PrefixNamespace IRI
n6http://www.iodbc.
n19http://www.iodbc.org/dataspace/services/wiki/
dctermshttp://purl.org/dc/terms/
n23http://www.iodbc.org/
atomhttp://atomowl.org/ontologies/atomrdf#
foafhttp://xmlns.com/foaf/0.1/
n22http://virtuoso.openlinksw.com/
n21http://www.iodbc.org/dataspace/person/iodbc#
oplhttp://www.openlinksw.com/schema/attribution#
n26http://www.iodbc.org/dataspace/iodbc#
n7http://www.openlinksw.com/
n2http://www.iodbc.org/dataspace/iodbc/wiki/iodbcWiki/
dchttp://purl.org/dc/elements/1.1/
rdfshttp://www.w3.org/2000/01/rdf-schema#
n5http://www.iodbc.org:80/wiki/main/iodbcWiki/IODBCPHPHOWTO/iodbc-php5.
n18http://rdfs.org/sioc/services#
siocthttp://rdfs.org/sioc/types#
n11http://community.openlinksw.com/
n8http://www.iodbc.org/dataspace/iodbc/wiki/
n14https://shop.openlinksw.com/license_generator/uda/
n28http://localhost/info.
n31http://www.php.net/
n27http://support.openlinksw.com/
rdfhttp://www.w3.org/1999/02/22-rdf-syntax-ns#
n24http://httpd.apache.org/
n29http://www.iodbc.org/odbcstory.
xsdhhttp://www.w3.org/2001/XMLSchema#
n9https://shop.openlinksw.com/license_generator/virtuoso/
n30http://www.php.net/manual/en/install.macosx.
n34http://www.iodbc.org/dataspace/dav#
n17http://www.iodbc.org/dataspace/iodbc/wiki/iodbcWiki/IODBCPHPHOWTO/sioc.
siochttp://rdfs.org/sioc/ns#
n32http://www.iodbc.org/dataspace/person/dav#
n33http://www.php.net/support.
n12http://uda.openlinksw.com/odbc/
Subject Item
n2:IODBCPHPHOWTO
rdf:type
atom:Entry sioct:Comment
dcterms:created
2016-09-14T12:28:33.942728
dcterms:modified
2019-03-20T09:56:21.892162
rdfs:label
IODBCPHPHOWTO
foaf:maker
n21:this n32:this
n18:has_services
n19:item
dc:title
IODBCPHPHOWTO
sioc:link
n2:IODBCPHPHOWTO
sioc:id
7b8747350d16225dc5bbfc172a28dd23
opl:isDescribedUsing
n17:rdf
sioc:links_to
n6:org n7: n9: n11: n12: n14: n22: n23: n24: n27: n28:php n29:htm n30:php n31: n33:php
sioc:has_creator
n26:this n34:this
sioc:has_container
n8:iodbcWiki
atom:source
n8:iodbcWiki
atom:title
IODBCPHPHOWTO
atom:author
n32:this
atom:published
2016-09-14T12:28:33Z
atom:updated
2019-03-20T09:56:21Z
sioc:content
---+ iODBC-PHP-Apache HOWTO for Linux/UNIX Systems %TOC% ---++Disclaimer The following is a HOWTO document for installing PHP with iODBC as an Apache module on Linux or Unix. Feel free to criticize, suggest modifications, or ask further questions. It is currently maintained by Tim Haynes of Openlink Software (<code>iodbc&#64;openlinksw.com</code>). Prerequisites include basic Unix familiarity, such as creating directories and users, using an editor, etc. This HOWTO is intended to assist in connecting <code>php</code>/<code>apache</code> to back end databases via ODBC in a development environment and should not take the place of thorough testing before deployment on a production system. ---++ ODBC Overview ODBC (Open Database Connectivity) is an operating system- and database-independent communication API that allows a client application (productivity tool, other database, web page, custom application, etc.) to communicate via standards-based function calls to a backend database without relying on that vendor's proprietary communication protocols. ODBC connections involve an application, driver manager, driver, and database. The driver manager under Microsoft Windows platforms is the ODBC Control Panel. The driver manager registers a set of ODBC driver connection parameters called a Data Source Name (DSN). An application looks to the driver manager for a DSN, and then passes the connection parameters specified in the DSN to the appropriate driver, which makes the connection. Under non-Windows platforms you may need to install a Driver Manager. iODBC is an Open Source Driver Manager maintained by <nop>OpenLink Software. It is released under a dual LGPL / BSD license. ---++ Preface You will also need an ODBC Driver and Database to complete the architecture. If you need ODBC drivers to connect to a third-party database on the same or another machine, [[http://uda.openlinksw.com/odbc/][OpenLink ODBC Drivers]] are available, and may be [[https://shop.openlinksw.com/license_generator/uda/][downloaded for free trial]]. The [[http://virtuoso.openlinksw.com/][Virtuoso database]] may also be [[https://shop.openlinksw.com/license_generator/virtuoso/][downloaded for free trial]]. Support with downloading, installing, configuring, and testing these <nop>OpenLink products may be obtained through the [[http://community.openlinksw.com/][OpenLink Community Space]]. ---++ Compiling PHP with linked iODBC Driver Manager as an Apache shared module The process is fairly straightforward. You will need to be a user who has sufficient privileges to perform all of these steps as well. Root privileges can be obtained by typing <code>su root</code> and entering your root password, but be forewarned that you can easily destroy your system as <code>root</code>. If you use root privileges, please do so on a test machine. Set up a build location, and get the latest builds of [[http://www.iodbc.org/][iODBC]], [[http://httpd.apache.org/][Apache]], and [[http://www.php.net/][PHP]]. Set some environment variables: <verbatim> export LD_LIBRARY_PATH=/usr/local/src/odbcsdk/lib:$LD_LIBRARY_PATH </verbatim> - this tells the compiler where to find the driver manager. If you prefer to statically link iODBC then remove or rename <code>libiodbc.so</code> from the above path, and <code>libiodbc.a</code> will be statically linked instead. ---++ Building Apache We build <code>apache</code> with support for dynamic modules and APXS: <verbatim> cd httpd-1.3.* ./configure --prefix=/usr/local/apache --enable-module=so --enable-mods-shared=[list of modules] nice make &amp;&amp; su root -c 'make install' </verbatim> Choose the list of modules to go with whatever you expect to be loading from your <code>httpd.conf</code> (or similar). Among other things, authentication, dav (in the case of Apache 2.x), ssl, virtualhosting, user-tracking, spelling-correction, proxying, SSI, fine control of MIME data, etc. -- these are all configurable at this time. After a while, Apache should finish compiling and install itself into <code>/usr/local/apache/</code>. ---++ Compiling PHP Unpack the PHP sources with a command like -- <verbatim> tar xvpfj php-4.3.2.tar.bz2 </verbatim> -- and change into the resultant directory. Note: if you are using iodbc-3.51.0, this will expose a problem in PHP's configure script whereby it assumes the only library required is <code>-liodbc</code>, when it should be calling "<code>iodbc-config --libs</code>" to determine the <code>LDFLAGS</code> required. This causes a <code>debug.log</code> to be created as PHP is configured, and while it may build seemingly to completion, the resultant PHP library will give unresolved symbol errors, and apache will fail to start. [[%ATTACHURLPATH%/php-configure-iodbc.diff][This patch]] can be applied to PHP's <code>./configure</code> script to avoid the problem. PHP needs to be configured with a pointer both to Apache that you installed earlier, and to the ODBC SDK (<code>iodbc</code> directory): <verbatim> bash$ ./configure --prefix=$HOME/php5 \ --enable-discard-path \ --with-layout=GNU \ --with-openlink=/usr/local/openlink/odbcsdk \ --enable-experimental-zts \ --with-regex=php \ --enable-experimental-zts \ --enable-debug \ --enable-calendar \ --with-iodbc=/usr/local/openlink/odbcsdk \ --without-mysql \ --disable-sockets \ --disable-cli \ --with-apxs=/usr/local/apache/sbin/apxs \ --enable-embed=share{,d} bash$ nice make bash$ su root -c 'make install' </verbatim> The process of installing here will invoke <code>apxs</code>, Apache's utility for making installation of modules an awful lot easier. This should also include making minor changes to your <code>httpd.conf</code> (so to be safe, back it up first) - namely these: <verbatim> LoadModule php5_module extramodules/libphp5.so </verbatim> and <verbatim> AddModule mod_php5.c </verbatim> Also, the following should be set: <verbatim> AddType application/x-httpd-php .php .php4 .php3 .phtml AddType application/x-httpd-php-source .phps </verbatim> ---++ Restarting Apache Use the command: <verbatim> /usr/local/apache/sbin/apachectl start </verbatim> to start apache. Should it fail to start, you'll be best off checking <code>logs/error_log</code> to see why it failed: there are a multitude of possible configuration errors, from typos, through failure to access files to which it should have permission, processes already using the socket configured for listening, and more. ---++ Checking your PHP installation Create a simple PHP starter script, e.g., <code>info.php</code>, containing nothing but the line: <verbatim> &lt;?php phpinfo(); ?> </verbatim> Ensure that the permissions are acceptable - <code>644</code> (owner read+write, everyone else read-only) should suffice. Put it in your <code>htdocs/</code> directory, or somewhere else accessible under your webserver configuration (e.g., <code>~/public_html/</code>). Point your browser to http://localhost/info.php to see all PHP's configuration information. ---++ Environment Variable concerns There are two files that your ODBC-using PHP scripts must be able to access: * <code>libiodbc.so</code> - PHP requires this to be in the list of directories searched, so if you export <code><nowiki>LD_LIBRARY_PATH</nowiki></code> either before starting <code>apache</code>, or using the <code><nop>SetEnv</code> directive in <code>httpd.conf</code>, it should be able to access the driver manager. * <code>odbc.ini</code> - this is accessed by the driver manager, <code>libiodbc.so</code>, and contains a list of all your DSNs and their connect info, etc. In order to find this, iODBC uses the <code>ODBCINI</code> environment variable, or failing that it will search <code>/etc/odbc.ini</code> or <code>~/.odbc.ini</code> instead. You can either export this in <code>httpd.conf</code>, or before Apache starts, or from within your PHP script itself with the <code>setenv()</code> function call. ---++ Sample PHP script The following script effects a connection to a database (<code>Local Virtuoso Demo</code> is the default DSN), and either executes a query or lists tables present in that database. <verbatim> &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> &lt;html> &lt;head> &lt;title>OpenLink Virtuoso test of ODBC access through PHP hosting&lt;/title> &lt;link type="text/css" rel="STYLESHEET" media="ALL" href="../../tutorial.css" /> &lt;/head> &lt;body> &lt;h1>Testing ODBC connectivity from PHP hosted within Virtuoso&lt;/h1> &lt;hr /> &lt;?php # set global variables based on the form thing - see `register global # variables' and PHP security updates $query=$_POST['query']; $uid=$_POST['uid']; $passwd=$_POST['passwd']; $listtables=$_POST['listtables']; $DSN=$_POST['DSN']; $exec=$_POST['exec']; ?> &lt;p>Enter the parameters for your query here:&lt;/p> &lt;form action="odbc-sample.php" method="post"> &lt;div> &lt;span class="caption">DSN&lt;/span> &lt;input type="text" name="DSN" value="&lt;?php print ($DSN&lt;>"")?$DSN:"Local Virtuoso Demo" ?>" /> &lt;span class="caption">UserID&lt;/span> &lt;input type="text" name="uid" value="&lt;?php print ($uid&lt;>"")?$uid:"demo" ?>" /> &lt;span class="caption">Password&lt;/span> &lt;input type="password" name="passwd" value="&lt;?php print ($passwd&lt;>"")?$passwd:"demo"?>" /> &lt;/div> &lt;div> &lt;span class="caption">Query&lt;/span> &lt;input type="text" name="query" value="&lt;?php print ($query&lt;>"")?$query:"select top 100 * from Demo..Customers" ?>" /> &lt;/div> &lt;div> &lt;input type="submit" name="exec" value="Execute query" /> or &lt;input type="submit" name="listtables" value="List Tables" /> &lt;/div> &lt;/form> &lt;hr /> &lt;?php if($query&lt;>"" &amp;&amp; $DSN&lt;>"" &amp;&amp; $exec!=NULL) { print "&lt;h2>Results:&lt;/h2> "; print "&lt;p>Connecting... "; $handle=odbc_connect ("$DSN", "$uid", "$passwd"); if(!$handle) { print "&lt;p>Uh-oh! Failure to connect to DSN [$DSN]: &lt;br />"; odbc_errormsg(); } else { print "done&lt;/p> "; $resultset=odbc_exec ($handle, "$query"); odbc_result_all($resultset, "border=2"); odbc_close($handle); } } if($listtables!=NULL) { print "&lt;h2>List of tables&lt;/h2>"; print "&lt;p>Connecting... "; $handle=odbc_connect ("$DSN", "$uid", "$passwd"); print "done&lt;/p> "; if(!$handle) { print "&lt;p>Uh-oh! Failure to connect to DSN [$DSN]: &lt;br />"; odbc_errormsg(); } else { $resultset=odbc_tables($handle); odbc_result_all($resultset, "border=2"); odbc_close($handle); } } ?> &lt;/body> &lt;/html> </verbatim> ---++ Concerns and Improvements Historically, iODBC has not been fully supported in PHP. We made a patch addressing these issues: * ODBC 3.52 datatypes are now used, to comply with ODBC64 spec on Win64 and 64-bit <nop>*nix platforms * Enabled use of <code><nop>SQLDriverConnect()</code>, array fetching, and other advanced PHP API functions * Made the static cursor model the default (instead of dynamic), to speed up advanced drivers. The cursor model can be selected by a setting in <code>php.ini</code>. This patch has been incorporated into PHP around version 5.2.11 and above. To use this patch with older versions of PHP, first download it: <code>[[%ATTACHURLPATH%/iodbc-php5.diff][iodbc-php5.diff]]</code> Second, apply it using <code>patch(1)</code>: <verbatim> bash$ tar xvfpj php-5.2.5.tar.bz2 php-5.2.5/ php-5.2.5/ext/ php-5.2.5/ext/gd/ php-5.2.5/ext/gd/gd.c php-5.2.5/ext/gd/gd_ctx.c ... bash$ patch -p0 &lt; ../iodbc-php5.diff patching file ext/odbc/php_odbc.c Hunk #26 succeeded at 1644 (offset 1 line). Hunk #27 succeeded at 1715 (offset 1 line). Hunk #28 succeeded at 1777 (offset 1 line). Hunk #29 succeeded at 1863 (offset 1 line). Hunk #47 succeeded at 3603 (offset 1 line). patching file ext/odbc/php_odbc.h patching file ext/odbc/php_odbc_includes.h </verbatim> You can now resume the build process from the "<code>./configure</code>" step above. ---++ References * PHP on macOS [[http://www.php.net/manual/en/install.macosx.php][installation instructions]] * [[http://www.iodbc.org][iODBC.org]] * History of [[http://www.iodbc.org/odbcstory.htm][ODBC on Unix]] * [[http://www.php.net/support.php][PHP main site]] * [[http://www.openlinksw.com/][OpenLink Software]] * [[http://community.openlinksw.com/][Community Space]] * [[http://support.openlinksw.com/][Support Center and Case System]]
sioc:topic
n8:iodbcWiki
sioc:attachment
n5:diff