简体   繁体   English

使用Apache 2和PHP 5.5安装MySQLi

[英]Installing MySQLi with Apache 2 and PHP 5.5

I'm really stuck on this I've been searching for hours... 我一直在寻找我几个小时的东西...

I recently installed an Apache server on a remote Ubuntu box for my website and I wanted to get started with PHP and MySQL. 我最近在网站的远程Ubuntu盒上安装了Apache服务器,并且想开始使用PHP和MySQL。 MySQL is installed and running. MySQL已安装并正在运行。 PHP installed fine, that works, but I can't figure out how to enable the MySQL extension. PHP安装良好,可以正常工作,但是我不知道如何启用MySQL扩展。 I've already done sudo apt-get install php5-mysql and/or sudo apt-get install php5-mysqlnd but neither of those seemed to actually install anything, at least according to my Apache server. 我已经完成了sudo apt-get install php5-mysql和/或sudo apt-get install php5-mysqlnd但是至少根据我的Apache服务器,这两个文件似乎都没有实际安装任何东西。 When I run php -m I see mysql, mysqli, and mysqlnd. 当我运行php -m我看到mysql,mysqli和mysqlnd。 I've also tried uncommenting the lines for loading the extensions in the Apache php.ini file but none of the mysql.so or mysqli.so or whatever exist in the default extension directory. 我也尝试取消注释在Apache php.ini文件中加载扩展的行,但没有mysql.somysqli.so或默认扩展目录中的任何内容。 There is another PHP extensions directory with those files in it, but when I tried pointing my Apache server to that extension directory, I got errors saying this: 还有另一个包含这些文件的PHP扩展目录,但是当我尝试将Apache服务器指向该扩展目录时,出现以下错误:

/usr/local/lib/php/extensions/no-debug-zts-20131226/mysqli.so: undefined symbol: core_globals in Unknown on line 0

I've tried everything I've seen so far and nothing has worked. 到目前为止,我已经尝试了所有尝试,但没有任何效果。 That error was the closest I got. 这个错误是我得到的最接近的错误。 Any help is appreciated. 任何帮助表示赞赏。

Also here's my phpinfo() output: http://pastebin.com/VM8kyrKV 这也是我的phpinfo()输出: http : //pastebin.com/VM8kyrKV

I also get this when I run sudo apt-get install php5-mysqlnd : 当我运行sudo apt-get install php5-mysqlnd时,我也会得到这个:

php5_invoke: Enable module mysqlnd for cli SAPI
php5_invoke: Enable module mysqlnd for apache2 SAPI
php5_invoke: Enable module mysql for cli SAPI
php5_invoke: Enable module mysql for apache2 SAPI
php5_invoke: Enable module mysqli for cli SAPI
php5_invoke: Enable module mysqli for apache2 SAPI
php5_invoke: Enable module pdo_mysql for cli SAPI
php5_invoke: Enable module pdo_mysql for apache2 SAPI
Which seems to look good but it's still not working... I can't find any mysql module files anywhere except the ones for CLI PHP. 看起来不错,但仍然无法正常工作...除了用于CLI PHP的文件外,我在任何地方都找不到mysql模块文件。

Edit: Long story short, don't compile your own binaries... I started over only using apt-get to install things and everything just worked. 编辑:长话短说,不要编译自己的二进制文件...我仅使用apt-get安装东西,一切都开始了。

I've already done sudo apt-get install php5-mysql and/or sudo apt-get install php5-mysqlnd but neither of those seemed to actually install anything, at least according to my Apache server. 我已经完成了sudo apt-get install php5-mysql和/或sudo apt-get install php5-mysqlnd,但是至少根据我的Apache服务器,这两个文件似乎都没有实际安装任何东西。

Your output from phpinfo() shows both the mysql and mysqlnd modules are active. phpinfo()输出显示mysql和mysqlnd模块均处于活动状态。 This suggests the install was successful and you just need to uncomment the line to load mysqli.so. 这表明安装成功,您只需要取消注释该行即可加载mysqli.so。 Make sure you're editing the file for the Apache instance ( /etc/php5/apache2/php.ini if I'm remembering correctly) and not the CLI instance. 确保编辑的是Apache实例的文件(如果我没有记错的话,请编辑/etc/php5/apache2/php.ini ),而不是CLI实例。 And of course don't forget to restart the service after any changes! 当然,不要忘记在进行任何更改后重新启动服务!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM