呃,我遇到了一些与我的Amazon微型实例有关的实际麻烦。我刚刚实现了一个PHP < - > MYSQL接口。该实例似乎报告说MYSQLI插件没有安装,但是,所有其他指示都是相反的。我已经用尽了搜索的耐心,现在将吸引整个互联网更高的智慧。感谢您的期待!PHP无法在Amazon EC2微型实例上运行MYSQLI函数
我的代码:
<?php
error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 'On');
$mysql = mysqli_connect('localhost', 'EulerPhpUser', '*********');
// more code
错误消息:致命错误:调用到/var/www/html/euler/login.php未定义功能mysqli_connect()第27行
$ 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
这是个e仅在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,但后来遇到错误连接失败:找不到驱动程序
请告知,如果任何进一步的信息请求,我会及时提供它。感谢您的帮助
你有没有启用php.ini中的mysqli扩展? – crush
我的php.ini文件中有“mysqli”的部分贴在上面。 – travish82
如果可以的话,我会关闭这个问题,但Stack Overflow似乎并不希望让他们的站点直观或用户友好,所以我没有动力去努力找出如何做到这一点。 – travish82