感谢支持
我们一直在努力

CentOS 6.3用ICC编译PHP5.4.8+Percona5.5.27+Tengine1.4.1

在上一篇文章里我们学习了如何安装ICC编译器,今天我们来记录一下用icc编译一台web服务器的过程。但是比较遗憾的是,根据我的测试,同样的参数,用icc编译出来的环境,运行discuz并未比用gcc编译出来的环境要有多大的提升,这是比较令人沮丧的。当然,也许是编译参数未能调整到最优的缘故。不管怎样,还是把这个编译过程记录下来吧,留作参考。

相关阅读:VMware虚拟机安装CentOS 6.3 见 http://www.linuxidc.com/Linux/2012-12/76583.htm
 
1、准备工作
 前提是你的服务器已经安装了icc编译器,没安装的话移步这里:http://www.linuxidc.com/Linux/2012-12/76637.htm
 
下载相关的源码:
 wget http://cn.php.net/get/php-5.4.8.tar.gz/from/this/mirror
 wget http://www.percona.com/redir/downloads/Percona-Server-5.5/LATEST/source/Percona-Server-5.5.27-rel29.0.tar.gz
 wget http://tengine.taobao.org/download/tengine-1.4.1.tar.gz
 wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
 wget https://github.com/downloads/libevent/libevent/libevent-2.0.20-stable.tar.gz
 wget “http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0”
 wget “http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?modtime=1194463373&big_mirror=0”
 wget http://download.savannah.gnu.org/releases/libunwind/libunwind-1.1.tar.gz
 wget https://gperftools.googlecode.com/files/gperftools-2.0.tar.gz
 wget http://downloads.sourceforge.net/project/pcre/pcre/8.31/pcre-8.31.tar.gz
 

其他还有memcache、imagick等大家就根据实际需要来下载安装吧。为了节约篇幅我们今天就不涉及这些东东了。
 设置动态链接库的路径,避免后续编译的时候出错:
 vi /etc/ld.so.conf
 最后增加:
 /opt/intel/lib/intel64/
 /usr/local/lib
 /usr/lib
 保存
 vi /etc/ld.so.conf.d/usr_local_lib.conf
 /usr/local/lib
 /usr/lib
 保存
 ldconfig
 
2、编译安装
 tar zxvf libunwind-*.tar.gz
 cd libun*
 CC=icc \
 CXX=icpc \
 LD=xild \
 AR=xiar \
 CFLAGS=’-O3 -xSSE4.2 -axSSE4.2,SSE4.1,SSE3,SSE2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel -fPIC’ \
 CXXFLAGS=’-O3 -xSSE4.2 -axSSE4.2,SSE4.1,SSE3,SSE2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel -fno-implicit-templates -fno-exceptions -fno-rtti -fPIC’ \
 ./configure
 make && make install
 cd ..
 
tar zxvf gperftools-2.0.tar.gz
 cd gperftools-2.0
 CC=icc \
 CXX=icpc \
 LD=xild \
 AR=xiar \
 CFLAGS=”-O3 -no-prec-div -ip -fp-model fast=1 -xSSE4.2 -axSSE4.2,SSE4.1,SSE3,SSE2 -fPIC” \
 CXXFLAGS=”${CFLAGS}” \
 CPPFLAGS=” -I/opt/intel/include ” \
 ./configure
 make && make install
 cd ..
 
tar xzvf libic*
 cd libic*
 CC=icc \
 CXX=icpc \
 LD=xild \
 AR=xiar \
 CFLAGS=’-O3 -xSSE4.2 -axSSE4.2,SSE4.1,SSE3,SSE2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel’ \
 CXXFLAGS=’-O3 -xSSE4.2 -axSSE4.2,SSE4.1,SSE3,SSE2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel -fno-implicit-templates -fno-exceptions -fno-rtti’ \
 ./configure –prefix=/usr/local
 make && make install
 cd ..
 
tar xzvf libmcry*
 cd libmcry*
 CC=icc \
 CXX=icpc \
 LD=xild \
 AR=xiar \
 CFLAGS=’-O3 -xSSE4.2 -axSSE4.2,SSE4.1,SSE3,SSE2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel’ \
 CXXFLAGS=’-O3 -xSSE4.2 -axSSE4.2,SSE4.1,SSE3,SSE2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel -fno-implicit-templates -fno-exceptions -fno-rtti’ \
 ./configure
 make && make install
 /sbin/ldconfig
 cd libltdl/
 CC=icc \
 CXX=icpc \
 LD=xild \
 AR=xiar \
 CFLAGS=’-O3 -xSSE4.2 -axSSE4.2,SSE4.1,SSE3,SSE2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel’ \
 CXXFLAGS=’-O3 -xSSE4.2 -axSSE4.2,SSE4.1,SSE3,SSE2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel -fno-implicit-templates -fno-exceptions -fno-rtti’ \
 ./configure –enable-ltdl-install
 make && make install
 cd ../../
 
tar zxvf mcrypt-2.6.8.tar.gz
 cd mcrypt-2.6.8/
 /sbin/ldconfig
 CC=icc \
 CXX=icpc \
 LD=xild \
 AR=xiar \
 CFLAGS=’-O3 -xSSE4.2 -axSSE4.2,SSE4.1,SSE3,SSE2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel’ \
 CXXFLAGS=’-O3 -xSSE4.2 -axSSE4.2,SSE4.1,SSE3,SSE2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel -fno-implicit-templates -fno-exceptions -fno-rtti’ \
 ./configure
 make && make install
 cd ../
 
/usr/sbin/groupadd mysql
 /usr/sbin/useradd -g mysql mysql

tar zxvf Percona-Server-*.tar.gz
cd Percona-Server-*
CC=icc \
CXX=icpc \
LD=xild \
AR=xiar \
CFLAGS=”-O3 -no-prec-div -unroll2 -ip -restrict -fp-model fast=1 -fno-rtti -xSSE4.2 -axSSE4.2,SSE4.1,SSE3,SSE2 -static-intel -static-libgcc” \
CXXFLAGS=”${CFLAGS}” \
CPPFLAGS=” -I/opt/intel/lib/intel64/ ” \
LDFLAGS=” -L/opt/intel/lib/intel64/ -lrt -lunwind -ltcmalloc_minimal -lstdc++ ” \
cmake . -DCMAKE_BUILD_TYPE:STRING=Release \
-DSYSCONFDIR:PATH=/etc \
-DCMAKE_INSTALL_PREFIX:PATH=/usr/local/mysql \
-DENABLED_PROFILING:BOOL=ON \
-DENABLE_DEBUG_SYNC:BOOL=OFF \
-DMYSQL_DATADIR:PATH=/var/lib/mysql \
-DMYSQL_MAINTAINER_MODE:BOOL=OFF \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk,gb2312 \
-DWITH_BIG_TABLES:BOOL=ON \
-DWITH_FAST_MUTEXES:BOOL=ON \
-DENABLE-PROFILING:BOOL=ON \
-DWITH_SSL:STRING=bundled \
-DWITH_UNIT_TESTS:BOOL=OFF \
-DWITH_ZLIB:STRING=bundled \
-DWITH_PARTITION_STORAGE_ENGINE:BOOL=ON \
-DWITH_SERVER_SUFFIX=hxsw \
-DWITH_PLUGINS=heap,csv,partition,innodb_plugin,myisam \
-DEFAULT_COLLATION=utf8_general_ci \
-DEFAULT_CHARSET=utf8 \
-DENABLED_ASSEMBLER:BOOL=ON \
-DENABLED_LOCAL_INFILE:BOOL=ON \
-DENABLED_THREAD_SAFE_CLIENT:BOOL=ON \
-DENABLED_EMBEDDED_SERVER:BOOL=OFF \
-DWITH_CLIENT_LDFLAGS:STRING=all-static \
-DINSTALL_LAYOUT:STRING=STANDALONE \
-DCOMMUNITY_BUILD:BOOL=ON;

make && make install

chmod +w /usr/local/mysql

chown -R mysql:mysql /usr/local/mysql

cp support-files/mysql.server /etc/rc.d/init.d/mysqld

chmod 755 /etc/rc.d/init.d/mysqld

chkconfig –add mysqld

chkconfig –level 3 mysqld on

cp support-files/my-huge.cnf /etc/my.cnf

/usr/local/mysql/scripts/mysql_install_db –user=mysql –defaults-file=/etc/my.cnf –basedir=/usr/local/mysql/ –datadir=/var/lib/mysql/

