Ubuntu 无法安装 php5-mysql

Ubuntu 无法安装 php5-mysql

现在,在有人将其标记为重复之前,我已在互联网上搜索了两天,但一直无法找到解决我的问题的方法。

我所做的只是让 mysql 与 php 一起运行。但是,无论我做什么,它仍然说 mysql_connect() 和 mysqli_connect() 都是未定义的函数。

我尝试安装 php5-mysql 和 php5-mysqlnd。我尝试配置 php.ini 以启用扩展(我更喜欢使用绝对路径,但我在互联网上找不到 mysql.so 的绝对路径)。

我尝试卸载并清除所有 php/apache/mysql 安装,然后使用此安装过程重新安装 Apache、MySQL 和 PHPhttp://howtoubuntu.org/how-to-install-lamp-on-ubuntu

而且,人们一直问我是否记得重启了 Apache,是的,我重启了。没有变化。

如果有人能对此提供任何启发,我将不胜感激。

您可能会发现一些有用的数据:

nathanf@nathanf:~⟫ php -v
PHP 5.3.29 (cli) (built: Mar 18 2016 02:32:59) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2014 Zend Technologies

nathanf@nathanf:~⟫ php -m | grep mysql
<this didn't have any output>

nathanf@nathanf:~⟫ dpkg -s libapache2-mod-php5 | grep Status
Status: install ok installed

nathanf@nathanf:~⟫ dpkg -s php5-mysql | grep Status
Status: deinstall ok config-files

nathanf@nathanf:~⟫ dpkg -s php5-mysqlnd | grep Status
Status: install ok installed

sudo service apache2 restart;tail /var/log/apache2/error.log
 * Restarting web server apache2
...done.
[Wed Apr 06 10:09:08.209690 2016] [core:notice] [pid 27834] AH00094:       Command line: '/usr/sbin/apache2'
[Wed Apr 06 10:11:35.337736 2016] [mpm_prefork:notice] [pid 27834] AH00169: caught SIGTERM, shutting down
[Wed Apr 06 10:11:36.392695 2016] [mpm_prefork:notice] [pid 31633] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.14 configured -- resuming normal operations
[Wed Apr 06 10:11:36.392726 2016] [core:notice] [pid 31633] AH00094: Command line: '/usr/sbin/apache2'
[Wed Apr 06 10:12:39.700572 2016] [mpm_prefork:notice] [pid 31633] AH00169: caught SIGTERM, shutting down
[Wed Apr 06 10:12:40.755404 2016] [mpm_prefork:notice] [pid 919] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.14 configured -- resuming normal operations
[Wed Apr 06 10:12:40.755434 2016] [core:notice] [pid 919] AH00094: Command line: '/usr/sbin/apache2'
[Wed Apr 06 16:37:30.038532 2016] [mpm_prefork:notice] [pid 919] AH00169: caught SIGTERM, shutting down
[Wed Apr 06 16:37:31.371803 2016] [mpm_prefork:notice] [pid 25602] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.14 configured -- resuming normal operations
[Wed Apr 06 16:37:31.371836 2016] [core:notice] [pid 25602] AH00094: Command line: '/usr/sbin/apache2'

答案1

显示输出

  1. php-v 命令
  2. php -m | grep mysql
  3. dpkg -s libapache2-mod-php5 | grep 状态
  4. dpkg -s php5-mysql | grep 状态
  5. dpkg -s php5-mysqlnd | grep 状态
  6. /var/log/apache2/error.log重启 apache 后立即出现消息

顺便说一下,mysql.so可能是/usr/lib/php5/20121212/mysql.so

相关内容