centos6.6 编译安装php7和php扩展

编译php7

机器环境

CentOS release 6.6 (Final)
kernal 2.6.32-504.23.4.el6.x86_64

yum

yum install -y curl libcurl-devel libjpeg-devel libpng-devel libjped-devel freetype-devel libxslt-devel boost-devel gperf libevent-devel libuuid-devel libgearman libgearman-devel

install php

下载目录: /opt/
安装目录: /Data/apps/php/

cd /opt
wget http://docs.php.net/distributions/php-7.0.28.tar.gz
tar xf php-7.0.28.tar.gz
cd php-7.0.28
./configure --with-libdir=lib64 --prefix=/Data/apps/php --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gd --with-zlib --with-png-dir --with-jpeg-dir --with-iconv --with-curl --with-mcrypt --with-openssl --with-xsl --enable-opcache --enable-inline-optimization --enable-fpm --enable-mbstring --enable-pcntl --enable-soap --enable-sockets --enable-bcmath --with-libxml --with-freetype-dir=/usr/include/freetype2/ --disable-phar

make && make install

php 扩展

下面所有php扩展包的下载目录统一为: /opt/soft/

opcache

cd /opt/php-7.0.28/ext
/Data/apps/php/bin/phpize
./configure --with-php-config=/Data/apps/php/bin/php-config
make && make install

xdebug

从2.4开始支持php7

下载地址: https://xdebug.org/files/

wget https://xdebug.org/files/xdebug-2.6.0.tgz
tar xf xdebug-2.6.0.tgz
cd xdebug-2.6.0
/Data/apps/php/bin/phpize
./configure --with-php-config=/Data/apps/php/bin/php-config
make
make install

igbinary

最新版本(2.0.5),2.0.1开始支持7.0

详情连接: http://pecl.php.net/package-changelog.php?package=igbinary

wget https://pecl.php.net/get/igbinary-2.0.5.tgz
tar xf igbinary-2.0.5.tgz
cd igbinary-2.0.5
/Data/apps/php/bin/phpize
./configure --with-php-config=/Data/apps/php/bin/php-config
make
make install

memcached

memcached版本要求:
    php-memcached 3.x
    Supports PHP 7.0 - 7.2.
    Requires libmemcached 1.x or higher.
    Optionally supports igbinary 2.0 or higher.
    Optionally supports msgpack 2.0 or higher.
安装libmemcached 依赖包
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gzc
tar -zxf libmemcached-1.0.18.tar.gz
./configure --prefix=/Data/apps/libmemcached --with-memcached
make && make install
wget https://pecl.php.net/get/memcached-3.0.0.tgz
tar xf memcached-3.0.0.tgz
cd /opt/soft/memcached-3.0.0
/Data/apps/php/bin/phpize
./configure --with-php-config=/Data/apps/php/bin/php-config --with-libmemcached-dir=/Data/apps/libmemcached --enable-memcached --enable-memcached-igbinary
make && make install

遇到这样的报错
configure: error: no, sasl.h is not available. Run configure with --disable-memcached-sasl to disable this check
根据提示加上参数重新编译

./configure --with-php-config=/Data/apps/php/bin/php-config --with-libmemcached-dir=/Data/apps/libmemcached --enable-memcached --enable-memcached-igbinary  --disable-memcached-sasl
make && make install

imagick

下载地址:https://pecl.php.net/package/imagick

安装ImageMagick(ImageMagick-7.0.7-28)
wget ftp://mirror.checkdomain.de/imagemagick/ImageMagick-7.0.7-28.tar.gz
tar xf ImageMagick-7.0.7-28.tar.gz
cd ImageMagick-7.0.7-28
./configure --prefix=/Data/apps/ImageMagick
make && make install

编译imagick
wget http://pecl.php.net/get/imagick-3.4.3.tgz
tar xf imagick-3.4.3.tgz
cd imagick-3.4.3
/Data/apps/php/bin/phpize
./configure --with-imagick=/Data/apps/ImageMagick --with-php-config=/Data/apps/php/bin/php-config
make && make install

redis

下载地址: https://github.com/phpredis/phpredis (develop版本)

安装redis目录: /Data/app/redis

编译redis扩展
wget https://pecl.php.net/get/redis-3.0.0.tgz
cd redis-3.0.0
/Data/apps/php/bin/phpize
./configure --enable-redis-igbinary=/Data/apps/redis/bin/ --with-php-config=/Data/apps/php/bin/php-config
make && make install

gearman

安装gearmand服务端 https://launchpad.net/gearmand 版本:1.1.12

编译gearman客服端扩展
git下载最新:https://github.com/wcgallego/pecl-gearman/tree/master
cd pecl-gearman-master
/Data/apps/php/bin/phpize
./configure  --with-php-config=/Data/apps/php/bin/php-config
make && make install

scws

下载链接:http://www.xunsearch.com/scws/download.php

