优化方法:
a.Compile PHP’s modules as less as possible, the simple the best (fast);
b.Increas PHP FastCGI child number to 100 and even more. Sometime, 200 is OK! ( On 4GB memory server);
c.Using SOCKET PHP FastCGI, and put into /dev/shm on Linux;
d.Increase Linux “max open files”, using the following command (must be root):
e.Increase PHP-FPM open file description rlimit:
f.Using PHP code accelerator, e.g eAccelerator, XCache. And set “cache_dir” to /dev/shm on Linux.
====================================
A.减少编译模块,对应需要编译,后续的可以通过扩展添加。eAccelerator也是通过扩展添加的。
B.修改 /usr/local/php/etc/php-fpm.conf,单独应用单独修改对应conf文件。LINK:nginx php fpm多实例配置
[global]process.max = 128;进程数量警告值[www]pm = dynamic
pm.max_children = 5;调高监听进程数量
C.参考nginx php fpm多实例配置当中nginx.cnf连接PHP方法”fastcgi_pass unix:/tmp/php-cgi-nodeA.sock;”
D.调高linux内核打开文件数量
echo 'ulimit -HSn 65536' >> /etc/profileecho 'ulimit -HSn 65536' >> /etc/rc.localsource /etc/profile#对应php-fpm.conf中rlimit_core,默认linux内核打开文件数量 E.修改 /usr/local/php/etc/php-fpm.conf,调高rlimit_files值
[global]rlimit_files = 2048[www]rlimit_files = 2048 F.利用php代码加速器eAccelerator
加速引擎: memcache、eAccelerator
创建www用户做web执行用户
groupadd www
useradd -r -g www -s /sbin/nologin www
F.1.memcache模块
简介:Memcache模块提供了于memcached方便的面向过程及面向对象的接口,memcached是为了降低动态web应用
从数据库加载数据而产生的一种常驻进程缓存产品。Memcached是一个高性能分布式的内存对象缓存系统,
通常被用于降低数据库加载压力以提高动态web应用的响应速度。
Memcached提供系统内存缓存-Memcache提供PHP接口
代码包:libevent-2.0.21-stable.tar.gz、memcached-1.4.15.tar.gz、memcache-2.2.7.tgz
memcached依赖libevent
tar zxvf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure
make && make installecho '/usr/local/lib/' > /etc/ld.so.conf.d/libevent.conf
ldconfig
tar zxvf memcached-1.4.15.tar.gz
cd memcached-1.4.15