Not logged in : Login

About: VOSBldPHP     Goto   Sponge   NotDistinct   Permalink

An Entity of Type : atom:Entry, within Data Space : ods.openlinksw.com associated with source document(s)

AttributesValues
type
Date Created
Date Modified
label
  • VOSBldPHP
maker
Title
  • VOSBldPHP
isDescribedUsing
has creator
content
  • %VOSWARNING% %VOSNAV% ---++PHP SAPI module for Virtuoso This is a SAPI module for PHP 5.x, implemented as a Virtuoso loadable module. ---+++Building php To build the plugin, you first need to build a libphp5.so, configured with ZTS (Zend Thread Safety), thus download a copy of the [[http://www.php.net/downloads/][PHP sources]]. The version tested against was 5.2.10. 1 In the php source directory, execute something similar to: <verbatim> ./configure \ --prefix=/usr/local/php-5.2.10 \ --enable-maintainer-zts \ --enable-embed=shared \ --with-config-file-path=. \ --with-tsrm-pthreads \ --disable-static \ --disable-cgi \ --disable-ipv6 \ --without-mysql \ --without-pear \ --enable-bcmath=shared \ --enable-calendar \ --enable-dbase=shared \ --enable-dba=shared \ --enable-dom=shared \ --enable-exif=shared \ --enable-ftp=shared \ --enable-gd-native-ttf \ --enable-mbstring=shared \ --enable-pdo \ --enable-shmop=shared \ --enable-soap=shared \ --enable-sockets=shared \ --enable-sysvmsg=shared \ --enable-sysvsem=shared \ --enable-sysvshm=shared \ --enable-wddx=shared \ --enable-xmlreader=shared \ --enable-xmlwriter=shared \ --with-bz2=shared \ --with-curl=shared \ --with-gd=shared \ --with-iodbc=/usr/local/iODBC \ --with-ldap=shared \ --with-mime-magic=shared \ --with-openssl=shared \ --with-pdo-odbc="generic,/usr/local/iODBC,iodbc,-L/usr/local/iODBC/lib,-I/usr/local/iODBC/include" \ --with-sqlite=shared \ --with-xmlrpc=shared \ --with-xsl=shared \ --with-xsl=shared \ --with-zlib \ ... NOTE: The options above require a number of other libraries to be installed prior to building PHP. On systems where these external libraries are not available as system libraries you may need additional configure options to point where certain libraries are installed. </verbatim> 1 Next build and install the php packages. <verbatim> make make install </verbatim> 1 In the Virtuoso Open Source directory, execute the following command: <verbatim> ./configure .... --enable-php5=/usr/local/php-5.2.10 ...... or if you configured Virtuoso before in this directory: ./config.nice --enable-php5=/usr/local/php-5.2.10 so the build process knows where to find the necessary PHP header files. </verbatim> At the end of the configure step, the summary screen should indicate that the BUILD_OPTS includes "php5". If this is not the case the config.log file should contain information why configure was unable to locate your php5 installation. ---+++Installation 1 Copy the libphp5.so into same directory where virtuoso installs the hosting_php5.so plugin e.g. <verbatim> PREFIX/hosting/libphp5.so. </verbatim> 1 If you have built PHP with shared extensions, you can copy them in <verbatim> PREFIX/hosting/php </verbatim> 1 Copy the php.ini-recommended from the php distro to the same directory as your virtuoso.ini e.g. <verbatim> PREFIX/database/php.ini. </verbatim> 1 Edit your php.ini to change the extensions_dir setting to the directory where you put your extensions, e.g. <verbatim> extensions_dir = PREFIX/hosting/php </verbatim> 1 Register the plugin in your virtuoso.ini: <verbatim> [Plugins] .. Load7 = attach, libphp5.so Load8 = Hosting, hosting_php.so </verbatim> This will enable the hosting_php plugin to dynamically hook into the PHP library. ---+++ Virtuoso PHP Extensions ---++++Settings The Virtuoso php hosting plugin adds the following default settings to the php.ini file: <verbatim> [Virtuoso] virtuoso.logging = On virtuoso.local_dsn = Local Virtuoso virtuoso.allow_dba = 0 </verbatim> If <code>virtuoso.logging<code> is On, all php messages are passed back to the virtuoso logwriter. The <code>virtuoso.local_dsn</code> is by default set to "Local Virtuoso" which is the DSN in your odbc.ini file normally associated with your local virtuoso database. The <code>virtuoso.allow_dba</code> option rejects the use of the dba uid when using the <code>&#95;&#95;virt&#95;internal&#95;dsn()</code> function detailed below. ---++++Functions <b> &#95;&#95;virt&#95;internal&#95;dsn([optional dsn])</b> Normally when programming a PHP application you have to store datasource, username and password credentials for making ODBC connections back into the database. This can be a security risk and requires the administrator to fix scripts manually when he wants to run a hosted application under its own sql account. The &#95;&#95;virt&#95;internal&#95;dsn() function returns an ODBC connect string based on the VSP user that owns the Virtual Directory. It starts by verifying that the Virtual Directory has been properly setup and that there is a valid user that has not been disabled and is allowed to make SQL connections, else it will log a message and return FALSE. If the user is a system privileged user like dba or dav and the virtuoso.allow.dba setting is disabled, the function will log a message and return FALSE. The function will return an ODBC <nop>SQLDriverConnect string using either the supplied optional dsn or the virtuoso.local&#95;dsn and the uid/pwd credentials of the virtual directory in the form: <verbatim> DSN=use_dsn;UID=uid;PWD=pwd </verbatim> This string can be used directly with the odbc_connect function in your script. If you want your PHP application also outside of the virtuoso hosting environment, you can use it like this: <verbatim> <?php // // ODBC Connection Variables // $o_DSN = 'ChangeMe'; $o_UID = 'ChangeMe'; $o_PWD = 'ChangeMe'; if (function_exists ('__virt_internal_dsn')) { $db = odbc_connect (__virt_internal_dsn(), null, null); } else { $db = odbc_connect ($o_DSN, $o_UID, $o_PWD); } if (!$db) error_log ('odbc_connect failed'); // ..... odbc_disconnect ($db); ?> </verbatim> Here is an example of a Virtuoso SQL script that creates a database schema and a table, a user that owns the schema and a vhost entry that can be used for a PHP application. <verbatim> myapp.sql: -- -- Sample script -- -- -- Create the MYAPP schema -- use MYAPP ; -- -- Create a user MYADMIN who owns the table in this schema -- db.dba.user_create ( 'MYADMIN', -- Account name uuid (), -- Random UUID as password vector ('LOGIN_QUALIFIER', 'MYAPP', 'SQL_ENABLE', 1, 'DAV_ENABLE', 0, 'FULL_NAME', 'MYAPP Administrator')) ; -- -- Create the tables in this schema -- create table MYTABLE ( mt_id INTEGER NOT NULL PRIMARY KEY, mt_value VARCHAR (32) ) ; -- -- Insert some sample data -- insert into MYAPP.DBA.MYTABLE VALUES (1, 'Apple'); insert into MYAPP.DBA.MYTABLE VALUES (2, 'Pear'); insert into MYAPP.DBA.MYTABLE VALUES (3, 'Banana'); insert into MYAPP.DBA.MYTABLE VALUES (4, 'Pineapple'); -- -- Add permissions -- grant all privileges on MYAPP.DBA.MYTABLE to MYADMIN ; -- -- Create a new virtual path in Virtuoso -- -- Point to $VIRTUOSO/vsp/testapp on filesystem -- db.dba.vhost_remove (lpath=>'/myapp'); db.dba.vhost_define ( lpath=>'/myapp', ppath=>'/testapp', is_dav=>0, is_brws=>0, vsp_user=>'MYADMIN', def_page=>'myapp.php') ; -- -- End of sample -- </verbatim> And the $VIRTUOSO/vsp/testapp/myapp.php: <verbatim> <?php $db = odbc_connect (__virt_internal_dsn(), null, null); if (!$db) error_log ('odbc_connect failed'); $rs = odbc_exec ($db, 'select * from MYAPP.DBA.MYTEST'); odbc_result_all ($rs); odbc_close ($db); ?> </verbatim> %VOSCOPY%
id
  • ce3943ba6c2830951f035dd67486e1ed
link
has container
http://rdfs.org/si...ices#has_services
atom:title
  • VOSBldPHP
links to
atom:source
atom:author
atom:published
  • 2017-06-13T05:46:48Z
atom:updated
  • 2017-06-13T05:46:48Z
topic
is made of
is container of of
is link of
is http://rdfs.org/si...vices#services_of of
is links to of
is creator of of
is atom:entry of
is atom:contains of
Faceted Search & Find service v1.17_git150 as of Jan 20 2025


Alternative Linked Data Documents: iSPARQL | ODE     Content Formats:   [cxml] [csv]     RDF   [text] [turtle] [ld+json] [rdf+json] [rdf+xml]     ODATA   [atom+xml] [odata+json]     Microdata   [microdata+json] [html]    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 08.03.3332 as of Sep 11 2024, on Linux (x86_64-generic-linux-glibc25), Single-Server Edition (15 GB total memory, 892 MB memory in use)
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2025 OpenLink Software