wget http://www.xunsearch.com/scws/down/scws-1.2.3.tar.bz2
cd scws-1.2.3/phpext
/Data/apps/php/bin/phpize
./configure --with-scws=/Data/apps/scws --with-php-config=/Data/apps/php/bin/php-config

amqp

下载地址: http://pecl.php.net/package/amqp

安装rabbitmq-c依赖库
wget https://github.com/alanxz/rabbitmq-c/releases/download/v0.8.0/rabbitmq-c-0.8.0.tar.gz
cd rabbitmq-c-0.8.0
./configure --prefix=/usr/local/rabbitmq-c-0.8.0
make && make install

编译amqp扩展
wget https://pecl.php.net/get/amqp-1.9.3.tgz
tar -xf amqp-1.9.3.tar
cd amqp-1.9.3
/Data/apps/php/bin/phpize
./configure --with-php-config=/Data/apps/php/bin/php-config --with-amqp --with-librabbitmq-dir=/usr/local/rabbitmq-c-0.8.0
make && make install

fastdfs client

wget https://github.com/happyfish100/fastdfs/archive/master.zip
unzip master.zip
cd fastdfs-master/php_client
/Data/apps/php/bin/phpize
./configure --with-php-config=/Data/apps/php/bin/php-config
make && make install

libiconv

安装libiconv
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar xf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure
make
make install
安装libdatrie
解压,进入目录
./configure LDFLAGS=-L/usr/local/lib LIBS=-liconv --host=arm
make
make install
安装trie_filter.so 拓展
git clonde https://github.com/zzjin/php-ext-trie-filter
cd  php-ext-trie-filter
/Data/apps/php/bin/phpize
./configure  --with-php-config=/Data/apps/php/bin/php-config  --with-trie_filter=/usr/local/libdatrie
make && make install

php.ini 配置

cd /opt/soft/php-7.0.28
cp php.ini-production /Data/apps/php/lib/php.ini
加载的模块配置
[opcache]
zend_extension="/Data/apps/php/lib/php/extensions/no-debug-non-zts-20151012/opcache.so"
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.fast_shutdown=1
opcache.enable_cli=1
opcache.validate_timestamps=1
opcache.revalidate_freq=1
opcache.error_log="/Data/apps/php/var/log/opcache.log"
[memcached]
extension=memcached.so
memcache.hash_strategy=consistent
memcache.hash_function=crc32
session.save_handler = memcached
extension=igbinary.so
extension=imagick.so
extension=redis.so
extension=gearman.so
extension=trie_filter.so
[scws]
extension=scws.so
scws.default.charset = utf8
scws.default.fpath = /Data/apps/scws/etc
[amqp]
extension=amqp.so
[fastdfs]
extension = fastdfs_client.so
fastdfs_client.base_path = /tmp
fastdfs_client.connect_timeout = 2
fastdfs_client.network_timeout = 60
fastdfs_client.log_level = info
fastdfs_client.http.anti_steal_secret_key =
fastdfs_client.tracker_group_count = 1
fastdfs_client.tracker_group0 = /etc/fdfs/client.conf
fastdfs_client.use_connection_pool = false
fastdfs_client.connection_pool_max_idle_time = 3600

php-fpm.conf

cp /Data/apps/php/etc/php-fpm.conf.default /Data/apps/php/etc/php-fpm

php-fpm 启动脚本

cd /opt/soft/php-7.0.28/sapi/fpm
cp init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm

启动php

/etc/init.d/php-fpm start
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 220,063评论 6 510
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,805评论 3 396
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 166,403评论 0 357
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 59,110评论 1 295
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 68,130评论 6 395
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,877评论 1 308
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,533评论 3 420
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,429评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,947评论 1 319
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 38,078评论 3 340
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,204评论 1 352
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,894评论 5 347
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,546评论 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 32,086评论 0 23
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,195评论 1 272
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,519评论 3 375
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 45,198评论 2 357

推荐阅读更多精彩内容

  • 更改ip和dnsVi /etc/sysconfig/network-scripts/ifcfg-eth0vi /...
    Xwei_阅读 1,824评论 0 3
  • 啊 公司要开始新项目 移动的app 名字叫安好 运维太坑爹了 给了个破配置 Xeon(TM) CPU 3.40...
    xiasix阅读 1,482评论 0 2
  • (centos7+nginx1.9+mysql5.6+php7) 1.准备工作: 1)把所有的软件安装在/data...
    Tshare_XUN阅读 596评论 0 0
  • 首先最好一直在root用户下进行安装。 一、安装mysql 1.安装编译环境 yum -y inst...
    Lin_小旻阅读 797评论 0 7
  • 如果可以时光倒回,最想做的事是什么呢? 如果可以重来一次,最想珍惜的是什么呢? 如果可以重拾爱情,最想跟他(她)怎...
    Flower_Yanny阅读 391评论 0 0