PHP /阿帕奇:PHP致命错误:调用未定义的函数mysql_connect()函数 [英] PHP/Apache: PHP Fatal error: Call to undefined function mysql_connect()

查看:2039
本文介绍了PHP /阿帕奇:PHP致命错误:调用未定义的函数mysql_connect()函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的MySQL(5.5.23社区服务器),阿帕奇(2.2),和PHP(5.3.13)在Fedora 15的机器(64位)上运行。每一个可以与自己没有任何问题。

I have MySQL (5.5.23 Community Server), Apache (2.2), and PHP (5.3.13) running on a Fedora 15 machine (64-bit). Each works with no problem on their own.

我认为PHP是配置/编译使用MySQL,但是当我尝试加载任何PHP网页,这使得MySQL的电话然后我得到了上面提到的致命错误(在Apache的错误日志)。 PHP可以在自己的好,虽然,通过Apache并在命令行。

I thought that PHP was configured/compiled to work with MySQL, but when I try to load any PHP web page which makes a MySQL call then I get the above noted fatal error (in the Apache error log). PHP works okay on its own though, through Apache and at the command line.

当我在命令行运行php -i然后果然显示了所有MySQL的点点滴滴,但是当我打开一个显示页面的phpinfo(),然后有没有提及MySQL的模块。

When I run php -i from the command line then sure enough it shows all the MySQL bits and pieces, but when I load a page displaying phpinfo() then there are no MySQL modules mentioned.

我也试着取消注释扩展名= mysql.so在php.ini,但PHP然后用PHP启动抱怨:无法加载动态库'的/ usr / lib64下/ PHP /modules/mysql.so'。(即使模块不住在那里)。但我不能完全肯定该行是否需要取消注释或没有。 [修正:所述的错误实际上是由于一个错字,但在命令行中运行表明,该模块已经加载反正 - 有来自PHP,上面写着这样的警告。]

I've also tried un-commenting "extension=mysql.so" in php.ini, but PHP then complains with "PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/mysql.so'." (even though the module does reside there). But then I'm not entirely certain whether that line is required to be un-commented or not. [correction: the error stated was actually due to a typo, but running from the command line shows that the module is already loaded anyway - there is a warning from PHP that says so.]

我也已经停用了SELinux;停止/重新启动阿帕奇无数次; yummed的MySQL-杰韦利,万一它使任何区别;并且,现在看来,所有其他可能的事情。

I've also disabled SELinux; stopped/restarted Apache numerous times; yummed MySQL-Devel, in case it made any difference; and, it seems, every other possible thing.

如果我运行命令行有点PHP测试脚本,访问MySQL数据库,那么它的工作原理没有问题,所以PHP不知道MySQL的,但是当它在Apache下运行,它似乎没有任何线索,MySQL的甚至存在。

If I run a little PHP test script from the command line, to access the MySQL database, then it works with no problem, so PHP does know about MySQL, but when it runs under Apache it seems to have no clue that MySQL even exists.

我一直在试图打开和关闭数月,以解决这个问题,似乎已经尝试了一切,但似乎没有任何工作。

I've been trying on and off for months to solve this problem, and seem to have tried everything, but nothing seems to work.

我不介意,如果我真的有,如果有人能证明配置/ MySQL的支持编译,这样我就可以得到它的Apache下工作的正确方法重新安装PHP,但理想的我ð只需preFER获得现有的安装工作。

I don't mind having to re-install PHP if I really have to, if somebody can demonstrate the proper way to configure/compile with MySQL support, so that I can get it to work under Apache, although ideally I'd simply prefer to get the existing installation working.

在提前为任何帮助非常感谢!

Many thanks in advance for any assistance!

推荐答案

在情况下,任何人都面临着这一点,它是PHP不能获得MySQL客户端库的情况。具有系统上的MySQL服务器是不是正确的修复。修正了Ubuntu的(和PHP 5):

In case anyone else faces this, it's a case of PHP not having access to the mysql client libraries. Having a MySQL server on the system is not the correct fix. Fix for ubuntu (and PHP 5):

sudo apt-get install php5-mysql

安装客户端后,网络服务器应重新启动。如果你使用Apache,下面应该工作:

After installing the client, the webserver should be restarted. In case you're using apache, the following should work:

sudo service apache2 restart

这篇关于PHP /阿帕奇:PHP致命错误:调用未定义的函数mysql_connect()函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