安装带有 MySQL 支持的 php 时遇到问题

安装带有 MySQL 支持的 php 时遇到问题

所以我不确定这个问题在这里最好还是在溢出或服务器故障上最好,但决定先在这里尝试。我正在 VPS 上安装 LAMP,并且遇到配置和构建 PHP 的问题。我已经安装了 MySQL,并且运行良好。我正在尝试对带有 MySQL 支持的 PHP 进行基本安装,如下所示:

http://www.php.net/manual/en/install.unix.apache2.php

这是我正在运行的配置命令:

./configure –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql 

我收到此错误:

configure: error: Cannot find MySQL header files under yes.
Note that the MySQL client library is not bundled anymore!

我刚刚使用 yum install mysql-server mysql 进行了基本的默认 MySQL 安装。

经过一番谷歌搜索后,我安装了 mysql-devel 来消除该错误:

yum install mysql-devel 

然后我开始收到这个错误:

configure: error: Try adding –with-zlib-dir=<DIR>. Please check config.log for more   information. 

好的。所以我将命令更改为:

./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-zlib

现在我明白了:

configure: error: mysql configure failed. Please check config.log for more information. 

老实说,此时有点迷失。我正在查看 config.log,但不太确定我需要寻找什么。以下是我认为可能相关的部分:

configure:60061: gcc -o conftest -I/usr/include -g -O2 -fvisibility=hidden-Wl,-rpath,/usr/lib/mysql -L/usr/lib/mysql -L/usr/lib  conftest.c -lmysqlclient  -lz -lrt -lm -ldl -lnsl  -lxml2 -lz -lm -lxml2 -lz -lm 1>&5
/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.so when searching for -lmysqlclient
/usr/bin/ld: skipping incompatible /usr/lib/mysql/libmysqlclient.a when searching for -lmysqlclient
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
configure: failed program was:
#line 60050 "configure"
#include "confdefs.h"

有什么想法吗?或者我应该在 config.log 中查看其他内容?

答案1

我建议寻找适合您的发行版的二进制包。

如果您想坚持从源代码构建,我建议您在安装新库后从原始源代码开始。该configure程序会保留所找到的内容的缓存,有时不会意识到缓存不再是最新的。如果configure运行完毕并生成了一个Makefile,则运行make distclean。否则,如果 PHP 没有做任何太奇特的事情,rm config.cache config.status应该可以解决问题。

答案2

您所遵循的手册有点复杂。我建议你关注LAMP 上的 Linode 指南堆。一步步按照步骤操作(几乎不需要 20 分钟),就完成了。

笔记:如果您计划运行一些开源应用程序,请暂时跳过 Suhosin (php5-suhosin) 包。它在 Linode 上使用 Wordpress 时出现问题。

答案3

如果您从源代码安装了 MySQL,则还必须安装/编译,mysql-connector以便 PHP 可以找到所需的头文件。

相关内容