简体   繁体   English

无法让 PHP 在 Vista 64 上与 MySQL 一起工作

[英]Can't get PHP to work with MySQL on Vista 64

I'm running Vista 64 box, and attempting to setup Joomla using IIS7 (I like Joomla, I want to have some asp.net components on my web site, so that's why I want to use IIS7 and not Apache).我正在运行 Vista 64 机器,并尝试使用 IIS7 设置 Joomla(我喜欢 Joomla,我想在我的网站上有一些 asp.net 组件,所以这就是我想使用 IIS7 而不是 Apache 的原因)。 It's my first time installing both PHP and MySQL, so it's very possible that I'm doing something obviously wrong... though I think I tried enough diagnostic steps (described below) that there's nothing obviously wrong to me ...这是我第一次同时安装 PHP 和 MySQL,所以很可能我做错了什么……尽管我认为我尝试了足够多的诊断步骤(如下所述),对我来说没有什么明显的错误……

I installed PHP (32 bit, 5.2.8), and that seems to work OK: I got a test.php that displays phpinfo in an IIS7-served web page.我安装了 PHP(32 位,5.2.8),这似乎工作正常:我有一个test.php ,它在 IIS7 提供的网页中显示 phpinfo。

I also installed MySQL (32 bit, 5.1.31, downloaded from http://dev.mysql.com/downloads/mysql/5.1.html#win32 ).我还安装了 MySQL(32 位,5.1.31,从http://dev.mysql.com/downloads/mysql/5.1.html#win32下载)。 That seems to work fine too (I can connect to it using MySQL Administrator).这似乎也可以正常工作(我可以使用 MySQL Administrator 连接到它)。

I've setup php.ini and what not to turn on the MySQL extension.我已经设置了php.ini和什么不打开 MySQL 扩展。 If I do PHP -m from the command line I see MySQL in the list.如果我从命令行执行 PHP -m,我会在列表中看到 MySQL。 However, with phpinfo (either from the command line (PHP -info) or served via IIS (in a test.php file)), there is no MySQL section.但是,使用 phpinfo(来自命令行 (PHP -info) 或通过 IIS 提供服务(在test.php文件中)),没有 MySQL 部分。 Because MySQL is not even showing up in the command-line call of PHP, I don't think this has anything to do with IIS -- just an install of MySQL & PHP on vista.因为 MySQL 甚至没有出现在 PHP 的命令行调用中,所以我认为这与 IIS 没有任何关系——只是在 vista 上安装了 MySQL 和 PHP。

I didn't install MySQL 64bit because I have an 32bit install of PHP, and since MySQL 32 bit seems to work fine I assume that's not the issue.我没有安装 MySQL 64 位,因为我安装了 32 位 PHP,并且由于 MySQL 32 位似乎工作正常,我认为这不是问题。 It seems there is no official 64bit version of PHP so that's why I installed that (and again, that seems to work fine).似乎没有官方的 64 位 PHP 版本,所以这就是我安装它的原因(同样,它似乎工作正常)。

I currently have UAC disabled, so that's not the issue.我目前禁用了 UAC,所以这不是问题。

If I put the semi-colon back in front of extension=php_mysql.dll in my php.ini then when running PHP -m, the MySQL module doesn't show up.如果我在我的php.ini中将分号放回 extension=php_mysql.dll 的前面,那么在运行 PHP -m 时,MySQL 模块不会出现。 If I take it out again then it shows up.如果我再把它拿出来,它就会出现。 So I'm at least certain I'm modifying the right php.ini .所以我至少可以确定我正在修改正确的php.ini

I've copied libeay32.dll , libmysql.dll , and php_mysql.dll to c:\windows\system32 .我已将libeay32.dlllibmysql.dllphp_mysql.dll复制到c:\windows\system32 I've taken them out and that doesn't seem to make a difference to the output of PHP -m (ie, MySQL still shows up there if the module is uncommented from php.ini ).我已将它们取出,这似乎对 PHP -m 的输出没有影响(即,如果模块未从php.ini注释,MySQL 仍会显示在那里)。

I also tried copying the DLLs ibeay32.dll , libmysql.dll , and php_mysql.dll to c:\windows\sysWOW64 ;我还尝试将 DLL ibeay32.dlllibmysql.dllphp_mysql.dll复制到c:\windows\sysWOW64 that made no difference.这没有什么区别。

It seems like the smallest positive step would be for MySQL to show up when running PHP -info from the command line.似乎最小的积极步骤是在从命令行运行 PHP -info 时出现 MySQL。 Is there any further thing I should try to figure out why MySQL is showing up in PHP -m and not with PHP -info?还有什么我应该尝试弄清楚为什么 MySQL 出现在 PHP -m 而不是 PHP -info 中的原因吗? Or am I off track as using this to gauge whether PHP can talk to MySQL?或者我是否偏离了使用它来衡量 PHP 是否可以与 MySQL 对话的轨道?

I've solved most of it.我已经解决了大部分。

The answer was to copy libmysql.dll to sysWOW64.答案是将libmysql.dll复制到 sysWOW64。 The other DLLs are not needed, and nothing needs to be copied to system32.不需要其他 DLL,也不需要将任何内容复制到 system32。 I guess this is a result of using php32 on a 64 bit system.我猜这是在 64 位系统上使用 php32 的结果。

I thought that didn't work at first because running PHP -info from the command line still doesn't show MySQL.起初我认为这不起作用,因为从命令行运行 PHP -info 仍然没有显示 MySQL。 However, running phpinfo from a PHP file served by IIS does show MySQL.但是,从 IIS 提供的 PHP 文件运行 phpinfo 会显示 MySQL。

I still don't know why MySQL doesn't show up when running PHP -info from the command line, but I guess I can live with this for now.我仍然不知道为什么从命令行运行 PHP -info 时 MySQL 没有出现,但我想我现在可以忍受这个。

If you want to focus on the php development I strongly suggest you don't manually install these things and go download xampp from http://www.apachefriends.org/en/xampp.html如果您想专注于 php 开发,我强烈建议您不要手动安装这些东西,而是从http://www.apachefriends.org/en/xampp.html下载 xampp

Basically this is a completely tested and build package which will link the software and give you a full develoment environment.基本上,这是一个经过全面测试和构建的软件包,它将链接软件并为您提供完整的开发环境。

There are other apache/php/mysql bundles out there as well.还有其他 apache/php/mysql 捆绑包。

The thing here is that as soon as you have the apache php working with mysql, you can just configure the IIS connector easily and you won't break the mysql connectivity这里的问题是,只要你让 apache php 与 mysql 一起工作,你就可以轻松配置 IIS 连接器,并且不会破坏 mysql 连接

Also remember to check everything with还记得检查一切

Are you sure the same php.ini is used for CLI and IIS?您确定 CLI 和 IIS 使用相同的php.ini吗? On POSIX-compatible systems, php normally uses two different ones.在 POSIX 兼容的系统上,php 通常使用两个不同的系统。 In my experience, inadvertly using the wrong php.ini is the major roadblock for php on Windows.根据我的经验,无意中使用了错误的 php.ini 是 Windows 上 php主要障碍。

Try slightly changing an option in php.ini (like memory_limit to 129M instead of 128M or so) and use ini_get to find out whether the change affects php@IIS/@CLI.尝试稍微更改 php.ini 中的选项(例如将memory_limit更改为129M而不是128M左右)并使用ini_get确定更改是否会影响 php@IIS/@CLI。 If this indeed only affects php@IIS, search for php.ini on C: - maybe there's a second one (usually in the PATH , like C:\Windows\php.ini ).如果这确实只影响 php@IIS,请在C:上搜索php.ini - 也许还有第二个(通常在PATH中,如C:\Windows\php.ini )。

The following is a link to a nice step-by-step article that I have followed successfully.以下是我成功遵循的一篇不错的分步文章的链接。 It does not address x64 specifically, but honestly I don't think that is the problem with your configuration.它没有专门针对 x64,但老实说,我认为这不是您的配置的问题。 Link 关联

我在 vista 64 上遇到了几乎相同的问题,问题是 system32 中 PHP 安装的libmysql.dll被我替换的 MySQL 安装覆盖,mysqladmin 和 Joomla 工作正常。

You can also try setting up a separate Application Pool in IIS7 for 32 bit apps, then in the Advanced settings for the pool, set "Enable 32-Applications" to true (default is false).您还可以尝试在 IIS7 中为 32 位应用程序设置单独的应用程序池,然后在池的高级设置中,将“启用 32 应用程序”设置为 true(默认为 false)。 Then set the php site to use that app pool.然后将 php 站点设置为使用该应用程序池。

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

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