[gdal-dev] Can not run ogr2ogr from a web server running PHP

Peter Hopfgartner peter.hopfgartner at r3-gis.com
Tue Dec 21 10:17:25 EST 2010


Hi Pavel. Thanks for your quick response. Anyway, I did the following test:

I have a PHP file (env.php):

<?php

exec("/data/sites/plantmap/web/env.sh", $output, $rv);
print_r($output);


and a shell script

#!/bin/sh
echo $ORACLE_HOME
echo $ORACLE_SID
echo $ORACLE_OWNER
echo $LD_LIBRARY_PATH

When I run env.php through the web server, it returns 

Array
(
    [0] => /u01/app/oracle/product/11.1.0/db_1
    [1] => plantmap
    [2] => oracle
    [3] => :/u01/app/oracle/product/11.1.0/db_1/lib
)
, so the environment variables are passed correctly to the called application.

Are there any other env. variables relevant for ogr2ogr when reading an Oracle DB?


Regards,

Peter
 
R3 GIS Srl - GmbH
http://www.r3-gis.com


--------Pavel Iacovlev <iacovlev.pavel at gmail.com> wrote--------
Subject: Re: [gdal-dev] Can not run ogr2ogr from a web server running PHP
Date: 21.12.2010 16:11

>Your environment variables are set for your current user, apache usually
>runs as www-data or nobody user.
>Use http://md.php.net/putenv to set your environment variables this will
>work both from apache and from CLI.
>
>On Tue, Dec 21, 2010 at 4:51 PM, Peter Hopfgartner <
>peter.hopfgartner at r3-gis.com> wrote:
>
>> I'm trying to run ogr2ogr from a PHP script. This runs fine, if the
>script
>> is run from the command line. It does not work if run through the web
>> server.
>>
>> The scripts basically runs:
>>
>> /usr/local/bin/ogr2ogr -f 'ESRI Shapefile'
>> '/tmp/tmp_plant_cfa4f818c6c5c1e7881b' 'OCI:plantmap/plantmapx at plantmap'
>> -sql 'SELECT * FROM tmp_plant_cfa4f818c6c5c1e7881b' -nln plant
>>
>> and returns the error:
>> ERROR 1: ORA-12504: TNS:listener was not given the SERVICE_NAME in
>> CONNECT_DATA
>>  in <unnamed>
>>
>> ORACLE_HOME, ORACLE_SID, ORACLE_HOME are set in the web server init
>script
>> (the whole application runs with Oracle).
>> I tried to enforce the variables in the virtual host fragment in
>> httpd.conf:
>>    SetEnv ORACLE_HOME /u01/app/oracle/product/11.1.0/db_1
>>    SetEnv ORACLE_SID plantmap
>>    SetEnv ORACLE_OWNER oracle
>>
>> If I run a little test script, like:
>> #!/bin/sh
>> echo $ORACLE_HOME
>> echo $ORACLE_SID
>> echo $LD_LIBRARY_PATH
>>
>> the environment variables are set correctly.
>> So why can't ogr2ogr find the correct Oracle instance?
>>
>> Platform: RHEL 5, 64 bit, Oracle 11.1
>>
>> Regards,
>>
>> Peter Hopfgartner
>>
>> R3 GIS Srl - GmbH
>> http://www.r3-gis.com
>>
>>
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>
>
>
>-- 
>http://iap.md, The future is open
>



More information about the gdal-dev mailing list