歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> 學習Linux >> CentOS7下為php7安裝擴展

CentOS7下為php7安裝擴展

日期:2017/3/3 17:46:13   编辑:學習Linux

CentOS7下為php7安裝擴展

CentOS7下為php7安裝擴展


環境說明:

系統環境:
系統:CentOS Linux release 7.2.1511 (Core)
GCC版本:gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)
LNMP環境:
Nginx版本:1.10.2
PHP版本:PHP 7.1.0 (cli)
MySQL版本:5.7.16
php7安裝路徑:/usr/local/php7/
安裝擴展之前先用pear設置php.ini的路徑:

/usr/local/php7/bin/pear config-set php_ini /usr/local/php7/etc/php.ini

這樣做的好處就是用pecl安裝php擴展的時候,會自動在php.ini中引用擴展包,不用自己手動添加擴展包。

1、安裝yaf擴展:

/usr/local/php7/bin/pecl install channel://pecl.php.net/yaf-3.0.4

安裝完成之後會自動把yaf.so加入到php.ini中,不用自己手動添加擴展

2、安裝yaconf擴展:

/usr/local/php7/bin/pecl install channel://pecl.php.net/yaconf-1.0.4

3、安裝swoole擴展:

/usr/local/php7/bin/pecl install channel://pecl.php.net/swoole-1.9.1

4、安裝redis擴展:

1、安裝Redis服務:

安裝教程詳見:CentOS7安裝Redis

2、安裝擴展:
/usr/local/php7/bin/pecl install channel://pecl.php.net/redis-3.0.0

5、安裝SeasLog擴展:

/usr/local/php7/bin/pecl install channel://pecl.php.net/SeasLog-1.6.8

6、安裝memcache擴展:

1、首先安裝memcache服務端memcached:
yum -y install libevent-develcd ~ && wget http://memcached.org/latest -O memcached-1.4.33.tar.gztar -zxvf memcached-1.4.33.tar.gzcd memcached-1.4.33./configure && make && make install

詳細安裝說明請見:Memcached官方說明,安裝完成開始啟動memcached:

memcached -d -l 127.0.0.1 -p 11211 -m 150 -u root  -c 512 -P /var/run/memcached.pid

啟動參數說明:

    -d選項是啟動一個守護進程,    -l是監聽的服務器IP地址,如果有多個地址的話,我這裡指定了本機地址127.0.0.1    -p是設置Memcache監聽的端口,我這裡設置了默認的11211,最好是1024以上的端口,    -m是分配給Memcache使用的內存數量,單位是MB,我這裡是10MB,    -u是運行Memcache的用戶,我這裡是root,    -c選項是最大運行的並發連接數,默認是1024,我這裡設置了512,按照你服務器的負載量來設定,    -P是設置保存Memcached的pid文件,我這裡是保存在/var/run/memcached.pid

啟動完成查看啟動結果:

ps -ef | grep memcached

設置memcache開機啟動:

echo -e 'memcached -d -l 127.0.0.1 -p 11211 -m 150 -u root  -c 512 -P /var/run/memcached.pid\n' >> /etc/rc.local
2、安裝memcache擴展:
  • Ⅰ、ⅣⅤ安裝依賴庫libmemcached:
cd ~ && wget https://launchpadlibrarian.net/165454254/libmemcached-1.0.18.tar.gztar -zxvf libmemcached-1.0.18.tar.gzcd libmemcached-1.0.18/./configuremake && make install
  • Ⅱ、安裝擴展:
cd ~ && git clone https://github.com/php-memcached-dev/php-memcached.gitcd php-memcached/git checkout php7phpize./configure --disable-memcached-saslmake && make install && make test
  • Ⅲ、配置擴展: 在/etc/php.ini中加入以下內容:
extension="memcached.so"

重啟php:

kill -USR2 `cat /usr/local/php7/var/run/php-fpm.pid`

重啟之後查看php是否已經正常加載:

php -m|grep memcached

如果輸出:memcached則說明配置成功

http://xxxxxx/Linuxjc/1184759.html TechArticle

Copyright © Linux教程網 All Rights Reserved