php缓存加速插件安装记录

系统环境:Cento_X64_6.0   Apache2.2.22  php5.3.13 Mysql5.1.62
安装前的准备:echo 'export  LC_ALL=C' >> /etc/profile;source /etc/profile 使其立即生效 
(此操作可以对PHP版本为5.3以上的解决perl,程序插件的编码问题)
~~~~~~~~~~~~~~~~~~~~~~~~安装eaccelerator缓存加速~~~~~~~~~~~~~~~~~~~~~~~~
[root@lamp113 ~]# wget http://fastlnmp.googlecode.com/files/eaccelerator-0.9.6.tar.bz2
--2012-12-28 11:20:18--    http://fastlnmp.googlecode.com/files/eaccelerator-0.9.6.tar.bz2
Resolving fastlnmp.googlecode.com... 74.125.128.82, 2404:6800:4005:c00::52
Connecting to fastlnmp.googlecode.com|74.125.128.82|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 105833 (103K) [application/x-bzip2]
Saving to: `eaccelerator-0.9.6.tar.bz2'

100%[==============================================>] 105,833         --.-K/s     in 0.08s        

2012-12-28 11:20:18 (1.27 MB/s) - `eaccelerator-0.9.6.tar.bz2' saved [105833/105833]

[root@lamp113 ~]# tar jxf eaccelerator-0.9.6.tar.bz2    
[root@lamp113 ~]# cd eaccelerator-0.9.6
[root@lamp113 eaccelerator-0.9.6]# /usr/local/php/bin/phpize -v
Configuring for:
PHP Api Version:                 20090626
Zend Module Api No:            20090626
Zend Extension Api No:     220090626
[root@lamp113 eaccelerator-0.9.6]# ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
过程省略.........
creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
config.status: config.h is unchanged
[root@lamp113 eaccelerator-0.9.6]# make && make install
Installing shared extensions:         /usr/local/php/lib/php/extensions/no-debug-zts-20090626/    
[root@lamp113 eaccelerator-0.9.6]# ll /usr/local/php/lib/php/extensions/no-debug-zts-20090626/
total 388
-rwxr-xr-x. 1 root root 395853 Dec 28 11:35 eaccelerator.so 出现此模块表示安装成功
[root@lamp113 eaccelerator-0.9.6]#    
~~~~~~~~~~~~~~配置php加载eaccelerator~~~~~~~~~~~~~~~~
[root@lamp113 ~]# vim /usr/local/php/lib/php.ini +891    
#把找到extension_dir = 字段 把后面的路径修改成 你安装的缓存模块的绝对路径
#extension_dir = extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20090626"
#在最底部追加
;;;;;;;;;;;;;;;eaccelerator;;;;;;;;;;;;;;
[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
eaccekerator.shm_ttl=3600
eaccelerator.shm_prune_period=3600
eaccelerator.shm_only=0
eaccelerator.compress=1
eaccelerator.compress_level=9

[root@lamp113 ~]# mkdir -p /tmp/eaccelerator;chown apache:apache /tmp/eaccelerator #创建缓存目录并把它的属主和用户组改为apache使用的用户和组
[root@lamp113 ~]# /usr/local/php/bin/php -v
PHP 5.3.13 (cli) (built: Nov 18 2012 13:42:57)    
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
        with eAccelerator v0.9.6, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
#出现上面的with eAccelerator 字段 就表示安装加载成功
#成功后缓存目录/tem/eaccelerator里面会出现0.1.2....a.b.c等目录
[root@lamp113 ~]# ll /tmp/eaccelerator/
total 64
drwxrwxrwx. 18 root root 4096 Dec 28 11:47 0
drwxrwxrwx. 18 root root 4096 Dec 28 11:47 1
drwxrwxrwx. 18 root root 4096 Dec 28 11:47 2
drwxrwxrwx. 18 root root 4096 Dec 28 11:47 3
drwxrwxrwx. 18 root root 4096 Dec 28 11:47 4
drwxrwxrwx. 18 root root 4096 Dec 28 11:47 5
drwxrwxrwx. 18 root root 4096 Dec 28 11:47 6
drwxrwxrwx. 18 root root 4096 Dec 28 11:47 7
drwxrwxrwx. 18 root root 4096 Dec 28 11:47 8
drwxrwxrwx. 18 root root 4096 Dec 28 11:47 9
drwxrwxrwx. 18 root root 4096 Dec 28 11:47 a
drwxrwxrwx. 18 root root 4096 Dec 28 11:47 b
drwxrwxrwx. 18 root root 4096 Dec 28 11:47 c
drwxrwxrwx. 18 root root 4096 Dec 28 11:47 d
drwxrwxrwx. 18 root root 4096 Dec 28 11:47 e
drwxrwxrwx. 18 root root 4096 Dec 28 11:47 f

#自己在web目录下添加一个index.php,里面是phpinfo()函数,访问一下,发现打不开了!
#查看日志文件发现如下错误提示:
[root@lamp113 ~]# cat /usr/local/apache/logs/error_log
~~~~~~~~~~~省略大部分日志
[Sun Nov 18 18:09:10 2012] [error] [client 192.168.137.1] PHP Warning:    phpinfo(): It is not safe to rely on the system's timezone settings.    
You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you    
are still getting this warning, you most likely misspelled the timezone identifier.    
#解决方法:
#php.ini中设置的eAccelerator,eaccelerator.shm_size="64",解释:eaccelerator可使用的共享内存大小(单位为MB),即64M
#在Linux下,单个进程的最大内存使用量受/proc/sys/kernel/shmmax中设置的数字限制(单位为字节)    /proc/sys/kernel/shmmax = 33554432 (32M)
#vim /etc/sysctl.conf
#kernel.shmmax = 250000000    #没有这参数的自己添加,这个值是我乱写的,具体请根据自己的生产环境而定!
#sysctl -p
[root@lamp113 ~]# /usr/local/apache/bin/apachectl graceful
#再访问一次能打开和显示phpinfo了
[root@lamp113 ~]# tree /tmp/eaccelerator/
/tmp/eaccelerator/
#省略大部分...
|-- 5
|     |-- 0
|     |-- 1
|     |-- 2
|     |-- 3
|     |-- 4
|     |-- 5
|     |-- 6
|     |-- 7
|     |-- 8
|     |-- 9
|     |-- a
|     |     `-- eaccelerator-86746.053614
|     |-- b
|     |-- c
|     |-- d
|     |-- e
|     `-- f
#省略大部分...    出现这个表示成功了加载进缓存了
#php5.3.10和5.3.13可用这插件的0.9.6版本,如果使用0.9.5.2版本在make阶段会报错(php5.2可以用)


~~~~~~~~~~~~~~~~~~~~~~~~memcache缓存扩展~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[root@lamp113 ~]# wget http://fastlnmp.googlecode.com/files/memcache-2.2.5.tgz    
--2012-12-28 12:18:55--    http://fastlnmp.googlecode.com/files/memcache-2.2.5.tgz
Resolving fastlnmp.googlecode.com... 74.125.128.82, 2404:6800:4005:c00::52
Connecting to fastlnmp.googlecode.com|74.125.128.82|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 35981 (35K) [application/x-gzip]
Saving to: `memcache-2.2.5.tgz'

100%[======================================>] 35,981             114K/s     in 0.3s        

2012-12-28 12:18:56 (114 KB/s) - `memcache-2.2.5.tgz' saved [35981/35981]
[root@lamp113 ~]# tar zxf memcache-2.2.5.tgz
[root@lamp113 ~]# cd memcache-2.2.5/
[root@lamp113 memcache-2.2.5]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version:                 20090626
Zend Module Api No:            20090626
Zend Extension Api No:     220090626
[root@lamp113 memcache-2.2.5]# ./configure --with-php-config=/usr/local/php/bin/php-config    
#省略编译过程
[root@lamp113 memcache-2.2.5]# make && make install

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:         /usr/local/php/lib/php/extensions/no-debug-zts-20090626/
[root@lamp113 memcache-2.2.5]# ll /usr/local/php/lib/php/extensions/no-debug-zts-20090626/
total 624
-rwxr-xr-x. 1 root root 395853 Dec 28 11:35 eaccelerator.so
-rwxr-xr-x. 1 root root 237602 Dec 28 12:32 memcache.so #出现此模块表示安装成功
[root@lamp113 memcache-2.2.5]#    
#在php.ini配置文件的eaccelerator配置段上面添加一行
#extension = memcache.so
~~~~~~~~~~~~~~~~~~~~PDO_MYSQL扩展模块~~~~~~~~~~~~~~~~~~~~
    
[root@lamp113 ~]# wget http://fastlnmp.googlecode.com/files/PDO_MYSQL-1.0.2.tgz    
--2012-12-28 12:36:23--    http://fastlnmp.googlecode.com/files/PDO_MYSQL-1.0.2.tgz
Resolving fastlnmp.googlecode.com... 74.125.128.82, 2404:6800:4005:c00::52
Connecting to fastlnmp.googlecode.com|74.125.128.82|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14778 (14K) [application/x-gzip]
Saving to: `PDO_MYSQL-1.0.2.tgz'

100%[============================================================================================================================================>] 14,778            --.-K/s     in 0.02s        

2012-12-28 12:36:23 (596 KB/s) - `PDO_MYSQL-1.0.2.tgz' saved [14778/14778]

[root@lamp113 ~]# tar zxf PDO_MYSQL-1.0.2.tgz
[root@lamp113 ~]# cd PDO_MYSQL-1.0.2
[root@lamp113 PDO_MYSQL-1.0.2]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version:                 20090626
Zend Module Api No:            20090626
Zend Extension Api No:     220090626
[root@lamp113 PDO_MYSQL-1.0.2]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
[root@lamp113 PDO_MYSQL-1.0.2]# make && make install
#编译过程省略..............
Build complete.
Don't forget to run 'make test'.

Installing shared extensions:         /usr/local/php/lib/php/extensions/no-debug-zts-20090626/
[root@lamp113 PDO_MYSQL-1.0.2]# ll /usr/local/php/lib/php    
php/         php.ini    
[root@lamp113 PDO_MYSQL-1.0.2]# ll /usr/local/php/lib/php/extensions/no-debug-zts-20090626/
total 776
-rwxr-xr-x. 1 root root 395853 Dec 28 11:35 eaccelerator.so
-rwxr-xr-x. 1 root root 237602 Dec 28 12:32 memcache.so
-rwxr-xr-x. 1 root root 153692 Dec 28 12:40 pdo_mysql.so #出现此模块表示安装成功
[root@lamp113 PDO_MYSQL-1.0.2]#    
#在php.ini配置文件的eaccelerator配置段上面添加一行
#extension = pdo_mysql.so
~~~~~~~~~~~~~ImageMagick图像处理程序和imagick扩展插件~~~~~~~~~~~
[root@lamp113 ~]# wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
--2012-12-28 13:07:51--    ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
                     => `ImageMagick.tar.gz'
Resolving ftp.imagemagick.org... 209.191.186.187
Connecting to ftp.imagemagick.org|209.191.186.187|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.        ==> PWD ... done.
==> TYPE I ... done.    ==> CWD (1) /pub/ImageMagick ... done.
==> SIZE ImageMagick.tar.gz ... 13859332
==> PASV ... done.        ==> RETR ImageMagick.tar.gz ... done.
Length: 13859332 (13M) (unauthoritative)

100%[============================================================================================================================================>] 13,859,332     907K/s     in 18s            

2012-12-28 13:08:12 (766 KB/s) - `ImageMagick.tar.gz' saved [13859332]

[root@lamp113 ~]# tar zxf ImageMagick.tar.gz    
[root@lamp113 ~]# cd ImageMagick
-bash: cd: ImageMagick: No such file or directory
[root@lamp113 ~]# cd ImageMagick
ImageMagick-6.8.1-4/ ImageMagick.tar.gz        
[root@lamp113 ~]# cd ImageMagick-6.5.1-2/
[root@lamp113 ImageMagick-6.5.1-2]# ls
AUTHORS.txt                    Install-unix.txt         Magick++             NEWS.txt             QuickStart.txt    common.shi.in    filters         magick                tests             winpath.sh
ChangeLog                        Install-vms.txt            Magickshr.opt    NOTICE                 README.txt            config                 images            magick.sh.in    utilities     www
ImageMagick.spec.in    Install-windows.txt    Makefile.am        PerlMagick         aclocal.m4            configure            index.html    scenes                version.sh
Install-mac.txt            LICENSE                            Makefile.in        Platforms.txt    coders                    configure.ac     m4                    scripts             wand
[root@lamp113 ImageMagick-6.5.1-2]# ./configure
#过程省略
[root@lamp113 ImageMagick-6.5.1-2]# make
#我第一次编译的时候碰到了一次错误,
#错误的大概内容是关于perl 和perl5 的 那次我解决的办法是yum install perl-devel -y
#希望对新手有帮助
[root@lamp113 ImageMagick-6.5.1-2]# make install    
#这个装完就不用管了 我装ImageMagick6.8版本的 后面的imagick-2.3.0就完全编译不过去,试了好久都没解决
#google和baidu 都翻到10几页 ,没一个正确的 没办法只好装ImageMagick-6.5版本的
[root@lamp113 ~]# wget http://unmp.googlecode.com/files/imagick-2.3.0.tgz
--2012-12-28 13:24:21--    http://unmp.googlecode.com/files/imagick-2.3.0.tgz
Resolving unmp.googlecode.com... 74.125.128.82, 2404:6800:4008:c00::52
Connecting to unmp.googlecode.com|74.125.128.82|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 86976 (85K) [application/x-gzip]
Saving to: `imagick-2.3.0.tgz'

100%[============================================================================================================================================>] 86,976             166K/s     in 0.5s    
[root@lamp113 ~]# tar zxf imagick-2.3.0.tgz
[root@lamp113 ~]# cd imagick-2.3.0
[root@lamp113 imagick-2.3.0]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version:                 20090626
Zend Module Api No:            20090626
Zend Extension Api No:     220090626
[root@lamp113 imagick-2.3.0]# ./configure --with-php-config=/usr/local/php/bin/php-config
[root@lamp112 imagick-2.3.0]# make && make install
#编译过程省略
Installing shared extensions:         /usr/local/php/lib/php/extensions/no-debug-zts-20090626/
[root@lamp112 imagick-2.3.0]# ll /usr/local/php/lib/php/extensions/no-debug-zts-20090626/
total 2288
-rwxr-xr-x. 1 root root    395853 Dec 11 17:27 eaccelerator.so
-rwxr-xr-x. 1 root root 1122253 Dec 29 21:56 imagick.so #出现这个模块表示安装成功
-rwxr-xr-x. 1 root root    237602 Dec 11 17:41 memcache.so
-rwxr-xr-x. 1 root root    153692 Dec 11 17:57 pdo_mysql.so
-rwxr-xr-x. 1 root root    423635 Dec 11 20:29 xcache.so
[root@lamp112 imagick-2.3.0]#    
#在php.ini配置文件的eaccelerator配置段上面添加一行
#extension = imagick.so
~~~~~~~~~~~~~~~~~~安装Xcache缓存加速~~~~~~~~~~~~~~~~~~~~
[root@lamp113 ~]# wget http://xcache.lighttpd.net/pub/Releases/1.3.2/xcache-1.3.2.tar.gz
--2012-12-28 16:42:07--    http://xcache.lighttpd.net/pub/Releases/1.3.2/xcache-1.3.2.tar.gz
Resolving xcache.lighttpd.net... 188.40.103.19, 2a01:4f8:100:8082::2
Connecting to xcache.lighttpd.net|188.40.103.19|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 113715 (111K) [application/octet-stream]
Saving to: `xcache-1.3.2.tar.gz'

100%[===================================================================================================================================================>] 113,715         72.3K/s     in 1.5s        

2012-12-28 16:42:09 (72.3 KB/s) - `xcache-1.3.2.tar.gz' saved [113715/113715]

[root@lamp113 ~]# tar zxf xcache-1.3.2.tar.gz    
[root@lamp113 ~]# cd xcache-1.3.2
[root@lamp113 xcache-1.3.2]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version:                 20090626
Zend Module Api No:            20090626
Zend Extension Api No:     220090626
[root@lamp113 xcache-1.3.2]# ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config
#过程省略
[root@lamp113 xcache-1.3.2]# make && make install
Installing shared extensions:         /usr/local/php/lib/php/extensions/no-debug-zts-20090626/
[root@lamp113 xcache-1.3.2]# ll /usr/local/php/lib/php/extensions/no-debug-zts-20090626/
total 2288
-rwxr-xr-x. 1 root root    395853 Dec 28 11:35 eaccelerator.so
-rwxr-xr-x. 1 root root 1122253 Dec 28 15:25 imagick.so
-rwxr-xr-x. 1 root root    237602 Dec 28 12:32 memcache.so
-rwxr-xr-x. 1 root root    153692 Dec 28 12:40 pdo_mysql.so
-rwxr-xr-x. 1 root root    423635 Dec 28 16:45 xcache.so #有此模块表示编译成功了
[root@lamp113 xcache-1.3.2]# cat xcache.ini >> /usr/local/php/lib/php.ini    
[root@lamp113 xcache-1.3.2]# vim /usr/local/php/lib/php.ini
#到php.ini最底下的Xcache配置段找出zend_extension_ts和zend_extension 把这2行注释
#把配置段的extension = xcache.so前面的注释取消
#Xcache的配置内容也是根据自己的环境去定的,我就不写了
[root@lamp113 xcache-1.3.2]# /usr/local/php/bin/php -v
PHP Warning:    Cannot load module 'XCache' because conflicting module 'eAccelerator' is already loaded in Unknown on line 0
PHP 5.3.13 (cli) (built: Nov 18 2012 13:42:57)    
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
        with eAccelerator v0.9.6, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
#上面提示Xcache和eaccelerator不能一起共用,解决的方法就是把eaccelerator配置段放在Xcache配置段的下边
[root@lamp113 xcache-1.3.2]# /usr/local/php/bin/php -v
PHP 5.3.13 (cli) (built: Nov 18 2012 13:42:57)    
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
        with eAccelerator v0.9.6, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
        with XCache v1.3.2, Copyright (c) 2005-2011, by mOo    #加载成功
Segmentation fault
内容来自参加老男孩linux运维培训,学习整理部分内容
 

你可能感兴趣的:(PHP,缓存插件)