squid,nginx,apache几个代理软件的比较

作者 : admin 于 2009年09月13日, 11:51:03
2009
09-13

最近一直在研究代理缓存之类的东东,几个软件一直在瞎鼓捣,没弄出个结果,自己也稀里糊涂,总结一下几天折腾的成绩:

在并发上,nginx无疑是老大,做反向代理的时候,没有发现squid的并发方面介绍,所以暂且认为ngnix是老大,apache的稳定性有目共睹,但在并发方面的确不是很如意。

缓存方面:squid,apache都支持diskcache和memcache,根据http的head头来确定是否缓存,nginx不支持缓存,不过我在google开源上看见了新浪的水杨老大的一个东东,给nginx加上了文件缓存,不过没有大规模使用,暂时不把它当做一种解决方案。

在代理和缓存的规则上,apache很强,很强大的重写功能,尤其是强制修改http规则,不过这个功能我始终没有调试成功,no-cache的页面始终无法去缓存。

如果只是做网站的反向代理,负载均衡,nginx感觉要比squid强,性能强悍,配置方便。

如果是做代理+缓存加速,那squid的功能和稳定性还是很好的,毕竟在互联网上大量应用。

apache呢?好像没它的事情了。当然不是,有些地方可以拿他的功能当中间件使用,这个等下次分解。

在windows下玩apache php不能不知的几个小设置

作者 : admin 于 2009年06月10日, 17:09:26
2009
06-10

1、PHPIniDir “D:\PHP5″

这样不用每次都把php.ini拷贝到C:\Windows下

2、set Path=D:\PHP5;D:\PHP5\ext;%Path%

这样不用每次把那些dll拷贝到C:\Windows\system32下

限制apache http线程的带宽

作者 : admin 于 2009年05月29日, 12:09:15
2009
05-29

最近带宽告急,原因是我做了几个开源软件的下载,结果带宽持续飙升,已经到了IDC给我的限度,所以在apache上增加了mod_bw模块(mod_bandwidth).

下载 mod_bw 的源代码 http://www.ivn.cl/apache/files/source/mod_bw-0.8.tgz

解压后,执行 apxs -i -a -c mod_bw.c

貌似自动就加到httpd.conf文件里。

如果不是自动的,就手工拷贝 mod_bw.so 到 apache module目录,httpd.conf 里增加 LoadModule bw_module modules/mod_bw.so

在虚拟主机里增加如下配置文件

  1. BandWidthModule On             #打开带宽限制功能
  2. ForceBandWidthModule On     #强制带宽限制
  3. BandWidth all 102400            #强制100KB
  4. MinBandWidth all -1

具体的配置文档可以看这里

mod_bw-08

我的apache配置-mpm

作者 : admin 于 2009年05月28日, 23:13:29
2009
05-28
  1. <ifmodule mpm_prefork_module>
  2.     StartServers              2
  3.     MinSpareServers         5
  4.     MaxSpareServers        10
  5.     MaxClients                 128
  6.     MaxRequestsPerChild    5000
  7. </ifmodule>

这个配置基本支撑http的访问,几个博客,一个论坛,还有一个哥们很大的静态并发。

以前使用的是work方式,因为不太了解,经常造成进程崩溃,又切换到了prefork方式,这次调整的比较稳定了。

Linux下APACHE MYSQL PHP FCgid Suexec 配置文档V1.0

作者 : admin 于 2009年05月22日, 11:14:12
2009
05-22

文档版本:V1.0

启动撰写时间: 2009年05月20日

目的:全面详细介绍LAMP fastcgi方式配置细节,基于之前的自动配置脚本,目的是把更多的细节转达给大家。

需要软件源码:

CentOS4.7

http://centos.ustc.edu.cn/centos/4.7/isos/i386/CentOS-4.7.ServerCD-i386.iso

http://centos.ustc.edu.cn/centos/4.7/isos/x86_64/CentOS-4.7.ServerCD-x86_64.iso

Apache-2.2.9

http://archive.apache.org/dist/httpd/httpd-2.2.9.tar.gz

MYSQL-5.2.6

http://downloads.mysql.com/archives/mysql-5.0/mysql-5.0.22.tar.gz

PHP-5.2.6

http://museum.php.net/php5/php-5.2.6.tar.gz

FCGID

http://ncu.dl.sourceforge.net/sourceforge/mod-fcgid/mod_fcgid.2.2.tgz

安装:

第一步:Linux系统安装,同时可以参照我原来的文档

http://www.sunboyu.cn/2008/06/13/centos5%E5%AE%89%E8%A3%85%E6%8C%87%E5%8D%97%EF%BC%88%E7%AE%80%E5%8D%95%E7%AF%87%EF%BC%89.shtml

阅读全部 »

还是Nginx对抗负载的能力强

作者 : admin 于 2009年04月07日, 14:45:11
2009
04-7

编译了老半天的apache,又做了很多调整和优化,依然抗不住死机,其实负载也不是很大,但内存CPU就是出奇的高,无奈,装上nginx,负载一下子下来了。

顺便提一下,我PC级的服务器。

感谢  http://www.51fit.com/ 友情提供测试数据

计划重新部署apache,调整工作模式。

Apache开启Gzip压缩

作者 : admin 于 2008年10月28日, 13:57:00
2008
10-28

文档位置 http://lamp.linux.gov.cn/Apache/ApacheMenu/mod/mod_deflate.html

Apache2中的实时压缩解压的模块编译在mod_deflate模块中,替换了原来的mod_gzip模块。

编译apache的时候 –enable-deflate  这个参数是默认开启的,编译完会有mod_deflate模块。

配置站点:

如果我们想使一个文件传输的时候进行加密,我们在站点配置文件里增加这样的配置

<Location />
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
Header append Vary User-Agent env=!dont-vary
</Location>
这样,/opt/httpd-2.2.9/htdocs目录下的所有mime类型为text/html的文件就可以启用

未压缩的http头

Date Tue, 28 Oct 2008 13:04:15 GMT
Server Apache/2.2.9 (Unix) DAV/2 PHP/5.2.6
Last-Modified Tue, 28 Oct 2008 12:51:52 GMT
Etag “30623-55fda-45a4fb62a8a00″
Accept-Ranges bytes
Content-Length 352218
Content-Type text/html
Vary Accept-Encoding,User-Agent

压缩后的http头

Date Tue, 28 Oct 2008 13:07:39 GMT
Server Apache/2.2.9 (Unix) DAV/2 PHP/5.2.6
Last-Modified Tue, 28 Oct 2008 12:51:52 GMT
Etag “30623-55fda-45a4fb62a8a00″-gzip
Accept-Ranges bytes
Vary Accept-Encoding,User-Agent
Content-Encoding gzip
Content-Length 2778
Keep-Alive timeout=5, max=100
Connection Keep-Alive
Content-Type text/html

原来length为352218,压缩后为2778,效果还是很明显的。

不过对于length很小的文件,是不进行压缩的。

具体的一些调整的细节,可以看原apache手册。

sunboyu-amp-mod-V1.0 alpha

作者 : admin 于 2008年07月26日, 13:37:47
2008
07-26

重新做了个模块版的,这次apache使用动态编译

sunboyu-amp-isapi-v10-alpha

sunboyu-amp-fastcgi-V1.0 Alpha版本发布

作者 : admin 于 2008年07月24日, 14:04:45
2008
07-24

sunboyu-amp-fastcgi-v10-alpha

基本都配置完毕了,但整体流程没有彻底自动化,适当的时候会作出stable版本。
# author:sunboyu@gmail.com
# qq:176300676 msn:sunboyu@gmail.com
# http://www.sunboyu.cn

#!/bin/sh
h_path = “/root/”
url=”http://www.sunboyu.cn/sourse/”
install_dir=”/opt/”
mkdir $install_dir

termcap_sourse_name=”termcap-1.3.1″

mysql_sourse_name=”mysql-5.0.22″
mysql_install_dir=$install_dir$mysql_sourse_name

openssl_sourse_name=”openssl-0.9.8g”
openssl_install_dir=$install_dir$openssl_sourse_name

httpd_sourse_name=”httpd-2.2.9″
httpd_install_dir=$install_dir$httpd_sourse_name

fastcgi_sourse_name=”mod_fastcgi-2.4.6″
fastcgi_install_dir=$install_dir$fastcgi_sourse_name

fcgid_sourse_name=”mod_fcgid.2.2″

libxml2_sourse_name=”libxml2-2.6.30″
libxml2_install_dir=$install_dir$libxml2_sourse_name

zlib_sourse_name=”zlib-1.2.3″

jpeg_sourse_name=”jpegsrc.v6b”
jpeg_install_dir=$install_dir$jpeg_sourse_name

libpng_sourse_name=”libpng-1.2.29″
libpng_install_dir=$install_dir$libpng_sourse_name

freetype_sourse_name=”freetype-2.3.7″
freetype_install_dir=$install_dir$freetype_sourse_name

php_sourse_name=”php-5.2.6″
php_install_dir=$install_dir$php_sourse_name

gd_sourse_name=”gd-2.0.36RC1″
gd_install_dir=$install_dir$gd_sourse_name

###MYSQL依赖库
wget ${url}${termcap_sourse_name}”.tar.gz”
tar -zxvf $termcap_sourse_name”.tar.gz”
cd $termcap_sourse_name
./configure
make && make install
cd ..
#rm -rf ${termcap_sourse_name}*
###openssl
wget ${url}${openssl_sourse_name}”.tar.gz”
tar -zxvf $openssl_sourse_name”.tar.gz”
cd $openssl_sourse_name
./Configure –prefix=$openssl_install_dir
make && make install
cd ..
#rm -rf ${openssl_sourse_name}*
###libxml
wget ${url}${libxml2_sourse_name}”.tar.gz”
tar -zxvf $libxml2_sourse_name”.tar.gz”
cd $libxml2_sourse_name
./configure –prefix=$libxml2_install_dir
make && make install
cd ..
#rm -rf ${libxml2_sourse_name}*
###zlib
wget ${url}${zlib_sourse_name}”.tar.gz”
tar -zxvf $zlib_sourse_name”.tar.gz”
cd $zlib_sourse_name
./configure
make && make install
cd ..
cp /usr/lib/libz.so.1 /usr/lib/libz.so
#rm -rf ${zlib_sourse_name}*
###jpeg
wget ${url}${jpeg_sourse_name}”.tar.gz”
tar -zxvf $jpeg_sourse_name”.tar.gz”
cd jpeg-6b
./configure
mkdir /usr/local/man/
mkdir /usr/local/man/man1/
mkdir /usr/local/man/man1/cjpeg/
make && make install
cp /usr/lib/libjpeg.so.62 /usr/lib/libjpeg.so
cp jpeglib.h /usr/include/jpeglib.h
cp jconfig.h /usr/include/jconfig.h
cp jmorecfg.h /usr/include/jmorecfg.h
cp jerror.h /usr/include/jerror.h
cd ..
#rm -rf ${jpeg_sourse_name}.tar.gz
#rm -rf jpeg-6b
###png
wget ${url}${libpng_sourse_name}”.tar.gz”
tar -zxvf $libpng_sourse_name”.tar.gz”
cd $libpng_sourse_name
./configure –prefix=$libpng_install_dir
make && make install
cp png* /usr/include/
cd ..
#rm -rf ${libpng_sourse_name}*
###freetype
wget ${url}${freetype_sourse_name}”.tar.gz”
tar -zxvf $freetype_sourse_name”.tar.gz”
cd $freetype_sourse_name
./configure –prefix=$freetype_install_dir
make && make install
cd ..
#rm -rf ${freetype_sourse_name}*
###GD2
wget ${url}${gd_sourse_name}”.tar.gz”
tar -zxvf $gd_sourse_name”.tar.gz”
cd $gd_sourse_name
./configure –prefix=$gd_install_dir –with-png=/opt/libpng-1.2.29 –with-freetype=/opt/freetype-2.3.7 –with-jpeg=/usr/lib/libjpeg.so
make && make install
cd ..
#rm -rf ${gd_sourse_name}*
###MYSQL
groupadd mysql
useradd -g mysql mysql
wget ${url}${mysql_sourse_name}”.tar.gz”
tar -zxvf $mysql_sourse_name”.tar.gz”
cd $mysql_sourse_name
./configure –prefix=$mysql_install_dir –without-debug –with-unix-socket-path=/tmp/mysql.sock –with-client-ldflags=-all-static –with-mysqld-ldflags=-all-static –enable-local-infile –enable-largefile –with-charset=utf8 –with-pic –with-mysqld-libs –with-comment –with-query-cache –with-bench –with-big-tables –with-innodb –with-mysqld-use=mysql
make && make install
cp ./support-files/my-medium.cnf /etc/my.cnf
cp ./support-files/mysql.server /etc/init.d/mysqld
cd ..
#mkdir $mysql_install_dir/var/
#$mysql_install_dir/bin/mysql_install_db –user=mysql &
#$mysql_install_dir/bin/mysqld_safe –user=mysql &

echo ${mysql_install_dir}”/bin/mysqld_safe –user=mysql &”>>/etc/rc.local
#rm -rf ${mysql_sourse_name}*
###APACHE
wget ${url}${httpd_sourse_name}”.tar.gz”
tar -zxvf $httpd_sourse_name”.tar.gz”
cd $httpd_sourse_name
./configure –prefix=$httpd_install_dir –enable-authz-dbm –enable-log-config –enable-headers –enable-setenvif –with-ssl=$openssl_install_dir –enable-static-ab –enable-http –enable-mime –enable-status –enable-suexec –enable-vhost-alias –enable-dir –enable-rewrite –with-mpm=worker
make && make install
cd ..
ln -s $httpd_install_dir/bin/apachectl /etc/init.d/httpd
echo $httpd_install_dir/bin/apachectl start>>/etc/rc.local
chkconfig –level 345 httpd on
#rm -rf ${httpd_sourse_name}*
###fastcgi
wget ${url}${fastcgi_sourse_name}”.tar.gz”
tar -zxvf $fastcgi_sourse_name”.tar.gz”
cd $fastcgi_sourse_name
sed ’s/\/usr\/local\/apache2/\/opt\/httpd-2.2.9\//g’ Makefile.AP2 > Makefile
make && make install
cd ..
###fcgid
wget ${url}${fcgid_sourse_name}”.tgz”
tar -zxvf $fcgid_sourse_name”.tgz”
cd $fcgid_sourse_name
mv Makefile Makefile.AP2
sed ’s/\/usr\/local\/apache2/\/opt\/httpd-2.2.9\//g’ Makefile.AP2 > Makefile
make && make install
cd ..
echo LoadModule fcgid_module modules/mod_fcgid.so>>$httpd_install_dir/conf/httpd.conf
echo AddHandler fcgid-script .php>>$httpd_install_dir/conf/httpd.conf
echo “FCGIWrapper “${php_install_dir}”/bin/php-cgi .php”>>$httpd_install_dir/conf/httpd.conf
#rm -rf ${fastcgi_sourse_name}*
###PHP
wget ${url}${php_sourse_name}”.tar.gz”
tar -zxvf $php_sourse_name”.tar.gz”
cd $php_sourse_name
cp php.ini-dist php.ini
./configure –prefix=$php_install_dir –with-libxml-dir=$libxml2_install_dir –enable-cli –enable-cgi –enable-fastcgi –enable-force-cgi-redirect –enable-discard-path –enable-path-info-check –with-openssl –with-pcre-regex –enable-calendar –enable-dom –enable-ftp –with-openssl-dir=/usr/local/ssl –enable-gd-jis-conv –enable-hash –with-iconv –enable-json –enable-mbstring –enable-mbregex –enable-pdo –enable-posix –enable-libxml=$xml2_install_dir –enable-simplexml –with-sqlite –enable-tokenizer –enable-xmlreader –enable-xmlwriter –with-zlib –with-freetype-dir=$freetype_install_dir –with-gd=$gd_install_dir –with-jpeg-dir=/usr/lib/libjpeg.so –with-libpng-dir=/opt/libpng-1.2.29/lib/libpng12.so –with-zlib-dir=/usr/lib/libz.so –with-mime-magic –with-mysql=$mysql_install_dir –with-zlib-dir=/usr/lib/libz.so –with-pdo-mysql=$mysql_install_dir –with-pdo-sqlite –enable-posix –enable-soap
make && make install
cp php.ini $php_install_dir/lib/
cd ..
$mysql_install_dir/bin/mysql_install_db –user=mysql &

service httpd start
service mysqld start

Apache2 PHP5 FastCgi配置终于完成

作者 : admin 于 2008年07月23日, 22:12:57
2008
07-23

这次是使用的mod_fastcgi的一个替代品:fcgid http://fastcgi.coremail.cn/ 在功能上完全可以取代fastcgi,在性能和稳定性上还优于fastcgi(据说),不过配置起来也比fastcgi的简单,只需要加上 loadmodule fcgid_module SetHandler fcgid-script
FCGIWrapper /usr/local/bin/php-cgi .php 即可。
权限方面,呵呵,还没有测试。留档,加到我的amp的shell里。

LoadModule fcgid_module modules/mod_fcgid.so
AddHandler fcgid-script .php
FCGIWrapper /opt/php5/bin/php-cgi .php

 Page 1 of 2  1  2 »