寻觅生命中的那一片浅草......

文章带标签 CentOS6

64位CentOS6系统上编译PHP

CentOS 6 64位版本,默认是不会安装32位软件的,这样就导致我们在安装PHP前安装的库,只会有64位版本

例如
yum -y install libjpeg libjpeg-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel mhash freetype freetype-devel

这样安装,系统默认只会安装64位版本,假设我们用以下命令去安装PHP

CHOST=”x86_64-pc-linux-gnu” CFLAGS=”-march=nocona -O2 -pipe” CXXFLAGS=”-march=nocona -O2 -pipe” \
./configure –prefix=/usr/local/php \
–with-config-file-path=/etc \
–with-mysql=/usr/loca/mysql –with-pdo-mysql=/usr/local/mysql/bin/mysql_config \
–with-mysqli=/usr/local/mysql/bin/mysql_config \
–with-iconv-dir=/usr/local \
–with-freetype-dir –with-jpeg-dir \
–with-png-dir –with-ttf \
–enable-zip –with-zlib \
–with-gd \
–disable-rpath –enable-discard-path \
–enable-safe-mode –enable-bcmath \
–enable-shmop –enable-sysvsem \
–with-curl –with-curlwrappers \
–enable-fastcgi –enable-force-cgi-redirect \
–enable-mbstring –with-mcrypt \
–disable-ipv6 \
–enable-static \
–enable-maintainer-zts \
–enable-zend-multibyte \
–enable-sockets \
–enable-soap \
–with-openssl \
–without-sqlite –without-pdo-sqlite

则会提示
configure: error: libjpeg.(a|so) not found.

通过rpm -qa |grep libjpeg是有安装的

解决办法是在configure里加入

–with-libdir=lib64

修改后是这样

CHOST=”x86_64-pc-linux-gnu” CFLAGS=”-march=nocona -O2 -pipe” CXXFLAGS=”-march=nocona -O2 -pipe” \
./configure –prefix=/usr/local/php \
–with-libdir=lib64 \
–with-config-file-path=/etc \
–with-mysql=/usr/loca/mysql –with-pdo-mysql=/usr/local/mysql/bin/mysql_config \
–with-mysqli=/usr/local/mysql/bin/mysql_config \
–with-iconv-dir=/usr/local \
–with-freetype-dir –with-jpeg-dir \
–with-png-dir –with-ttf \
–enable-zip –with-zlib \
–with-gd \
–disable-rpath –enable-discard-path \
–enable-safe-mode –enable-bcmath \
–enable-shmop –enable-sysvsem \
–with-curl –with-curlwrappers \
–enable-fastcgi –enable-force-cgi-redirect \
–enable-mbstring –with-mcrypt \
–disable-ipv6 \
–enable-static \
–enable-maintainer-zts \
–enable-zend-multibyte \
–enable-sockets \
–enable-soap \
–with-openssl \
–without-sqlite –without-pdo-sqlite

不过,由于我们MySQL不是用rpm包装的,是自编译安装在/usr/local/mysql
如果使用以上configure参数,则会提示

configure: error: Cannot find libmysqlclient_r under /usr/local/mysql/.
Note that the MySQL client library is not bundled anymore!

此时做个修改

ln -s /usr/local/mysql/lib /usr/local/mysql/lib64

这样就可以configure通过了,然后就make && make install吧

题外话,如果要在CentOS6 64位上yum安装32位的软件
echo ‘multilib_policy=all’ >> /etc/yum.conf
就可以了

64位CentOS6通过yum安装32位软件

64位CentOS 6 通过yum安装软件的时候,默认不会安装32位的软件,这样会导致某些软件无法安装成功,实际上yum仓库里是有32位软件的,只是它默认只安装64位软件,如果需要安装32位,有2个方法,
假设你要安装libjpeg的32位版本

方法1:
先查询
yum list |grep libjpeg
指定安装32位版
yum install libjpeg.i686

方法2:
这是一种一劳永逸的方法
echo ‘multilib_policy=all’ >> /etc/yum.conf
以下命令会同时安装32位和64位版
yum install libjpeg 

参考资料:http://grokbase.com/t/centos.org/centos/2011/07/centos-centos6-installing-32bit-and-64bit-rpms-via-the-installer/133tcfqf5pag5uldm62ygv34psia

2024年十月
« 5月    
 123456
78910111213
14151617181920
21222324252627
28293031