WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: PHP7  (Read 4650 times)

Offline parky_dw

  • Newbie
  • *
  • Posts: 33
PHP7
« on: October 03, 2018, 12:15:54 PM »
I've been going round in circles here with PHP7, MariaDB and Wordpress.  Hopefully some one here can help me out.

My starting point is the Wordpress error:

Code: (bash) [Select]
"Your PHP installation appears to be missing the MySQL extension which is required by WordPress."
I can't see anything wrong with my php installation. (php7-cli.tcz, php7-ext.tcz, php7-mod.tcz).

The .ini file has

Code: (bash) [Select]
extension_dir=/usr/local/lib/php/extensions/no-debug-zts-20170718
In the files sitting in that directory we have:

Code: (bash) [Select]
bcmath.so            mysqli.so            shmop.so
bz2.so               oci8.so              simplexml.so
calendar.so          odbc.so              snmp.so
.....                ........             ......

The command php -m gives me a shorter list which overlaps with some of those above. It doesn't include mysqli.so.

Is this listing just compiled in modules or should I be seeing the complete list from the extension_dir?

I tried a simple php script to check a database and got:

Code: [Select]
rose@mirror:~$php -f db-connect-test.php
PHP Fatal error:  Uncaught Error: Call to undefined function mysqli_connect() in /home/rose/db-connect-test.php:10
Stack trace:
#0 {main}
  thrown in /home/rose/bd-connect-test.php on line 10

Next I set enable_dl in the ini file to On and added the line
dl("mysqli.so");

This gave me the error message:

Code: [Select]
PHP Warning:  dl(): Unable to load dynamic library 'mysqli.so'
(tried: /usr/local/lib/php/extensions/no-debug-zts-20170718/mysqli.so (libmysqlclient.so.18: cannot open shared object file: No such file or directory),
 /usr/local/lib/php/extensions/no-debug-zts-20170718/mysqli.so.so (/usr/local/lib/php/extensions/no-debug-zts-20170718/mysqli.so.so: cannot open shared object file: No such file or directory))
 in /home/rose/bd-connect-test.php on line 10
PHP Fatal error:  Uncaught Error: Call to undefined function mysqli_connect() in /home/rose/bd-connect-test.php:12
Stack trace:
#0 {main}
  thrown in /home/rose/bd-connect-test.php on line 12


What is going on here?  It reports [color=#ff0000]tried: /usr/local/lib/php/extensions/no-debug-zts-20170718/mysqli.so[/color] and the file is there....
Finally I tried:
Code: [Select]
rose@mirror:~$ php --re mysqli.so
Exception: Extension mysqli.so does not exist
rose@mirror:~$ php --ri mysqli.so
Extension 'mysqli.so' not present.
rose@mirror:~$



What is going on?  Why is the mysqli.so extension not being found and used?

Offline andyj

  • Hero Member
  • *****
  • Posts: 1036
Re: PHP7
« Reply #1 on: October 03, 2018, 02:58:43 PM »
The MySQL extension (or any other PHP extension) will not load if any dependent libraries are not available. Have you downloaded and installed the MySQL extensions?

Offline parky_dw

  • Newbie
  • *
  • Posts: 33
Re: PHP7
« Reply #2 on: October 03, 2018, 04:12:10 PM »
I also installed mariadb.tcz and mariadb-client.tcz.  I'm just repeating a successful build I did back in January which I documented here: http://www.parkytowers.me.uk/thin/Linux/TinycoreWP.shtml

I don't think any dependencies are missing....

I see the php version has advanced to 7.2.1 (from 7.1.12 previously) and that the problem I had with the sample ini file and the extension_dir at that time have been fixed.

Offline parky_dw

  • Newbie
  • *
  • Posts: 33
Re: PHP7
« Reply #3 on: October 03, 2018, 04:27:34 PM »
Maybe I was a little hasty in my last post.....running ldd I see

Code: [Select]
rose@mirror:/usr/local/lib/php/extensions/no-debug-zts-20170718$ ldd mysqli.so
        linux-gate.so.1 (0xb77e4000)
        libmysqlclient.so.18 => not found
        libz.so.1 => /usr/lib/libz.so.1 (0xb77aa000)
        libm.so.6 => /lib/libm.so.6 (0xb776a000)
        libssl.so.1.0.0 => /usr/local/lib/libssl.so.1.0.0 (0xb771e000)
        libcrypto.so.1.0.0 => /usr/local/lib/libcrypto.so.1.0.0 (0xb75cf000)
        libdl.so.2 => /lib/libdl.so.2 (0xb75cb000)
        libpthread.so.0 => /lib/libpthread.so.0 (0xb75b4000)
        libc.so.6 => /lib/libc.so.6 (0xb74a1000)
        /lib/ld-linux.so.2 (0x8005f000)

...and find shows...

Code: [Select]
/usr/local/mysql/lib/libmysqlclient.so.18.0.0
/usr/local/mysql/lib/libmysqlclient.so.18
/usr/local/mysql/lib/libmysqlclient.so

I thought I'd addressed the issue with the mysql shared libraries not being in the usual /usr/local/lib with an entry in /etc/ld.so.conf  I obviously need to revisit.

Thanks AndyJ for the pointer.

Offline josejoao

  • Newbie
  • *
  • Posts: 1
Re: PHP7
« Reply #4 on: October 04, 2018, 03:38:20 PM »
I was having the same error where php wasn't loading mysqli.

The only extra step I've done, besides what is at http://www.parkytowers.me.uk/thin/Linux/TinycoreWP.shtml,
was to uncomment the mysqli extension (around line 942) on the file  /usr/local/etc/php7/php.ini
Code: [Select]
extension=mysqli
Thanks for all the information parky_dw of setting-up tiny core for wordpress.

Offline parky_dw

  • Newbie
  • *
  • Posts: 33
Re: PHP7
« Reply #5 on: October 04, 2018, 06:15:34 PM »
I have done that as well.  I need to update the page - either I didn’t document what I did fully last time or some defaults have changed in the latest releases.  For example the default socket is different between PHP and MariaDB and I found I had to set it explicitly in the PHP ini file for Wordpress to connect to the database.

Offline andyj

  • Hero Member
  • *****
  • Posts: 1036
Re: PHP7
« Reply #6 on: October 04, 2018, 07:45:07 PM »
What version of TC and arch are you using?

Offline parky_dw

  • Newbie
  • *
  • Posts: 33
Re: PHP7
« Reply #7 on: October 05, 2018, 03:38:05 AM »
Version reports as 8.2.1.  32-bit architecture.