php5.5和php5.4安装xcache的加速插件

cd /opt;wget http://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz 
或者:
cd /opt/wget https://gitee.com/zzhlinux911218/dgg_cluster_shell/raw/master/xcache-3.2.0.tar.gz

tar -xf xcache-3.2.0.tar.gz 
cd xcache-3.2.0


[[email protected]]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version:         20121113
Zend Module Api No:      20121212
Zend Extension Api No:   220121212



[[email protected]]# ./configure --enable-xcache --enable-xcache-coverager --enable-xcache-optimizer --with-php-config=/usr/local/php/bin/php-config 
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
………………
………………
creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h


[[email protected]]# make && make install
…………
………………
----------------------------------------------------------------------
Libraries have been installed in:
   /zhh/xcache-3.2.0/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

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

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/  --#xcache模块路径,记住他



创建xcache缓存文件
touch /tmp/xcache 
chmod 777 /tmp/xcache 

3、创建xcache管理员密码为123456
[root@localhost xcache-3.2.0]# echo -n "123456" | md5sum  
e10adc3949ba59abbe56e057f20f883e  -         #记住类似下面一行代码(md5加密之后的密码),后面会用到


4、拷贝xcache后台管理程序到网站根目录
cp -r /opt/xcache-3.2.0/htdocs   /home/wwwroot/xcache
chown www.www -R /home/wwwroot/xcache 

mkdir -p /usr/local/nginx/conf/vhost/xcache

vim /usr/local/nginx/conf/vhost/xcache/web.conf
server
    {
        listen 80;
        index index.html index.htm index.php;
        root  /home/wwwroot/xcache;
        include enable-php.conf;
}




vim /usr/local/php/etc/php.ini(在最后面增加以下内容)


[xcache-common]
extension = xcache.so
[xcache.admin]
xcache.admin.enable_auth = On  --登录管理界面的用户名和密码,留空则禁用管理界面
xcache.admin.user = "admin"   --插件web页面的登录用户名
xcache.admin.pass = "e10adc3949ba59abbe56e057f20f883e"   --刚刚md5sum生成的加密(插件web页面的登录用户的密码 123456)
[xcache]
xcache.shm_scheme ="mmap"    --决定 XCache 如何从系统分配共享内存
xcache.size=64M              --所用共享缓存的大小。如果为0,缓存将无法使用
xcache.count =1              --指定将 cache 切分成多少块, 建议设置为 cpu 数
xcache.slots =8K             --只是作为 hash 槽个数的参考值, 您可以放心地缓存超过这个个数的项目
xcache.ttl=3600              --Opcode文件的生存时间。如果将此值设置为0,则将无限期缓存
xcache.gc_interval =300      --触发垃圾回收的时间间隔。默认设置为0 (秒)
xcache.var_size=64M          --只是针对变量缓存设置
xcache.var_count =1          --只是针对变量缓存设置
xcache.var_slots =8K         --只是针对变量缓存设置
xcache.var_ttl=0             --只是针对变量缓存设置
xcache.var_maxttl=0          --只是针对变量缓存设置
xcache.var_gc_interval =300  --只是针对变量缓存设置
xcache.test =Off             --禁用测试功能,如果启用将会略微降低性能, 但是会提高一定的安全系数
xcache.readonly_protection = On  --如果启用了 ReadonlyProtection, 将会略微降低性能, 但是会提高一定的安全系数
xcache.mmap_path ="/tmp/xcache" --用于只读保护的文件路径,这将限制两个 php 进程组共享同一个 /tmp/xcache 目录, 指定为 /dev/zero 时无效
xcache.coredump_directory =""   --在遇到故障时,放置核心转储的目录。必须是PHP可写入的目录。保留为空代表禁用
xcache.cacher =On               --使用opcode 缓存. xcache.size = 0 时无效
xcache.stat=On                  --使用 stat() 发现检查脚本更新
xcache.optimizer =Off           --禁用优化。默认状态为禁用
[xcache.coverager]
xcache.coverager =On            --启用代码覆盖信息采集器,启用后 xcache.coveragedump_directory 设置以及 xcache_coverager_start/stop/get/clean() 系列函数才可以使用(启用后会对降低影响)
xcache.coveragedump_directory =""  --放置数据采集信息的目录位置。默认使用目录 /tmp/pcovis



/etc/init.d/php-fpm restart #重启php-fpm
/etc/init.d/nginx reload #重启nginx
浏览器输入ip,输入用户名xcache 密码123456


实列:




cd /opt;wget http://xcache.lighttpd.net/pub/Releases/3.2.0/xcache-3.2.0.tar.gz
tar -xf xcache-3.2.0.tar.gz
cd xcache-3.2.0
yum install autoconf -y
/usr/local/php/bin/phpize
./configure --enable-xcache --enable-xcache-coverager --enable-xcache-optimizer --with-php-config=/usr/local/php/bin/php-config
make && make install
mkdir /home/xcache
touch /home/xcache/xcache
chmod 777 /home/xcache/xcache

echo -n "dgg123456" | md5sum
b152e1c07803be8f712d5da6fed0f7cf


cp -r /opt/xcache-3.2.0/htdocs   /home/xcache
mkdir -p /usr/local/nginx/conf/vhost/xcache
vim /usr/local/nginx/conf/vhost/xcache/web.conf

server
    {
        listen 3000;
        index index.html index.htm index.php;
        root  /home/xcache/htdocs;

        access_log  /home/log/nginx/xcache/web.access.log main;
        error_log  /home/log/nginx/xcache/web.error.log;

        include enable-php.conf;
}

                       

vim /usr/local/php/etc/php.ini (在末尾增加内容)



[xcache-common]
extension = xcache.so
[xcache.admin]
xcache.admin.enable_auth = On  
xcache.admin.user = "dgg"   
xcache.admin.pass = "b152e1c07803be8f712d5da6fed0f7cf"     --上面 md5sum 的值
[xcache]
xcache.shm_scheme ="mmap"    
xcache.size=300M              
xcache.count =8                     
xcache.slots =32K             
xcache.ttl=3600              
xcache.gc_interval =300      
xcache.var_size=300M    --和xcache.size 值保持一致    
xcache.var_count =8     --和xcache.count 值保持一致     
xcache.var_slots =32K   --和xcache.slots 值保持一致      
xcache.var_ttl=0             
xcache.var_maxttl=0          
xcache.var_gc_interval =300  --和xcache.gc_interval 值保持一致 
xcache.test =Off             
xcache.readonly_protection = On  
xcache.mmap_path ="/home/xcache/xcache"  --上面创建的777权限的文件路径
xcache.coredump_directory ="/home/xcache/coredump"   --自定义
xcache.cacher =On               
xcache.stat=On                  
xcache.optimizer =Off           
[xcache.coverager]
xcache.coverager =On            
xcache.coveragedump_directory ="/home/xcache/coveragedump"  --自定义
:wq

chown www.www -R /home/xcache
chown www.www -R /usr/local/nginx/conf/vhost/xcache/

/etc/init.d/php-fpm restart
/etc/init.d/nginx reload


访问:ip:3000
登录用户:dgg 密码:dgg123456  

猜你喜欢

转载自blog.csdn.net/zzhlinux911218/article/details/89348248