1

Hi I have a piece of code that execute python3 command from php file:

shell_exec('python3 /var/www/html/PlantDiseaseSystem/src/lib/py/riskcalc.py '.$riskValue[0].','.$riskValue[1].','.$riskValue[2].','.$riskValue[3]);

It works just fine and give me the right result. But once I run the same php file from apache server using Javascript Post request, it won't work! I checked my apache2 error log and shows below message:

Traceback (most recent call last):
  File "/var/www/html/PlantDiseaseSystem/src/lib/py/riskcalc.py", line 10, in <module>
    from osgeo import gdal
  File "/usr/lib/python3/dist-packages/osgeo/__init__.py", line 21, in <module>
    _gdal = swig_import_helper()
  File "/usr/lib/python3/dist-packages/osgeo/__init__.py", line 17, in swig_import_helper
    _mod = imp.load_module('_gdal', fp, pathname, description)
  File "/usr/lib/python3.5/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: /usr/lib/python3/dist-packages/osgeo/_gdal.cpython-35m-x86_64-linux-gnu.so: undefined symbol: VSICurlClearCache  

It seems to me I'm having trouble import a library, how come I could do it just fine from shell? I'm using Ubuntu 16.04. Thanks!

MaxG
  • 199
  • 2
  • 12
  • LIVE Servers often block access to `shell_exec` for obvious reasons. Have you checked the config of the Apache server/php config – RiggsFolly Apr 11 '18 at 13:57
  • Hi, thanks for the reply! Can you be more specific? I have done similar deployment on AWS server, haven't seen such issue before..? – MaxG Apr 11 '18 at 13:58
  • @RiggsFolly I granted the permission to www-data in sudoers – MaxG Apr 11 '18 at 14:00
  • @Max_Guo check [this question](https://stackoverflow.com/questions/24999673/how-to-enable-shell-exec-and-exec-on-php). You should check PHP configuration. Most probably, exec functions are disabled there for security reasons, as already pointed out by RiggsFolly. – Sergio Monteleone Apr 12 '18 at 10:49

0 Answers0