aws php mysql failed 头,PHP无法在Amazon EC2微实例上运行MYSQLI函数

在AWS的Amazon Linux AMI环境中,遇到PHP无法连接到MySQL的问题,错误提示为未定义mysqli_connect()函数。检查php.ini配置显示mysqli已启用,但问题依然存在。尝试使用phpinfo()显示的Configure Command确认mysqli已编译进PHP。解决方案是通过运行'yum install php-mysqli'来安装缺失的mysqli扩展。
摘要由CSDN通过智能技术生成

呃,我的亚马逊微实例遇到了一些麻烦.我刚刚实现了PHP< - > MYSQL界面.该实例似乎报告未安装MYSQLI插件,但是,所有其他指示都是相反的.我已经厌倦了对搜索的耐心,现在将吸引整个互联网的更高智慧.谢谢你的期待!

我的代码:

error_reporting(E_ALL);

ini_set('error_reporting', E_ALL);

ini_set('display_errors', 'On');

$mysql = mysqli_connect( 'localhost', 'EulerPhpUser', '*********' );

// more code

错误消息:致命错误:在第27行的/var/www/html/euler/login.php中调用未定义的函数mysqli_connect()

$cat /etc/*-release

Amazon Linux AMI release 2013.03

这是我的php.ini文件的一部分

; Maximum number of links. -1 means no limit.

; http://www.php.net/manual/en/mysqli.configuration.php#ini.mysqli.max-links

mysqli.max_links = -1

; Default port number for mysqli_connect(). If unset, mysqli_connect() will use

; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the

; compile-time value defined MYSQL_PORT (in that order). Win32 will only look

; at MYSQL_PORT.

; http://www.php.net/manual/en/mysqli.configuration.php#ini.mysqli.default-port

mysqli.default_port = 3306

; Default socket name for local MySQL connects. If empty, uses the built-in

; MySQL defaults.

; http://www.php.net/manual/en/mysqli.configuration.php#ini.mysqli.default-socket

mysqli.default_socket =

; Default host for mysql_connect() (doesn't apply in safe mode).

; http://www.php.net/manual/en/mysqli.configuration.php#ini.mysqli.default-host

mysqli.default_host =

; Default user for mysql_connect() (doesn't apply in safe mode).

; http://www.php.net/manual/en/mysqli.configuration.php#ini.mysqli.default-user

mysqli.default_user =

; Default password for mysqli_connect() (doesn't apply in safe mode).

; Note that this is generally a *bad* idea to store passwords in this file.

; *Any* user with PHP access can run 'echo get_cfg_var("mysqli.default_pw")

; and reveal this password! And of course, any users with read access to this

; file will be able to reveal the password as well.

; http://www.php.net/manual/en/mysqli.configuration.php#ini.mysqli.default-pw

mysqli.default_pw =

; Allow or prevent reconnect

mysqli.reconnect = Off

这是phpifo()的唯一部分,我搜索mysqli产生了结果

Configure Command

'./configure' '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--target=x86_64-amazon-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib64' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--without-pear' '--with-bz2' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--with-xpm-dir=/usr' '--enable-gd-native-ttf' '--with-t1lib=/usr' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--with-kerberos' '--enable-ucd-snmp-hack' '--enable-shmop' '--enable-calendar' '--without-sqlite' '--with-libxml-dir=/usr' '--enable-xml' '--with-system-tzdata' '--with-mhash' '--with-apxs2=/usr/sbin/apxs' '--libdir=/usr/lib64/php' '--enable-pdo=shared' '--with-mysql=shared,/usr' '--with-mysqli=shared,/usr/lib64/mysql/mysql_config' '--with-pdo-mysql=shared,/usr/lib64/mysql/mysql_config' '--with-pdo-sqlite=shared,/usr' '--without-gd' '--disable-dom' '--disable-dba' '--without-unixODBC' '--disable-xmlreader' '--disable-xmlwriter' '--without-sqlite3' '--disable-phar' '--disable-fileinfo' '--disable-json' '--without-pspell' '--disable-wddx' '--without-curl' '--disable-posix' '--disable-sysvmsg' '--disable-sysvshm' '--disable-sysvsem'

最后,还有一点需要注意.我试图运行以下代码,服务器返回一个完全空白的页面.没有错误,没有任何错误.好像php崩溃而没有产生错误.我不确定如何解释.

if (function_exists('mysqli_connect')) {

echo 'mysqli is installed';

}

我甚至非常沮丧,我尝试了一些PDO,但后来得到错误连接失败:找不到驱动程序

如果有任何进一步的信息请告知我们,我会及时提供.感谢您的帮助

解决方法:

在AWS中,我收到此错误,发现我需要运行“yum install php-mysqli”.这是mysql和php包的补充.

标签:php,mysql,mysqli,pdo

来源: https://codeday.me/bug/20190715/1468217.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值