2
votes

Showing my case how to debug the problem, that a PHP module is not loaded into PHP.

I use OpenSUSE v42.2 Linux OS, with Apache webserver, PHP v7.1, Mysql.

Because it does not provide PHP v7.1 I need, I built PHP v7.1 from source. Using PHP-FPM.

I installed it into

/opt/php-7.1/

php.ini is in:

/opt/php-7.1/lib/php.ini

I find, that opcache is installed to

/opt/php-7.1/lib64/extensions/no-debug-non-zts-20160303/opcache.so

I edited php.ini and added the following line:

zend_extension=/opt/php-7.1/lib64/extensions/no-debug-non-zts-20160303/opcache.so

Restarted:

systemctl restart php-7.1-fpm.service
systemctl restart apache2.service

But still I get the following result:

php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
imap
intl
json
libxml
mbstring
mcrypt
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
Reflection
session
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
zip
zlib

[Zend Modules]

The opcache is missing from [Zend Modules].

But in configure there is '--enable-opcache':

php -i | grep -i opcache

Configure Command => './configure' '--prefix=/opt/php-7.1' '--with-pdo-pgsql' '--with-zlib-dir' '--with-freetype-dir' '--enable-mbstring' '--with-libxml-dir=/usr' '--enable-soap' '--enable-intl' '--enable-calendar' '--with-curl' '--with-mcrypt' '--with-gd' '--with-pgsql' '--disable-rpath' '--enable-inline-optimization' '--with-bz2' '--with-zlib' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-pcntl' '--enable-mbregex' '--enable-exif' '--enable-bcmath' '--with-mhash' '--enable-zip' '--with-pcre-regex' '--with-pdo-mysql' '--with-mysqli' '--with-mysql-sock=/var/run/mysql/mysql.sock' '--with-xpm-dir=/usr' '--with-webp-dir=/usr' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--with-openssl' '--with-fpm-user=wwwrun' '--with-fpm-group=www' '--with-libdir=lib64' '--enable-ftp' '--with-imap' '--with-imap-ssl' '--with-kerberos' '--with-gettext' '--with-xmlrpc' '--with-xsl' '--enable-opcache' '--enable-fpm'

I also tried to specify as:

zend_extension=opcache

but I got the same result, opcache still missing.

How to fix to have opcache enabled?

1

1 Answers

0
votes

In my case the affected module was the opcache PHP module.

Solution:

I noticed, that within phpinfo the "display_errors" Local value was OFF, Master value was ON. Because Master value comes from php.ini, and in /opt/php-7.1/lib/php.ini had "display_errors = Off", it means this php.ini is not loaded.

Also found, that the "Loaded Configuration File" field value is empty, so it also shows php.ini is not loaded.

But the php.ini is located (and should have been loaded from): /opt/php-7.1/lib/php.ini.

Furthermore I noticed, that within phpinfo the "Configuration File (php.ini) Path" is set to: "/opt/php-7.1/lib64" So it means the php.ini should be located at /opt/php-7.1/lib64/ directory.

Step1 fix:

copy php.ini 
from 
/opt/php-7.1/lib/php.ini
to
/opt/php-7.1/lib64/php.ini

In command line:

cp -p /opt/php-7.1/lib/php.ini /opt/php-7.1/lib64/php.ini

Also noticed, that php was compiled with '--with-libdir=lib64' argument.

This will likely mean, that "opcache.so" file should be found under this directory.

Currently "opcache.so" is located in directory: "/opt/php-7.1/lib64/extensions/no-debug-non-zts-20160303/". I supposed placing the "opcache.so" to "/opt/php-7.1/lib64/extensions/" would be enough. That became the final fix.

Step2 fix:

copy opcache.a & opcache.so
from 
/opt/php-7.1/lib64/extensions/no-debug-non-zts-20160303/
to
/opt/php-7.1/lib64/extensions/

In command line:

cp -p /opt/php-7.1/lib64/extensions/no-debug-non-zts-20160303/opcache.* /opt/php-7.1/lib64/extensions/

Step3 fix:

Restart Apache & PHP-FPM (optionally, if used):

service apache2 restart
service php-7.1-fpm restart

After doing these 3 fix steps, the PHP opcache module is loaded successfully.

Result:

php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
imap
intl
json
libxml
mbstring
mcrypt
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
Reflection
session
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache