为PHP添加xcache缓冲加速模块
http://xcache.lighttpd.net/ 最新稳定版本 Ver 1.2.2
首先通过
-
wget http://xcache.lighttpd.net/pub/Releases/1.2.2/xcache-1.2.2.tar.gz
获取最新的稳定版 Ver1.2.2 源码包
然后对源码包进行编译安装
-
tar -xzvf xcache-1.2.2.tar.gz
-
cd xcache-1.2.2/
-
/usr/local/php526/bin/phpize
-
./configure –with-php-config=/usr/local/php526/bin/php-config –enable-xcache
-
make
-
make install
-
cd ../
对xcache做配置
-
cat xcache.ini >> /usr/local/php526/conf/php.ini
或直接编辑 /usr/local/php526/conf/php.ini 添加后面的一些
-
[xcache-common]
-
zend_extension="/usr/local/php526/lib/php/extensions/no-debug-non-zts-20060613/xcache.so"
-
-
[xcache.admin]
-
xcache.admin.user = "xcache"
-
; xcache.admin.pass = md5("password")
-
xcache.admin.pass = "5f4dcc3b5aa765d61d8327deb882cf99"
-
-
[xcache]
-
xcache.cacher = On
-
xcache.shm_scheme = "mmap"
-
xcache.size = 32M
-
; cpu number (cat /proc/cpuinfo |grep -c processor)
-
xcache.count = 2
-
xcache.slots = 8k
-
xcache.ttl = 0
-
xcache.gc_interval = 0
-
xcache.var_size = 2M
-
; cpu number (cat /proc/cpuinfo |grep -c processor)
-
xcache.var_count = 2
-
xcache.var_slots = 8K
-
xcache.var_ttl = 0
-
xcache.var_maxttl = 0
-
xcache.var_gc_interval = 300
-
xcache.readonly_protection = Off
-
xcache.mmap_path = "/dev/zero"
验证xcache安装
1. 通过 /usr/local/php526/bin/php -v 查看有如下信息
PHP 5.2.6 (cli) (built: Jul 11 2008 00:02:23) Copyright (c) 1997-2008 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies with XCache v1.2.2, Copyright (c) 2005-2006, by mOo
2. 重新启动 phpfastcgi 进程,在网站下面做一个 php 页面包含
-
<?php
-
echo phpinfo();
-
?>
其中在 php credits 前面可以看到 有 eaccelerator 加载的标志。
This program makes use of the Zend Scripting Language Engine: Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies with XCache v1.2.2, Copyright (c) 2005-2006, by mOo
xcache 和 前面文章中介绍安装的 eaccelerator 功效差不多。
网上有人做了这两个缓冲器的对比,php缓冲器:eaccelerator与xcache性能测试对比 显示结果相差不大,可以按照自己的喜好使用其中一个。
Popularity: 4% [?]
Related
为php添加eaccelerator代码缓冲加速器
php每次都是加载文件进行分析解释执行,这当中浪费了很多资源,于是就有人想到,可不可以在php加载了文件后将分析后的op代码缓冲起来,以此来加快php代码的装载执行速度,这样就有了eaccelerator这样的产品诞生了。
http://www.eaccelerator.net/ 最新版本 0.9.5.3
首先通过
-
wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2
获取最新的 0.9.5.3 源码包
然后对源码包进行编译安装
-
tar -xjvf eaccelerator-0.9.5.3.tar.bz2
-
cd eaccelerator-0.9.5.3/
-
/usr/local/php526/bin/phpize
-
./configure –with-php-config=/usr/local/php526/bin/php-config
-
make
-
make install
-
cd ../
对eaccelerator做配置
编辑 /usr/local/php526/conf/php.ini 添加后面的一些
-
zend_extension="/usr/local/php526/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
-
eaccelerator.shm_size="16"
-
eaccelerator.cache_dir="/var/cache/eaccelerator"
-
eaccelerator.enable="1"
-
eaccelerator.optimizer="1"
-
eaccelerator.check_mtime="1"
-
eaccelerator.debug="0"
-
eaccelerator.filter=""
-
eaccelerator.shm_max="0"
-
eaccelerator.shm_ttl="0"
-
eaccelerator.shm_prune_period="0"
-
eaccelerator.shm_only="0"
-
eaccelerator.compress="1"
-
eaccelerator.compress_level="9"
对 extenstion 设置部分部分有如下一些要点:
1.如果使用Zend的线程安全方式则使用: zend_extension_ts
2.如果只是作为普通的php扩展则使用: extension
3.如果和Zend Optimizer一起使用,则必须在Zend Optimizer前加载,在php.ini中配置放在Zend Optimizer前面。
创建临时文件夹
-
mkdir -p /var/cache/eaccelerator
-
chmod 0777 /var/cache/eaccelerator
验证eaccelerator安装
1. 通过 /usr/local/php526/bin/php -v 查看有如下信息
PHP 5.2.6 (cli) (built: Jul 11 2008 00:02:23) Copyright (c) 1997-2008 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies with eAccelerator v0.9.5.3, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
2. 重新启动 phpfastcgi 进程,在网站下面做一个 php 页面包含
-
<?php
-
echo phpinfo();
-
?>
其中在 php credits 前面可以看到 有 eaccelerator 加载的标志。
This program makes use of the Zend Scripting Language Engine: Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies with eAccelerator v0.9.5.3, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
Popularity: 4% [?]
Related
安装配置Nginx 0.6.32 +php 5.2.6(fastcgi) + Mysql 5.0.51
安装过程参考: http://blog.s135.com/read.php/314.htm
安装 mysql 5.0.51
- 首先下载必须资源
-
wget http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.51b.tar.gz/from/ftp://ftp.iij.ad.jp/pub/db/mysql/
- 添加mysql 用户组和账号
-
/usr/sbin/groupadd mysql
-
/usr/sbin/useradd -d /var/lib/mysql -s /sbin/nologin -g mysql mysql
- 用源码包编译安装
-
tar zxvf mysql-5.0.51b.tar.gz
-
cd mysql-5.0.51b/
-
./configure –prefix=/usr/local/mysql5051 –without-debug –with-unix-socket-path=/usr/local/mysql5051/mysql.sock –with-client-ldflags=-all-static –with-mysqld-ldflags=-all-static –enable-assembler –with-extra-charsets=gbk,gb2312,utf8 –with-pthread –enable-thread-safe-client
-
make
-
make install
- 修改目录的权限
-
chmod +w /usr/local/mysql5051
-
chown -R mysql:mysql /usr/local/mysql5051
- 复制默认配置文件
-
cp support-files/my-medium.cnf /usr/local/mysql5051/my.cnf
-
cp support-files/mysql.server /etc/init.d/mysqld
-
chmod +x /etc/init.d/mysqld
-
cd ../
- 初始化mysql库
-
/usr/local/mysql5051/bin/mysql_install_db –defaults-file=/usr/local/mysql5051/my.cnf –basedir=/usr/local/mysql5051 –datadir=/usr/local/mysql5051/data –user=mysql –pid-file=/usr/local/mysql5051/mysql.pid –skip-locking –port=3306 –socket=/tmp/mysql.sock
- 开启MySQL数据库服务
-
/bin/sh /usr/local/mysql5051/bin/mysqld_safe –defaults-file=/usr/local/mysql5051/my.cnf &
-
chkconfig –add mysqld
-
chkconfig –level 3456 mysqld on
-
/sbin/service mysqld start
-
/sbin/service mysqld stop
- 验证MySQL服务器运行情况
mysql 5.0.51 源码包获取。
设定安装路径到 /usr/local/mysql5051
建立初始化的数据库表,数据库数据存放在 /usr/local/mysql5051/data目录下
直接的命令行方式开启
或通过服务控制方式开启关闭服务
1.ps -fe |grep mysql 查看运行的进程
2.netstat -na |grep mysql 查看开放的端口
3./usr/local/mysql5051/bin/mysql -u root -p 登陆mysql看一下,同时可以修改一下root密码。
安装 php 5.2.6
- 下载源码包
-
wget http://cn2.php.net/get/php-5.2.6.tar.gz/from/cn.php.net/mirror
-
wget "http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0"
- 安装依赖包
-
rpm -ivh libjpeg-devel-6b-33.i386.rpm
-
rpm -ivh libpng-devel-1.2.7-1.i386.rpm
-
rpm -ivh freetype-devel-2.1.9-1.i386.rpm
-
rpm -ivh gd-devel-2.0.28-4.i386.rpm
-
tar -xzvf libmcrypt-2.5.8.tar.gz
-
cd libmcrypt-2.5.8/
-
./configure
-
make
-
make install
-
/sbin/ldconfig
-
cd libltdl/
-
./configure –enable-ltdl-install
-
make
-
make install
-
cd ../../
- 编译安装源码包
-
tar -xzvf php-5.2.6.tar.gz
-
cd php-5.2.6
-
./configure –prefix=/usr/local/php526 –with-config-file-path=/usr/local/php526/etc –with-gd=/usr/ –enable-gd-native-ttf –with-ttf –with-freetype-dir –with-jpeg-dir=/usr/ –with-png-dir=/usr/ –with-zlib=/usr/ –with-mysql=/usr/local/mysql5051 –with-openssl=/usr/local/ssl –enable-mbstring –with-curl –with-curlwrappers –with-iconv-dir=/usr/local –with-libxml-dir –enable-xml –disable-debug –disable-rpath –enable-discard-path –enable-safe-mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –enable-mbregex –enable-fastcgi –enable-force-cgi-redirect –with-mcrypt
-
make
-
make install
-
cd ..
- 启动php的fast-cg进程
-
ulimit -SHn 51200
-
/usr/local/php526/spawn-fcgi -a 127.0.0.1 -p 10080 -C 30 -u www -f /usr/local/php526/bin/php-cgi
php 5.2.6
php 安装需要的一些配置包。
libmcrypt
先从RHEL安装盘上拷贝出如下一些rpm包用 rpm -ivh xxx.rpm 方式安装上。
在用源码方式安装下载下来的源码包
使用lighttpd带的 spwan-fcgi, 如下以www身份开启30个fast-cgi进程
安装 nginx
nginx的中文Wiki站点 http://wiki.codemongers.com/NginxChs
niginx的英文站点 http://nginx.net
- 下载需要的资源
-
wget http://sysoev.ru/nginx/nginx-0.6.32.tar.gz
-
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.7.tar.gz
- 安装需要的库
-
tar -xzvf pcre-7.7.tar.gz
-
cd pcre-7.7/
-
./configure
-
make
-
make install
-
cd ../
- 从源码包编译安装Nginx
-
tar -xzvf nginx-0.6.32.tar.gz
-
cd nginx-0.6.32/
-
./configure –user=www –group=www –prefix=/usr/local/nginx632 –with-http_stub_status_module
-
make
-
make install
-
cd ../
- 建立WEB账号以及组
-
/usr/sbin/groupadd www -g 48
-
/usr/sbin/useradd -u 48 -g www www
- 建立相关网站目录
-
mkdir -p /var/www/xxt.igrow.cn
-
chmod +w /var/www/xxt.igrow.cn
-
chown -R www:www /var/www/xxt.igrow.cn
-
mkdir -p /var/www/logs
-
chmod +w /var/www/logs
-
chown -R www:www /var/www/logs
- 做Nginx参数配置
-
user www www;
-
-
worker_processes 8;
-
-
error_log /var/www/logs/nginx_error.log crit;
-
pid /usr/local/nginx632/nginx.pid;
-
-
worker_rlimit_nofile 51200;
-
-
events
-
{
-
use epoll;
-
worker_connections 51200;
-
}
-
-
http
-
{
-
include mime.types;
-
default_type application/octet-stream;
-
-
charset utf-8;
-
-
server_names_hash_bucket_size 128;
-
-
sendfile on;
-
tcp_nopush on;
-
-
keepalive_timeout 60;
-
tcp_nodelay on;
-
-
fastcgi_connect_timeout 60;
-
fastcgi_send_timeout 180;
-
fastcgi_read_timeout 180;
-
fastcgi_buffer_size 128k;
-
fastcgi_buffers 4 128k;
-
fastcgi_busy_buffers_size 128k;
-
fastcgi_temp_file_write_size 128k;
-
fastcgi_temp_path /dev/shm;
-
-
gzip on;
-
gzip_min_length 1k;
-
gzip_buffers 4 8k;
-
gzip_http_version 1.1;
-
gzip_types text/plain application/x-javascript text/css text/html application/xml;
-
-
server
-
{
-
listen 80;
-
server_name xxt.igrow.cn;
-
index index.html index.htm index.php;
-
root /var/www/xxt.igrow.cn;
-
-
if (-d $request_filename)
-
{
-
rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
-
}
-
-
location ~ .*\.php?$
-
{
-
include fcgi.conf;
-
fastcgi_pass 127.0.0.1:10080;
-
fastcgi_index index.php;
-
}
-
-
log_format access '$remote_addr – $remote_user [$time_local] "$request" '
-
'$status $body_bytes_sent "$http_referer" '
-
'"$http_user_agent" $http_x_forwarded_for';
-
access_log /var/www/logs/access.log access;
-
}
-
-
server
-
{
-
listen 80;
-
server_name status.xxt.igrow.cn;
-
-
location / {
-
stub_status on;
-
access_log off;
-
}
-
}
-
}
-
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
-
fastcgi_param SERVER_SOFTWARE nginx;
-
-
fastcgi_param QUERY_STRING $query_string;
-
fastcgi_param REQUEST_METHOD $request_method;
-
fastcgi_param CONTENT_TYPE $content_type;
-
fastcgi_param CONTENT_LENGTH $content_length;
-
-
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
-
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
-
fastcgi_param REQUEST_URI $request_uri;
-
fastcgi_param DOCUMENT_URI $document_uri;
-
fastcgi_param DOCUMENT_ROOT $document_root;
-
fastcgi_param SERVER_PROTOCOL $server_protocol;
-
-
fastcgi_param REMOTE_ADDR $remote_addr;
-
fastcgi_param REMOTE_PORT $remote_port;
-
fastcgi_param SERVER_ADDR $server_addr;
-
fastcgi_param SERVER_PORT $server_port;
-
fastcgi_param SERVER_NAME $server_name;
-
-
# PHP only, required if PHP was built with –enable-force-cgi-redirect
-
#fastcgi_param REDIRECT_STATUS 200;
- 启动Nginx
-
ulimit -SHn 51200
-
/usr/local/nginx632/sbin/nginx
-
the configuration file /usr/local/nginx632/conf/nginx.conf syntax is ok
-
the configuration file /usr/local/nginx632/conf/nginx.conf was tested successfully
获取nginx 0.6.32 源码包和所依赖的 pcre 源码包
设定安装目录到 /usr/local/nginx632
建立以 www:www 的账号和组用来运行网站服务。
存放网站的路径
日志路径
建nginx.conf文件
cat /usr/local/nginx632/conf/nginx.conf:
建fcgi.conf文件
cat /usr/local/nginx632/conf/fcgi.conf
在运行前可以通过 /usr/local/nginx632/sbin/nginx -t 检查一下看nginx的参数是否配置正确。
如果屏幕显示以下两行信息,说明配置文件正确:
配置开机启动Mysql+Phpcgi+Nginx
因为没有安装服务,需要添加一些命令到 /etc/rc.local 中用来开机启动
-
ulimit -SHn 51200
-
/bin/sh /usr/local/mysql5051/bin/mysqld_safe –defaults-file=/usr/local/mysql5051/my.cnf &
-
/usr/local/php526/spawn-fcgi -a 127.0.0.1 -p 10080 -C 30 -u www -f /usr/local/php526/bin/php-cgi
-
/usr/local/nginx632/sbin/nginx
设置iptables
在防火墙中放开相关服务端口。
-
#web port
-
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
-
#fastcgi port
-
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 10080 -s 127.0.0.1 -j ACCEPT
-
#mysql 本地通过unix socket访问, 不用设置
-
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp -s 127.0.0.1 –dport 3306 -j ACCEPT
使用 /sbin/service iptables restart 重新应用防火墙规则
验证服务状态
验证 nginx + php 运行是否正常。
在 /var/www/xxt.igrow.cn 目录下建一个test.php,里面存放内容
-
<?
-
echo phpinfo();
-
?>
通过 curl http://127.0.0.1/test.php 可以看到输出的php信息,表示 nginx + php 运行正常。
Popularity: 5% [?]
Related
July 11, 2008 | Filed Under LAMP, MySQL, WebServer | 4 Comments
快速打造Win下的Php+Mysql开发环境
快速打造自己的php+mysql开发环境。
一.打造服务端运行环境
选择http://www.fleaphp.org/的安装包,安装后包括了 apache + mysql + php 的集成环境。
假定安装后的路径为 D:\fleaphp-apmxe, 使用cmd方式运行 D:\fleaphp-apmxe\php5\php -ver 查看php版本。
1.为php添加xdebug模块
到 http://xdebug.org/ 下载对应版本的 xdebug 模块,拷贝到 D:\fleaphp-apmxe\php5目录下, 在 D:\fleaphp-apmxe 目录下创建文件夹 xdebug
在 D:\fleaphp-apmxe\etc\php.ini.template 文件中注释掉 [Zend] 设置,然后添加
[XDebug]
zend_extension_ts=”%APMXE%\php5\php_xdebug-2.0.3-5.2.5.dll”
xdebug.profiler_enable=on
xdebug.trace_output_dir=”%APMXE%\xdebug”
xdebug.profiler_output_dir=”%APMXE%\xdebug”
xdebug.profiler_output_name=”script”
到 http://sourceforge.net/projects/wincachegrind/ 下载WinCacheGrind方便以后打开 xdebug目录下的script文件分析php脚本执行性能。 附一篇介绍使用XDebug查找Php代码中问题的好文: http://www.ibm.com/developerworks/cn/opensource/os-php-xdebug/
2.修改apache的www路径为自己的文件路径
fleaphp的集成环境安装后默认是指向 D:\fleaphp-apmxe\htdocs 目录提供服务,我们自己使用其作为开发环境时基本不是这样。需要修改apache的配置文件设定自己的主工作路径和虚拟主机的名称。
在 D:\fleaphp-apmxe\etc\httpd.conf.template 文件的最后添加一个虚拟主机配置
ServerAdmin webmaster@dummy-host.example.com DocumentRoot d:\mysites\test ServerName test.mysite.com ErrorLog %APMXE%/var/logs/dummy-host.example.com-error_log CustomLog %APMXE%/var/logs/dummy-host.example.com-access_log common
设定一个 test.mysite.com 的主机,指向 d:\mysites\test 的目录
可以到 www.phpmyadmin.net/下载一个phpMyAdmin做mysql的维护
3.修改本地hosts文件
修改 本地 %SYSTEMDIR%\drivers\etc\hosts文件,添加一行
127.0.0.1 test.mysite.com
4.重新启动fleaphp集成包的APM Express,使修改生效
在浏览器中输入 test.mysite.com 打开自己的目录
二.打造自己的浏览器
1. 下载 FireFox 安装
2. 为FireFox安装 FireBug 插件
3. 为FireFox安装Yahoo 的 YSlow插件
Popularity: 3% [?]