1.环境要求
- 前提是已经部署好了lnmp与lamp,大部分操作是相同的,这里只以lnmp为例。
2.设置语言
[root@lnmp ~]
[root@lnmp ~]
export LC_ALL=C
[root@lnmp ~]
3.下载安装包,解压
百度网盘安装包下载:链接
[root@lamp ~]# ll nginx-php-ext-soft.zip
-rw-r--r--. 1 root root 11425505 Aug 7 2018 nginx-php-ext-soft.zip
[root@lamp ~]# unzip nginx-php-ext-soft.zip
[root@lamp ~]# ll nginx-php-ext-soft
total 11212
-rw-r--r--. 1 root root 11130738 Oct 22 2013 ImageMagick.tar.gz
-rw-r--r--. 1 root root 14778 Oct 22 2013 PDO_MYSQL-1.0.2.tgz
-rw-r--r--. 1 root root 105833 Oct 22 2013 eaccelerator-0.9.6.tar.bz2
-rw-r--r--. 1 root root 86976 Oct 22 2013 imagick-2.3.0.tgz
-rw-r--r--. 1 root root 35981 Oct 22 2013 memcache-2.2.5.tgz
-rw-r--r--. 1 root root 95322 Jan 19 2012 xcache-1.3.2.tar.bz2
[root@lnmp ~]# cd nginx-php-ext-soft
[root@lnmp nginx-php-ext-soft]# ls
ImageMagick.tar.gz eaccelerator-0.9.6.tar.bz2 memcache-2.2.5.tgz
PDO_MYSQL-1.0.2.tgz imagick-2.3.0.tgz xcache-1.3.2.tar.bz2
4.安装eaccelerator缓存模块
[root@lnmp nginx-php-ext-soft]
[root@lnmp nginx-php-ext-soft]
[root@lnmp eaccelerator-0.9.6]
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
[root@lnmp eaccelerator-0.9.6]
[root@lnmp eaccelerator-0.9.6]
[root@lnmp eaccelerator-0.9.6]
eaccelerator.so <<====最后生成这个模块
[root@lnmp eaccelerator-0.9.6]
5.安装xcache缓存模块
[root@lnmp nginx-php-ext-soft]# ls
ImageMagick.tar.gz eaccelerator-0.9.6.tar.bz2 xcache-1.3.2.tar.bz2
PDO_MYSQL-1.0.2.tgz imagick-2.3.0.tgz
eaccelerator-0.9.6 memcache-2.2.5.tgz
[root@lnmp nginx-php-ext-soft]#tar jxf xcache-1.3.2.tar.bz2
[root@lnmp nginx-php-ext-soft]#cd xcache-1.3.2
[root@lnmp xcache-1.3.2]# /application/php/bin/phpize
[root@lnmp xcache-1.3.2]# ./configure --enable-xcache --with-php-config=/application/php/bin/php-config
[root@lnmp xcache-1.3.2]#make && make install
6.安装memcache客户端扩展模块
[root@lnmp nginx-php-ext-soft]
[root@lnmp nginx-php-ext-soft]
[root@lnmp memcache-2.2.5]
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
[root@lnmp memcache-2.2.5]
[root@lnmp memcache-2.2.5]
7.安装PDO_MYSQL扩展模块
[root@lnmp nginx-php-ext-soft]
[root@lnmp nginx-php-ext-soft]
[root@lnmp PDO_MYSQL-1.0.2]
[root@lnmp PDO_MYSQL-1.0.2]
[root@lnmp PDO_MYSQL-1.0.2]
8.安装图像处理程序及imagick扩展模块
[root@lnmp nginx-php-ext-soft]
[root@lnmp nginx-php-ext-soft]
[root@lnmp ImageMagick-6.5.1-2]
[root@lnmp ImageMagick-6.5.1-2]
[root@lnmp ImageMagick-6.5.1-2]
9.安装imagick模块
[root@lnmp nginx-php-ext-soft]
[root@lnmp nginx-php-ext-soft]
[root@lnmp imagick-2.3.0]
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
[root@lnmp imagick-2.3.0]
[root@lnmp imagick-2.3.0]
10.检查安装结果
[root@lnmp imagick-2.3.0]# ls /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
eaccelerator.so imagick.so memcache.so pdo_mysql.so xcache.so
[root@lamp imagick-2.3.0]# ls /usr/local/php5.3.27/lib/php/extensions/no-debug-zts-20090626/
eaccelerator.so imagick.so memcache.so pdo_mysql.so xcache.so
11.模块配置测试
[root@lnmp imagick-2.3.0]# cd /application/php/lib/
[root@lnmp lib]# cp php.ini php.ini.backup
编辑配置文件
[root@lamp lib]# vim php.ini
819 extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"
820 extension = memcache.so
821 extension = imagick.so
822 extensio = pdo_mysql.so
创建缓存目录
[root@lnmp ~]# mkdir /tmp/eaccelerator
[root@lnmp ~]# chown -R nginx:nginx /tmp/eaccelerator/
插入模块
cat >> /application/php/lib/php.ini<<EOF
[eaccelerator]
extension=eaccelerator.so
eaccelerator.shm_size="64"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
EOF
查看信息
[root@lnmp ~]# php-fpm -v
PHP 5.3.27 (fpm-fcgi) (built: Aug 6 2018 11:16:44)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
with eAccelerator v0.9.6, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
[root@lnmp ~]# ls /tmp/eaccelerator/
0 1 2 3 4 5 6 7 8 9 a b c d e f
重启nginx与php
[root@lnmp ~]# nginx -s restart
[root@lnmp ~]# kill -USR2 `cat /app/logs/php-fpm.pid`
测试
[root@lamp ~]# for num in `seq 100`;do curl 10.0.0.130 >/dev/null 2>&1;done
[root@lnmp ~]# du -h `find /tmp/eaccelerator/ -type f`
4.0K /tmp/eaccelerator/8/6/eaccelerator-86746.901672
12.配置xcache
需要将eacc的配置删除,不然会冲突。
[root@lnmp ~]
3 ;zend_extension = /usr/local/lib/php/extensions/non-debug-non-zts-xxx/xcache.so
6 ;zend_extension_ts = c:/php/extensions/php_xcache.dll
8 extension = xcache.so
[root@lnmp ~]
[root@lnmp ~]
PHP 5.3.27 (fpm-fcgi) (built: Aug 6 2018 11:16:44)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
with XCache v1.3.2, Copyright (c) 2005-2011, by mOo