2

Using php-5.4. I'm trying to load 'oci8.so' to access the function oci_connect. When in command line, I can access said function fine. But (after reloading, restarting, and reloading) php-fpm REFUSES to load the extension.

php -r 'print_r(get_loaded_extensions()); lists oci8.

Array
(
    [0] => Core
    [1] => date
    [2] => ereg
    [3] => libxml
    [4] => openssl
    [5] => pcre
    [6] => zlib
    [7] => bz2
    [8] => calendar
    [9] => ctype
    [10] => hash
    [11] => filter
    [12] => ftp
    [13] => gettext
    [14] => gmp
    [15] => SPL
    [16] => iconv
    [17] => pcntl
    [18] => readline
    [19] => Reflection
    [20] => session
    [21] => standard
    [22] => shmop
    [23] => SimpleXML
    [24] => sockets
    [25] => exif
    [26] => tokenizer
    [27] => xml
    [28] => curl
    [29] => fileinfo
    [30] => json
    [31] => oci8
    [32] => Phar
    [33] => zip
    [34] => mhash
)

However curl localhost/extensions.php reads

Array
(
    [0] => Core
    [1] => date
    [2] => ereg
    [3] => libxml
    [4] => openssl
    [5] => pcre
    [6] => zlib
    [7] => bz2
    [8] => calendar
    [9] => ctype
    [10] => hash
    [11] => filter
    [12] => ftp
    [13] => gettext
    [14] => gmp
    [15] => SPL
    [16] => iconv
    [17] => Reflection
    [18] => session
    [19] => standard
    [20] => shmop
    [21] => SimpleXML
    [22] => sockets
    [23] => exif
    [24] => tokenizer
    [25] => xml
    [26] => cgi-fcgi
    [27] => curl
    [28] => fileinfo
    [29] => json
    [30] => Phar
    [31] => zip
    [32] => mhash
    // missing oci8
    // and also missing 'pcntl'??
)

Both the fpm and cli are reading the exact same php.ini. I have check and tested.

Nothing at all in any error logs.

6
  • How specifically have you checked that fpm/cli php.ini were the same? Commented May 7, 2019 at 22:56
  • "Using php-5.4" WHY? NO! Don't do that. Anyway, probably a php.ini file is getting included in one SAPI and not the other. Check with php -i compared to output on web from phpinfo(). Watch for "Loaded Configuration File" and "Additional .ini files parsed" in each. Commented May 7, 2019 at 23:00
  • It's for a client and of course they force me to use outdated equipment. Commented May 7, 2019 at 23:01
  • Then make them hire you to do an upgrade! No excuse for running such old versions. At least 5.6 just went EOL last year. Commented May 7, 2019 at 23:01
  • Again. both php -i and the fpm's phpinfo() point to /etc/php.ini. That is where extension=oci8.so is located. Commented May 7, 2019 at 23:03

2 Answers 2

2

Well not sure it is related but this happened to me on "Amazon Linux 2 AMI" so I guess could apply to "CentOS" too.

Long story short I installed composer and other php stuff.

[zzzz@stageOpenID /etc/httpd/sites-enabled]$ php -i
phpinfo()
PHP Version => 7.2.30

System => Linux stageOpenID 4.14.177-139.254.amzn2.x86_64 #1 SMP Thu May 7 18:48:23 UTC 2020 x86_64
Build Date => May  5 2020 18:04:39
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini
Scan this dir for additional .ini files => /etc/php.d
Additional .ini files parsed => 

So far so good.

And now to the web.

From phpinfo.php:

PHP Version: 7.2.30 
System: Linux stageOpenID 4.14.177-139.254.amzn2.x86_64 #1 SMP Thu May 7 18:48:23 UTC 2020 x86_64
Build Date: May 5 2020 18:06:20
Server API: FPM/FastCGI
Virtual Directory Support: disabled
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan this dir for additional .ini files /etc/php.d
Additional .ini files parsed

But the lists are different.

Why? Simply because after the yum installation I restarted httpd but I forgot to restart php-fpm, so php-cli got the new modules and php-fpm didn't.

So, don't forget to:

sudo systemctl restart php-fpm
Sign up to request clarification or add additional context in comments.

Comments

1

Depending how you have installed PHP FPM but, On Debian CLI and FPM use different ini files try:

   php -i | grep php.ini

Mines is /etc/php/7.0/cli/php.ini

and

    <?php phpinfo(); ?>

Mine is /etc/php/7.0/fpm/php.ini

Hope this helps.

1 Comment

Those are troubleshooting steps, not an answer. Once you have sufficient reputation, you'll be able to comment on any post. Until then, please refrain from answering with questions or comments!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.