PHP的加速器配置介绍
php的加速器:基于PHP的特殊扩展机制如opcode缓存扩展也可以将opcode缓存于php的共享内存中,从而可以让同一段代码的后续重复执行时跳过编译阶段以提高性能。这些加速器并非真正提高了opcode的运行速度,而仅是通过分析opcode后并将它们重新排列以达到快速执行的目的
常见的第三方php加速器1、APC (Alternative PHP Cache)
遵循PHP License的开源框架,PHP opcode缓存加速器,目前的版本不适用于PHP 5.4
项目地址:http://pecl.php.net/package/APC
2、eAccelerator
源于Turck MMCache,早期的版本包含了一个PHP encoder和PHP loader,目前encoder已经不在支持。项目地址 :http://eaccelerator.net/
3、XCache
快速而且稳定的PHP opcode缓存,经过严格测试且被大量用于生产环境。项目地址:http://xcache.lighttpd.net/,收录EPEL源
4、Zend Optimizer和Zend Guard Loader
Zend Optimizer并非一个opcode加速器,它是由Zend Technologies为PHP5.2及以前的版本提供的一个免费、闭源的PHP扩展,其能够运行由Zend Guard生成的加密的PHP代码或模糊代码。 而Zend Guard Loader则是专为PHP5.3提供的类似于Zend Optimizer功能的扩展。项目地址http://www.zend.com/en/products/guard/runtime-decoders
5、NuSphere PhpExpress
NuSphere的一款开源PHP加速器,它支持装载通过NuSphere PHP Encoder编码的PHP程序文件,并能够实现对常规PHP文件的执行加速。项目地址,http://www.nusphere.com/products/phpexpress.htm
编译php-xcache加速访问,支持php 5.6版以下
官网:http://xcache.lighttpd.net/wiki/ReleaseArchive
案例:CentOS 7上安装清华源的php56,并编译安装 xcache加速
[root@centos7 ~]#yum -install https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/remi-release-7.rpm [root@centos7 ~]#yum -y install php56-php php56-php-mysqlnd mariadb-server [root@centos7 ~]#systemctl enable --now httpd mariadb Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service. [root@centos7 ~]#mysql MariaDB [(none)] create database wordpress; MariaDB [(none)] grant all on wordpress.* to wordpress@ localhost identified by magedu [root@centos7 ~]#tar xvf wordpress-5.3.2-zh_CN.tar.gz -C /var/www/html [root@centos7 ~]#cd /var/www/html [root@centos7 ~]#chown -R apache.apache wordpress/ [root@centos8 ~]#ab -c 10 -n 100 http://10.0.0.7/wordpress/ ...... Requests per second: 3.16 [#/sec] (mean) ...... #安装编译xcache [root@centos7 ~]#yum -y install gcc php56-php-devel #下载并解压缩xcache-3.2.0.tar.bz2 [root@centos7 ~]#tar xf xcache-3.2.0.tar.gz #生成编译环境 [root@centos7 ~]#cd xcache-3.2.0/ [root@centos7 xcache-3.2.0]#/opt/remi/php56/root/usr/bin/phpize Configuring for: PHP Api Version: 20131106 Zend Module Api No: 20131226 Zend Extension Api No: 220131226 [root@centos7 xcache-3.2.0]#./configure --enable-xcache --with-php-config=/opt/remi/php56/root/usr/bin/php-config [root@centos7 xcache-3.2.0]#make make install ...省略... Installing shared extensions: /opt/remi/php56/root/usr/lib64/php/modules/ [root@centos7 xcache-3.2.0]#cat xcache.ini /opt/remi/php56/root/etc/php.ini #安装base源中执行即可cp xcache.ini /etc/php.d/ [root@centos7 ~]#systemctl restart httpd.service #测试性能 [root@centos8 ~]#ab -c10 -n 100 http://LAMP服务器/wordpress Requests per second: 7.26 [#/sec] (mean)opcache加速php 7.X
[root@centos8 ~]#dnf install php-opcache [root@centos8 ~]#cat /etc/php.ini [opcache] zend_extension=opcache.so opcache.enable=1
范例:CentOS 8 实现opache 加速
[root@centos8 ~]#dnf -y install httpd php php-mysqlnd mariadb-server php-opcache php-json [root@centos8 ~]#rpm -ql php-opcache /etc/php.d/10-opcache.ini /etc/php.d/opcache-default.blacklist /usr/lib/.build-id /usr/lib/.build-id/71 /usr/lib/.build-id/71/55ebb00f7ebcab9d708c1d5c7b7e634cce259c /usr/lib64/php/modules/opcache.so [root@centos8 ~]#grep opcache /etc/php.d/10-opcache.ini zend_extension=opcache opcache.enable=1 ...省略... #禁用加速 [root@centos8 ~]#vim /etc/php.d/10-opcache.ini opcache.enable=0 [root@centos8 ~]#systemctl restart php-fpm [root@centos7 ~]#ab -c 10 -n 100 http://10.0.0.8/wordpress/ ...... Requests per second: 4.31 [#/sec] (mean) ...... #启用加速 [root@centos8 ~]#vim /etc/php.d/10-opcache.ini opcache.enable=1 [root@centos8 ~]#systemctl restart php-fpm ##加速后 [root@centos7 ~]#ab -c 10 -n 100 http://10.0.0.8/wordpress/ ...... Requests per second: 19.76 [#/sec] (mean) ......
本文链接:http://www.yunweipai.com/36095.html
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/52443.html
apachecentosLAMPmysqlphpPHP5wordpress开源相关文章
- PHP时区设置相差8小时间程序与php.ini配置方法
- Linux快速部署配置PHP服务器环境(linux部署php环境)
- 解锁PHP的高效Oracle配置(php配置oracle)
- MacOS上配置PHP环境的指南(Macos配置php)
- MySQL PHP长连接:持久化提升应用性能(mysql php长连接)
- PHP无法连接MSSQL服务器(php 读不到mssql)
- 使用PHP扩展开发MSSQL应用(php扩展使用mssql)
- PHP与MSSQL的良好结合,发挥强大的功能(php和mssql)
- PHP封装MSSQL,提升高效开发力度(php mssql 封装)
- PHP如何正确配置MongoDB数据库连接?(php配置mongodb)
- Linux环境下轻松配置PHP:简单指南(linux下配置php)
- Linux系统下 PHP的安装和配置(linux下php的安装)
- 安装MongoDB,接入PHP开发新篇章(php安装mongodb)
- MySQL和PHP:构建更先进的开发体系(mysql 和php)
- Oracle和PHP完美配合提升数据库性能(oracle php配置)
- PHP初学者头疼问题总结
- IIS6的PHP最佳配置方法
- PHP输入流php://input介绍
- php中flush()、ob_flush()、ob_end_flush()的区别介绍
- PHP获取和操作配置文件php.ini的几个函数介绍