php5.2+mysql5.0+apache2.2

今天比较郁闷,之前配置好的php5.2+apache2.2环境随着系统的崩溃也不复存在了,重新在新的恢复的系统上搭个环境可总提示"Fatal error: Class 'mysqli' not found in..."。在网上找了大半个下午也没找到真正的解决办法,最终还是从php manual帮了忙;

根源:显然,上述问题源于未加载mysqli类,从而导致程序无法执行数据库查询;
分析:从配置文件来看应该从两个阶段中找寻出错原因,其一:apache加载php模块;其二:php.ini加载*.dll(例如php_mysqli.dll);
先看第一阶段:
如果浏览器访问*.php文件显示正常,这里的正常指文件能被正确解析,并能显示基本的界面(当然除了跟数据库查询相关的部分);如果此阶段界面显示出文件的原代码,说明apache配置有问题(httpd.conf),可以通过apache自带的test检查一下;

正确配置如下:
安装完apache2.*(2.0和2.2通杀)后,在httpd.conf最后加入下面的内容,无需更改其它内容:

对于PHP4
# For PHP 4 do something like this:
LoadModule php4_module "c:/php/php4apache2.dll"
#对apache2.0用php4apache2.dll,对apache2.2用php4apache2_2.dll
# Don't forget to copy the php4apache2.dll file from the sapi directory!
AddType application/x-httpd-php .php

对于PHP5
# For PHP 5 do something like this:
#对apache2.0用php5apache2.dll,对apache2.2用php4apache2_2.dll
LoadModule php5_module "c:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php

# configure the path to php.ini
PHPIniDir "C:/php"

#Congratulation, that is ok;

再看第二阶段
如果第一阶段没有问题,继续检查php.ini,首先找到display_startup_errors=off,把默认值off改为on,同时找到;extension=php_mysql.dll把";"号去掉,重启apache2,看到效果了吧?原来不报错的,现在会提示找不到dll

看一下报错的路径跟php的安装路径是否一致,若不一致,找到extension_dir,把值修改成的C:/php/ext路径
手册里是这样说的:
Some of the extensions need extra DLLs to work. Couple of them can be found in the distribution package, in the C:/php/dlls/ folder in PHP 4 or in the main folder in PHP 5, but some, for example Oracle (php_oci8.dll) require DLLs which are not bundled with the distribution package. If you are installing PHP 4, copy the bundled DLLs from C:/php/dlls folder to the main C:/php folder. Don't forget to include C:/php in the system PATH (this process is explained in a separate FAQ entry).

Some of these DLLs are not bundled with the PHP distribution. See each extensions documentation page for details. Also, read the manual section titled Installation of PECL extensions for details on PECL. An increasingly large number of PHP extensions are found in PECL, and these extensions require a separate download.

再来看看那张表

什么意思呢?就是说:php_mysqli.dll必须要跟libmysqli(与php.ini在同一目录下)捆绑加载或者说同时加载;
ok,那我把libmysqli.dll也放在php_mysqli.dll的目录下,同时再加个extention=libmysqli.dll;不好意思"这样真~不行"!^_^

终极解决方案:

在环境变量的path里把php的主目录加上即c:/php,重启机器!问题解决!(怎么修改环境变量?自己去搜下设置java环境变量==一堆)

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值