设为首页 收藏本站
查看: 1505|回复: 0

[经验分享] RHEL5下如何打开PHP对MYSQL的支持?

[复制链接]

尚未签到

发表于 2018-12-24 10:35:56 | 显示全部楼层 |阅读模式
RHEL5默认安装后,PHP对MYSQL不支持,也就是说在使用PHP调用MYSQL数据时,会提示Mysql_Connect错误,出现这种情况跟PHP的RPM包的编译是有关系的,我们来看一下,用phpinfo()函数打印出来的默认PHP信息:'./configure' '--build=i386-redhat-linux' '--host=i386-redhat-linux' '--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib64' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--without-pear' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-pspell' '--with-expat-dir=/usr' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--with-kerberos' '--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr' '--enable-memory-limit' '--enable-shmop' '--enable-calendar' '--enable-dbx' '--enable-dio' '--with-mime-magic=/usr/share/file/magic.mime' '--without-sqlite' '--with-libxml-dir=/usr' '--with-xml' '--with-system-tzdata' '--with-apxs2=/usr/sbin/apxs' '--without-mysql' '--without-gd' '--without-odbc' '--disable-dom' '--disable-dba' '--without-unixODBC' '--disable-pdo' '--disable-xmlreader' '--disable-xmlwriter'


主要是加红粗体部分参数,导致PHP不支持Mysql函数调用,下面我们就来进行PHP的重新编译安装。
首先,请在你的系统安装光盘上查找如下安装包(从安装光盘上查找的原因是可以保证安装包版本同你现在在使用的系统版本一致):
httpd-devel-2.2.3-6.el5.i386.rpm


mysql-devel-5.0.22-2.1.i386.rpm


php-devel-5.1.6-5.el5.i386.rpm


pcre-devel-6.6-1.1.i386.rpm


libjpeg-devel-6b-37.i386.rpm


libpng-devel-1.2.10-7.i386.rpm


freetype-devel-2.2.1-16.el5.i386.rpm


unixODBC-devel-2.2.11-7.1.i386.rpm


aspell-devel-0.60.3-7.1.i386.rpm



以上安装包可以保证在重新编译PHP的过程中,防止由于缺少.h头文件,导致编译失败,比如:
Configure: error: libjpeg.(also) not found.

说明系统中缺少libjpeg的开发库文件,需要相关文件的支持。如果你遇到其他错误,可以将错误信息复制到GOOGLE进行相关搜索,网络上会有更详细的介绍说明以及解决办法。

以上安装包可以通过如下命令,在进行PHP编译安装之前安装到系统中:
[root@nbuit bbs]# rpm -ivh pcre-devel-6.6-1.1.i386.rpm

部分安装包会有依赖关系,在这里不做具体说明,请参考其他文章进行解决。

现在,我们下载php-5.3.0.tar.bz2准备进行编译安装。
[root@nbuit web]# tar jxvf php-5.3.0.tar.bz2

[root@nbuit web]# cd php-5.3.0

[root@nbuit web]# './configure' '--build=i386-redhat-linux' '--host=i386-redhat-linux' '--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=/lib' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--with-pear' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--with-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-pspell=/usr' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-wddx' '--with-kerberos' '--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr' '--enable-shmop' '--enable-calendar' '--without-sqlite' '--with-libxml-dir=/usr' '--with-apxs2=/usr/sbin/apxs' '--with-mysql' '--with-gd' '--enable-dom' '--enable-dba' '--with-unixODBC=shared,/usr' '--enable-pdo' '--enable-xmlreader' '--enable-xmlwriter' '--with-mysqli' '--enable-inline-optimization'

[root@nbuit web]# make

[root@nbuit web]# make test

[root@nbuit web]# make install

最后,使用phpinfo()函数检查php信息里,是否有关于mysql的相关信息,以及php的版本是否己经升级到5.3.0  

说明一点:如果您在编译PHP的时候,结果里有如下相关显示,请对编译命令中的相关参数进行删除。
Notice: Following unknown configure options were used:

--with-png
--with-expat-dir=/usr
--enable-track-vars
--enable-trans-sid
--enable-yp
--enable-memory-limit
--enable-dbx
--enable-dio
--with-mime-magic=/etc/httpd/conf/magic
--with-xml
--without-odbc

Check './configure --help' for available options




以上希望对遇到相同问题的朋友有所帮助,也希望高手多多指正错误,联系方式:31312532@qq.com




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-655194-1-1.html 上篇帖子: nginx+php+mysql安装配置 下篇帖子: 对php安装的一些体会
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表