2015-12-08 1 views
0

J'essaye d'installer Spatialite (4.3.0a) sur Ubuntu (14.94.2 LTS) ..... Je voudrais l'utiliser avec PHP (5.5.9-1) ....Spatialite non chargé en PHP5 sur Ubuntu

après ce post

https://faimsproject.atlassian.net/wiki/display/FAIMS/Installing+Spatialite+4+on+Ubuntu

(en utilisant évidemment les versions mises à jour des paquets concernés ....), je suis maintenant installé:

  • PHP 5.5.9-1
  • SQLite 3.9.2
  • Proj4 4.9.2
  • Geos 3.5.0
  • Freexl 1.0.2
  • Spatialite 4.3.0a

J'ai aussi exporté/usr/local/lib

export "LD_LIBRARY_PATH=/usr/local/lib" 

Il semble que SQLite 3 et Spatialite fonctionnent très bien ...

sqlite3 myDB 
SQLite version 3.9.2 2015-11-02 18:31:45 
Enter ".help" for usage hints. 
sqlite> SELECT load_extension('mod_spatialite'); 

sqlite> SELECT sqlite_version(); 
3.9.2 
sqlite> SELECT spatialite_version(); 
4.3.0a 
sqlite> SELECT proj4_version(); 
Rel. 4.9.2, 08 September 2015 
sqlite> SELECT geos_version(); 
3.5.0-CAPI-1.9.0 r4084 
sqlite> .quit 

Mais si je tente d'exécuter ce simple fichier PHP

<html> 
    <head> 
    <title>Testing SpatiaLite on PHP</title> 
    </head> 
    <body> 
    <h1>testing SpatiaLite on PHP</h1> 

<?php 
# connecting some SQLite DB 
# we'll actually use an IN-MEMORY DB 
# so to avoid any further complexity; 
# an IN-MEMORY DB simply is a temp-DB 
$db = new SQLite3(':memory:'); 

# loading SpatiaLite as an extension 
$db->loadExtension('/usr/local/lib/mod_spatialite.so'); 


# enabling Spatial Metadata 
# using v.2.4.0 this automatically initializes SPATIAL_REF_SYS 
# and GEOMETRY_COLUMNS 
$db->exec("SELECT InitSpatialMetadata()"); 

# reporting some version info 
$rs = $db->query('SELECT sqlite_version()'); 
while ($row = $rs->fetchArray()) 
{ 
    print "<h3>SQLite version: $row[0]</h3>"; 
} 
$rs = $db->query('SELECT spatialite_version()'); 
while ($row = $rs->fetchArray()) 
{ 
    print "<h3>SpatiaLite version: $row[0]</h3>"; 
} 

?> 

    </body> 
</html> 

... le résultat est

testing SpatiaLite on PHP 

SQLite version: 3.9.2 

il semble donc que somthing va mal avec le chargement Spatialite.

Ma configuration php.ini est le suivi

[sqlite] 
http://php.net/sqlite.assoc-case 
sqlite.assoc_case = 0 

[sqlite3] 
sqlite3.extension_dir = /var/www/html/test/sqlite3_ext 

dans/var/www/html/test/sqlite3_ext il y a

-rwxr-xr-x 1 cesare cesare 15527574 Dec 1 22:17 libspatialite.so 
-rwxr-xr-x 1 cesare cesare 15944537 Dec 2 22:28 mod_spatialite.so 

Toute suggestion est appréciée ...

Merci beaucoup d'avance!

Cesare

Répondre

0

J'ai résolu de mettre

$db->loadExtension('mod_spatialite.so'); 

dans mon code PHP et la configuration de la variable d'env LD_LIBRARY_PATH THSiS manière

export "LD_LIBRARY_PATH=/usr/local/lib"