Jump to content

PHP + MariaDB на Giga (KN-1010)


Recommended Posts

Добрый день! Помогите, пожалуйста, настроить связку PHP и MariaDB (+ lighttpd).

Установлено и то и другое. Отдельно друг от друга прекрасно работают.

PHP тест phpinfo( ); выдаёт таблицу со своими параметрами, MariaDB в свою очередь доступна через консоль и HeidiSQL на ПК. Таблицы создаются, запросы работают.

Проблема в том, что не получается без fatal error обратиться из PHP к MariaDB. Гуглил, искал причину и вроде бы нашёл, но не понимаю как искоренить.

Если выполняю скрипт: 

<?php
$mysqli = new mysqli("localhost", "test_user", test_user", "test");
if ($mysqli->connect_errno) {
    echo "Не удалось подключиться к MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}

if (!$mysqli->query("DROP TABLE IF EXISTS test") ||
    !$mysqli->query("CREATE TABLE test(id INT)") ||
    !$mysqli->query("INSERT INTO test(id) VALUES (1)")) {
    echo "Не удалось создать таблицу: (" . $mysqli->errno . ") " . $mysqli->error;
}
?>

Получаю вот это:

Fatal error: Uncaught Error: Class 'mysqli' not found in /opt/share/www/php_sql_test.php:3 Stack trace: #0 {main} thrown in /opt/share/www/php_sql_test.php on line 3

Вероятно не подгрузился плагин mysqli? Я проверял, по пути, указанном в файлах конфигурации PHP - mysqli.so есть. Как заставить его работать? Прошу помочь.

 

Link to comment
Share on other sites

Nginx + PHP

Mysql Server 

Spoiler

BusyBox v1.31.1 () built-in shell (ash)

~ # opkg update
Downloading http://bin.entware.net/mipssf-k3.4/Packages.gz
Updated list of available packages in /opt/var/opkg-lists/entware
Downloading http://bin.entware.net/mipssf-k3.4/keenetic/Packages.gz
Updated list of available packages in /opt/var/opkg-lists/keendev
~ # opkg install mariadb-client-extra mariadb-server-extra
Installing mariadb-client-extra (10.4.10-1a) to root...
Downloading http://bin.entware.net/mipssf-k3.4/mariadb-client-extra_10.4.10-1a_mips-3.4.ipk
Installing mariadb-common (1.0-1) to root...
Downloading http://bin.entware.net/mipssf-k3.4/mariadb-common_1.0-1_mips-3.4.ipk
Installing libiconv-full (1.11.1-4) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libiconv-full_1.11.1-4_mips-3.4.ipk
Installing libatomic (8.3.0-9) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libatomic_8.3.0-9_mips-3.4.ipk
Installing zlib (1.2.11-3) to root...
Downloading http://bin.entware.net/mipssf-k3.4/zlib_1.2.11-3_mips-3.4.ipk
Installing libopenssl (1.1.1d-2) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libopenssl_1.1.1d-2_mips-3.4.ipk
Installing libncursesw (6.1-5) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libncursesw_6.1-5_mips-3.4.ipk
Installing libncurses (6.1-5) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libncurses_6.1-5_mips-3.4.ipk
Installing libedit (20191025-3.1-1) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libedit_20191025-3.1-1_mips-3.4.ipk
Installing mariadb-client-base (10.4.10-1a) to root...
Downloading http://bin.entware.net/mipssf-k3.4/mariadb-client-base_10.4.10-1a_mips-3.4.ipk
Installing mariadb-client (10.4.10-1a) to root...
Downloading http://bin.entware.net/mipssf-k3.4/mariadb-client_10.4.10-1a_mips-3.4.ipk
Installing mariadb-server-extra (10.4.10-1a) to root...
Downloading http://bin.entware.net/mipssf-k3.4/mariadb-server-extra_10.4.10-1a_mips-3.4.ipk
Installing libaio (0.3.112-1) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libaio_0.3.112-1_mips-3.4.ipk
Installing liblzma (5.2.4-5) to root...
Downloading http://bin.entware.net/mipssf-k3.4/liblzma_5.2.4-5_mips-3.4.ipk
Installing resolveip (2) to root...
Downloading http://bin.entware.net/mipssf-k3.4/resolveip_2_mips-3.4.ipk
Installing mariadb-server-base (10.4.10-1a) to root...
Downloading http://bin.entware.net/mipssf-k3.4/mariadb-server-base_10.4.10-1a_mips-3.4.ipk
Installing mariadb-server (10.4.10-1a) to root...
Downloading http://bin.entware.net/mipssf-k3.4/mariadb-server_10.4.10-1a_mips-3.4.ipk
Configuring libatomic.
Configuring liblzma.
Configuring mariadb-common.
Configuring libiconv-full.
Configuring zlib.
Configuring libopenssl.
Configuring libncursesw.
Configuring libncurses.
Configuring libedit.
Configuring mariadb-client-base.
Configuring mariadb-client.
Configuring resolveip.
Configuring libaio.
Configuring mariadb-server-base.
Configuring mariadb-server.
Configuring mariadb-server-extra.
Configuring mariadb-client-extra.
~ # 
~ # 
~ # ndmq -p "show version" -P device
DSL
~ # 
~ # 
~ # echo $HOSTNAME
KN-2010
~ # 
~ # 
~ # cat /etc/hosts
127.0.0.1 localhost
::1 localhost
~ # 
~ # ping -c3 127.0.0.1
PING 127.0.0.1 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: seq=0 ttl=64 time=0.748 ms
64 bytes from 127.0.0.1: seq=1 ttl=64 time=0.716 ms
64 bytes from 127.0.0.1: seq=2 ttl=64 time=0.461 ms

--- 127.0.0.1 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.461/0.641/0.748 ms
~ # 
~ # 
~ # ping -c3 KN-2010
ping: bad address 'KN-2010'
~ # 
~ # 
~ # echo "192.168.3.1 KN-2010" >> /etc/hosts 
~ # 
~ # 
~ # ping -c3 KN-2010
PING KN-2010 (192.168.3.1): 56 data bytes
64 bytes from 192.168.3.1: seq=0 ttl=64 time=0.685 ms
64 bytes from 192.168.3.1: seq=1 ttl=64 time=0.424 ms
64 bytes from 192.168.3.1: seq=2 ttl=64 time=0.455 ms

--- KN-2010 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.424/0.521/0.685 ms
~ # 
~ # 
~ # mysql_install_db 
Could not find plugin directory.
Will continue with "/opt/lib/mariadb/plugin".
Installing MariaDB/MySQL system tables in '/opt/var/lib/mysql' ...
2020-03-25 11:13:16 0 [ERROR] InnoDB: Linux Native AIO interface is not supported on this platform. Please check your OS documentation and install appropriate binary of InnoDB.
2020-03-25 11:13:16 0 [Warning] InnoDB: Linux Native AIO disabled.
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system


Two all-privilege accounts were created.
One is root@localhost, it has no password, but you need to
be system 'root' user to connect. Use, for example, sudo mysql
The second is root@localhost, it has no password either, but
you need to be the system 'root' user to connect.
After connecting you can set the password, if you would need to be
able to connect as any of these users with a password and without sudo

See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

You can start the MariaDB daemon with:
cd '/opt' ; /opt/bin/mysqld_safe --datadir='/opt/var/lib/mysql'

You can test the MariaDB daemon with mysql-test-run.pl
cd '/opt/mysql-test' ; perl mysql-test-run.pl

Please report any problems at http://mariadb.org/jira

The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/

~ # 
~ # 
~ # /opt/etc/init.d/S70mysqld start
~ # 
~ # 
~ # ps | grep mysql
 5495 root      590m S    /opt/bin/mysqld --pid-file=/opt/var/run/mysqld/mysqld.pid
 5567 root      6196 S    grep mysql
~ # 
~ # 
~ # mysqladmin -u root password "passwd123"
~ # 
~ # 
~ # mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.4.10-MariaDB Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.009 sec)

MariaDB [(none)]> \q
Bye
~ # 

 

 

Link to comment
Share on other sites

~ # opkg update
Downloading http://bin.entware.net/mipselsf-k3.4/Packages.gz
Updated list of available packages in /opt/var/opkg-lists/entware
Downloading http://bin.entware.net/mipselsf-k3.4/keenetic/Packages.gz
Updated list of available packages in /opt/var/opkg-lists/keendev
~ # opkg install php7-mod-mysqli php7-mod-pdo-mysql
Package php7-mod-mysqli (7.4.3-1) installed in root is up to date.
Installing php7-mod-pdo-mysql (7.4.3-1) to root...
Downloading http://bin.entware.net/mipselsf-k3.4/php7-mod-pdo-mysql_7.4.3-1_mips                                     el-3.4.ipk
Configuring php7-mod-pdo-mysql.
~ # /opt/etc/init.d/S79php7-fpm restart
 Shutting down php-fpm...              done.
 Starting php-fpm...              done.


 

Fatal error: Uncaught Error: Class 'PDO' not found in /opt/share/www/php_sql_test_pdo.php:3 Stack trace: #0 {main} thrown in /opt/share/www/php_sql_test_pdo.php on line 3

Fatal error: Uncaught Error: Class 'mysqli' not found in /opt/share/www/php_sql_test.php:3 Stack trace: #0 {main} thrown in /opt/share/www/php_sql_test.php on line 3

Как я понимаю плагины по какой-то причине не подключаются. 

 

Link to comment
Share on other sites

4 hours ago, musasimaru said:

~ # opkg update
Downloading http://bin.entware.net/mipselsf-k3.4/Packages.gz
Updated list of available packages in /opt/var/opkg-lists/entware
Downloading http://bin.entware.net/mipselsf-k3.4/keenetic/Packages.gz
Updated list of available packages in /opt/var/opkg-lists/keendev
~ # opkg install php7-mod-mysqli php7-mod-pdo-mysql
Package php7-mod-mysqli (7.4.3-1) installed in root is up to date.
Installing php7-mod-pdo-mysql (7.4.3-1) to root...
Downloading http://bin.entware.net/mipselsf-k3.4/php7-mod-pdo-mysql_7.4.3-1_mips                                     el-3.4.ipk
Configuring php7-mod-pdo-mysql.
~ # /opt/etc/init.d/S79php7-fpm restart
 Shutting down php-fpm...              done.
 Starting php-fpm...              done.


 

Fatal error: Uncaught Error: Class 'PDO' not found in /opt/share/www/php_sql_test_pdo.php:3 Stack trace: #0 {main} thrown in /opt/share/www/php_sql_test_pdo.php on line 3

Fatal error: Uncaught Error: Class 'mysqli' not found in /opt/share/www/php_sql_test.php:3 Stack trace: #0 {main} thrown in /opt/share/www/php_sql_test.php on line 3

Как я понимаю плагины по какой-то причине не подключаются. 

 

 Nginx + PHP

Mysql Server 

  Reveal hidden contents

BusyBox v1.31.1 () built-in shell (ash)

~ # opkg update
Downloading http://bin.entware.net/mipssf-k3.4/Packages.gz
Updated list of available packages in /opt/var/opkg-lists/entware
Downloading http://bin.entware.net/mipssf-k3.4/keenetic/Packages.gz
Updated list of available packages in /opt/var/opkg-lists/keendev
~ # opkg install mariadb-client-extra mariadb-server-extra
Installing mariadb-client-extra (10.4.10-1a) to root...
Downloading http://bin.entware.net/mipssf-k3.4/mariadb-client-extra_10.4.10-1a_mips-3.4.ipk
Installing mariadb-common (1.0-1) to root...
Downloading http://bin.entware.net/mipssf-k3.4/mariadb-common_1.0-1_mips-3.4.ipk
Installing libiconv-full (1.11.1-4) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libiconv-full_1.11.1-4_mips-3.4.ipk
Installing libatomic (8.3.0-9) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libatomic_8.3.0-9_mips-3.4.ipk
Installing zlib (1.2.11-3) to root...
Downloading http://bin.entware.net/mipssf-k3.4/zlib_1.2.11-3_mips-3.4.ipk
Installing libopenssl (1.1.1d-2) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libopenssl_1.1.1d-2_mips-3.4.ipk
Installing libncursesw (6.1-5) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libncursesw_6.1-5_mips-3.4.ipk
Installing libncurses (6.1-5) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libncurses_6.1-5_mips-3.4.ipk
Installing libedit (20191025-3.1-1) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libedit_20191025-3.1-1_mips-3.4.ipk
Installing mariadb-client-base (10.4.10-1a) to root...
Downloading http://bin.entware.net/mipssf-k3.4/mariadb-client-base_10.4.10-1a_mips-3.4.ipk
Installing mariadb-client (10.4.10-1a) to root...
Downloading http://bin.entware.net/mipssf-k3.4/mariadb-client_10.4.10-1a_mips-3.4.ipk
Installing mariadb-server-extra (10.4.10-1a) to root...
Downloading http://bin.entware.net/mipssf-k3.4/mariadb-server-extra_10.4.10-1a_mips-3.4.ipk
Installing libaio (0.3.112-1) to root...
Downloading http://bin.entware.net/mipssf-k3.4/libaio_0.3.112-1_mips-3.4.ipk
Installing liblzma (5.2.4-5) to root...
Downloading http://bin.entware.net/mipssf-k3.4/liblzma_5.2.4-5_mips-3.4.ipk
Installing resolveip (2) to root...
Downloading http://bin.entware.net/mipssf-k3.4/resolveip_2_mips-3.4.ipk
Installing mariadb-server-base (10.4.10-1a) to root...
Downloading http://bin.entware.net/mipssf-k3.4/mariadb-server-base_10.4.10-1a_mips-3.4.ipk
Installing mariadb-server (10.4.10-1a) to root...
Downloading http://bin.entware.net/mipssf-k3.4/mariadb-server_10.4.10-1a_mips-3.4.ipk
Configuring libatomic.
Configuring liblzma.
Configuring mariadb-common.
Configuring libiconv-full.
Configuring zlib.
Configuring libopenssl.
Configuring libncursesw.
Configuring libncurses.
Configuring libedit.
Configuring mariadb-client-base.
Configuring mariadb-client.
Configuring resolveip.
Configuring libaio.
Configuring mariadb-server-base.
Configuring mariadb-server.
Configuring mariadb-server-extra.
Configuring mariadb-client-extra.
~ # 
~ # 
~ # ndmq -p "show version" -P device
DSL
~ # 
~ # 
~ # echo $HOSTNAME
KN-2010
~ # 
~ # 
~ # cat /etc/hosts
127.0.0.1 localhost
::1 localhost
~ # 
~ # ping -c3 127.0.0.1
PING 127.0.0.1 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: seq=0 ttl=64 time=0.748 ms
64 bytes from 127.0.0.1: seq=1 ttl=64 time=0.716 ms
64 bytes from 127.0.0.1: seq=2 ttl=64 time=0.461 ms

--- 127.0.0.1 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.461/0.641/0.748 ms
~ # 
~ # 
~ # ping -c3 KN-2010
ping: bad address 'KN-2010'
~ # 
~ # 
~ # echo "192.168.3.1 KN-2010" >> /etc/hosts 
~ # 
~ # 
~ # ping -c3 KN-2010
PING KN-2010 (192.168.3.1): 56 data bytes
64 bytes from 192.168.3.1: seq=0 ttl=64 time=0.685 ms
64 bytes from 192.168.3.1: seq=1 ttl=64 time=0.424 ms
64 bytes from 192.168.3.1: seq=2 ttl=64 time=0.455 ms

--- KN-2010 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.424/0.521/0.685 ms
~ # 
~ # 
~ # mysql_install_db 
Could not find plugin directory.
Will continue with "/opt/lib/mariadb/plugin".
Installing MariaDB/MySQL system tables in '/opt/var/lib/mysql' ...
2020-03-25 11:13:16 0 [ERROR] InnoDB: Linux Native AIO interface is not supported on this platform. Please check your OS documentation and install appropriate binary of InnoDB.
2020-03-25 11:13:16 0 [Warning] InnoDB: Linux Native AIO disabled.
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system


Two all-privilege accounts were created.
One is root@localhost, it has no password, but you need to
be system 'root' user to connect. Use, for example, sudo mysql
The second is root@localhost, it has no password either, but
you need to be the system 'root' user to connect.
After connecting you can set the password, if you would need to be
able to connect as any of these users with a password and without sudo

See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

You can start the MariaDB daemon with:
cd '/opt' ; /opt/bin/mysqld_safe --datadir='/opt/var/lib/mysql'

You can test the MariaDB daemon with mysql-test-run.pl
cd '/opt/mysql-test' ; perl mysql-test-run.pl

Please report any problems at http://mariadb.org/jira

The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/

~ # 
~ # 
~ # /opt/etc/init.d/S70mysqld start
~ # 
~ # 
~ # ps | grep mysql
 5495 root      590m S    /opt/bin/mysqld --pid-file=/opt/var/run/mysqld/mysqld.pid
 5567 root      6196 S    grep mysql
~ # 
~ # 
~ # mysqladmin -u root password "passwd123"
~ # 
~ # 
~ # mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.4.10-MariaDB Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.009 sec)

MariaDB [(none)]> \q
Bye
~ # 

 

 

Link to comment
Share on other sites

Победил. Дело было в несовпадении версии php  и плагинов. Просто удалил все пакеты PHP вместе с зависимыми, потом поставил заново. Настроил как здесь описано: 

 

 

 

Edited by musasimaru
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...