apache2.2 php5 mysql_Apache 2.2 + PHP5 + MySQL的配置

1.在Apache中加载PHP

LoadModule php5_module X:/php/php5apache2_2.dll

PHPIniDir "X:/php"

需要注意的是dll对应的apache版本,也就是php5apache后面的数字。

2.在PHP5中连接MySQL5

PHP5中已经不直接支持MySQL了,需要自己手动配置,官方网站中是这样说明的:

MySQL is supported with the only change being that MySQL support is no longer enabled by default in PHP 5. This essentially means that PHP doesn't include the --with-mysql option in the configure line so that you must now manually do this when compiling PHP. Windows users will edit php.ini and enable the php_mysql.dll DLL as in PHP 4 no such DLL existed, it was simply built into your Windows PHP binaries.

Also, the MySQL client libraries are no longer bundled with PHP. More details on this topic are covered in the following FAQ and be sure to read the MySQL section for details on installing MySQL. An example configure line would be --with-mysql=/usr while Windows users will need the libmySQL.dll available to the system.

先修改php.ini的内容

extension_dir = "X:\php\ext"

并去掉下面两项的分号

extension=php_mysql.dll

extension=php_mysqli.dll

然后,将php目录下的libmysql.dll拷贝到C:\Windows目录,之后MySQL就可以正常连接了。

写个程序来测试一下吧。

1 <?php2  $link=mysql_connect("localhost","username","password")3 ordie("Could not connect:".mysql_error());4 print("Connected successfully");5 mysql_close($link);6 ?>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值