echo “export PATH=/usr/local/mysql/bin:$PATH” >>/etc/profile

source /etc/profile

cd ..

tar xzvf php-5.4*
cd php-5.4*
CC=icc \
CXX=icpc \
LD=xild \
AR=xiar \
CFLAGS=’-O3 -xSSE4.2 -axSSE4.2,SSE4.1,SSE3,SSE2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel’ \
CXXFLAGS=’-O3 -xSSE4.2 -axSSE4.2,SSE4.1,SSE3,SSE2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel -fno-implicit-templates -fno-exceptions -fno-rtti’ \
CPPFLAGS=” -I/opt/intel/lib/intel64/ ” \
LDFLAGS=” -L/opt/intel/lib/intel64/ -lrt -lunwind -ltcmalloc_minimal -lstdc++ ” \
./configure –prefix=/usr/local/php –with-config-file-path=/etc \
–with-mysql=mysqlnd –with-mysqli=mysqlnd \
–with-iconv-dir=/usr/local –enable-fpm \
–disable-phar –with-fpm-user=nobody –with-fpm-group=nobody –with-pcre-regex \
–with-openssl –with-zlib –with-bz2 –enable-calendar –with-curl –enable-dba –with-libxml-dir \
–enable-ftp –with-gd –with-xmlrpc –with-jpeg-dir –with-png-dir –with-zlib-dir –with-freetype-dir \
–enable-gd-native-ttf –enable-gd-jis-conv –with-mhash –enable-mbstring –with-mcrypt \
–enable-pcntl –disable-debug –enable-xml –disable-rpath –enable-shmop –enable-sockets –enable-zip \
–enable-bcmath –disable-ipv6
make ZEND_EXTRA_LIBS=’-liconv’
make install

cp php.ini-production /etc/php.ini

cd ..

tar xzvf libevent*
cd libevent*
CC=icc \
CXX=icpc \
LD=xild \
AR=xiar \
CFLAGS=’-O3 -xSSE4.2 -axSSE4.2,SSE4.1,SSE3,SSE2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel’ \
CXXFLAGS=’-O3 -xSSE4.2 -axSSE4.2,SSE4.1,SSE3,SSE2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel -fno-implicit-templates -fno-exceptions -fno-rtti’ \
CPPFLAGS=” -I/opt/intel/lib/intel64/ ” \
LDFLAGS=” -L/opt/intel/lib/intel64/ -lrt -lunwind -ltcmalloc_minimal -lstdc++ ” \
./configure –prefix=/usr/local
make && make install
cd ..

tar zxvf pcre-*.tar.gz
cd pcre-*
CC=icc \
CXX=icpc \
LD=xild \
AR=xiar \
./configure –prefix=/usr/local/pcre
make && make install
cd ..

tar xzvf tengine*
cd tengine*
CC=icc \
CXX=icpc \
LD=xild \
AR=xiar \
CFLAGS=’-O3 -xSSE4.2 -axSSE4.2,SSE4.1,SSE3,SSE2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel’ \
CXXFLAGS=’-O3 -xSSE4.2 -axSSE4.2,SSE4.1,SSE3,SSE2 -ip -unroll2 -no-prec-div -fp-model source -restrict -static-intel -fno-implicit-templates -fno-exceptions -fno-rtti’ \
CPPFLAGS=” -I/opt/intel/lib/intel64/ ” \
LDFLAGS=” -L/opt/intel/lib/intel64/ -lrt -lunwind -ltcmalloc_minimal -lstdc++ ” \
./configure –prefix=/usr/local/nginx –conf-path=/usr/local/nginx/conf/nginx.conf –with-google_perftools_module –with-http_sysguard_module –with-http_realip_module –with-http_addition_module –with-http_gzip_static_module –with-http_random_index_module –with-http_stub_status_module –with-http_sub_module –with-http_dav_module –with-http_concat_module –with-pcre
make && make install

特别说明:用icc编译tengine的时候,with-pcre后面如果跟上pcre的路径,就会报错,这跟gcc编译正好相反。。。

赞(0) 打赏
转载请注明出处:服务器评测 » CentOS 6.3用ICC编译PHP5.4.8+Percona5.5.27+Tengine1.4.1
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