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

每月存档 十月, 2011

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
就可以了

利用rpmbuild制作MySQL的rpm包

1、配置环境
yum -y install rpm-build
2、下载源代码rpm包
mkdir /root/download
cd /root/download
wget http://www.percona.com/redir/downloads/Percona-Server-5.1/Percona-Server-5.1.58-12.9/source/Percona-Server-51-5.1.58-rel12.9.271.rhel6.src.rpm

3、安装打包MySQL时依赖的包

yum -y install perl readline-devel gcc-c++ ncurses-devel zlib-devel libtool automake autoconf time ccache bison

4、安装percona的源代码
rpm -ivh Percona-Server-51-5.1.58-rel12.9.271.rhel6.src.rpm

安装了2个文件,它们的位置是
/root/rpmbuild/SOURCES/Percona-Server-5.1.58.tar.gz
/root/rpmbuild/SPECS/percona-server.spec

5、修改percona-server.spec
加入我们自己的编译参数
vi percona-server.spec

# The –enable-assembler simply does nothing on systems that does not
# support assembler speedups.

%if %{YASSL_BUILD}
之间的一段修改成这样

# The –enable-assembler simply does nothing on systems that does not
# support assembler speedups.
sh -c  “CFLAGS=\”$CFLAGS\” \
CXXFLAGS=\”$CXXFLAGS\” \
AM_CPPFLAGS=\”$AM_CPPFLAGS\” \
LDFLAGS=\”$LDFLAGS\” \
./configure \
$* \
–with-comment=MC-DB \
–with-server-suffix=-MC-DB-Server \
–with-charset=utf8 \
–with-plugins=blackhole,csv,innodb_plugin \
–enable-assembler \
–enable-local-infile \
–with-mysqld-user=%{mysqld_user} \
–with-unix-socket-path=/tmp/mysql.sock \
–with-pic \
-prefix=/usr \
–with-extra-charsets=gbk,gb2312,utf8 \
–without-debug \
–with-pthread \
–enable-thread-safe-client \
–with-client-ldflags=-all-static \
–without-ndb-debug \
%if %{YASSL_BUILD}

保存退出

6、定义在打包过程中不进行测试
export MYSQL_RPMBUILD_TEST=”no”

7、开始打包
cd /root/rpmbuild/SPECS/
rpmbuild -bb percona-server.spec
等待一段时间就可以看到编译好的软件包
/root/rpmbuild/RPMS/x86_64

Percona-Server-client-51-5.1.58-rel12.9.rhel6.x86_64.rpm
Percona-Server-devel-51-5.1.58-rel12.9.rhel6.x86_64.rpm
Percona-Server-server-51-5.1.58-rel12.9.rhel6.x86_64.rpm
Percona-Server-shared-51-5.1.58-rel12.9.rhel6.x86_64.rpm
Percona-Server-test-51-5.1.58-rel12.9.rhel6.x86_64.rpm

7、安装顺序
先安装这个
Percona-Server-shared-51-5.1.58-rel12.9.rhel6.x86_64.rpm
再安装其他软件包
8、已知问题:
无法打包为一个包
无法将所有问题安装到一个目录,例如我们之前一直安装的目录/usr/local/mysql

9、题外话
一般MySQL源代码包都有包含打包所需要的spec文件,一般存放在support-files/下

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

2011年十月
« 8月   11月 »
 12
3456789
10111213141516
17181920212223
24252627282930
31