Error loading oci8.so with Ubuntu server 17.04 php 7 and apache2

后端 未结 3 1420
北恋
北恋 2020-12-20 02:27

I have gone through the whole process of downloading Oracle instant client, SDK, etc. in a Ubuntu Server 17.04. Then converted rpm packages to deb with alien, installed, set

相关标签:
3条回答
  • 2020-12-20 02:54

    With Linux Ubuntu 18, if you're getting the same message, but its command line version: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20170718/oci8' when using php cli (= command line, as opposed to php as an apache module), all you need to do is to set LD_LIBRARY_PATH (not ORACLE_HOME), inside of /etc/environment, as shown below:

    export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2

    Next time you open a shell, the environment will declare this variable.

    Note that the variable value needs to point to the folder that contains the lib*.so files.

    Verification: open a new console, and run php -m | grep oci8

    0 讨论(0)
  • 2020-12-20 02:55

    The solution is to put the ORACLE global variables NOT in /etc/environment but in the /etc/apache2/envvars

    So, I've added these 2 lines at the end of /etc/apache2/envvars

    export LD_LIBRARY_PATH=/usr/lib/oracle/12.2/client64/lib
    export ORACLE_HOME=/usr/lib/oracle/12.2/client64
    

    And all working great

    0 讨论(0)
  • 2020-12-20 03:11

    As you still will have the same problem with php cli with the above solution, it would be better to add a new file /etc/ld.so.conf.d/oracle.conf with this content:

    /usr/lib/oracle/12.2/client64/lib
    

    Then run

    sudo ldconfig
    

    This way it works for apache and php cli and you do not need to change /etc/apache2/envvars

    0 讨论(0)
提交回复
热议问题