在SSH Linux中文解决乱码的技巧
作者:admin 日期:2009-11-12
rhel5下安装GCC
作者:admin 日期:2009-11-12
程序代码error: Failed dependencies:
cpp = 4.1.1-52.el5 is needed by gcc-4.1.1-52.el5.i386
libgomp = 4.1.1-52.el5 is needed by gcc-4.1.1-52.el5.i386
libgomp.so.1 is needed by gcc-4.1.1-52.el5.i386
找了好久的资料,最后终于找到一些相关的,先安装
1.libgomp
2.cpp
3.gcc
squid 2.6之Web反向代理加速实做/防盗链/防盗用/防爬虫
作者:admin 日期:2008-12-16
1. 下载squid2.6 http://www.squid-cache.org/Versions/v2/2.6/squid-2.6.STABLE1-20060726.tar.gz
2. 安装:
wwwtest137#cd squid-2.6.STABLE1-20060726
wwwtest137#configure --prefix=/usr/local/squid --enable-dlmalloc --with-pthreads --enable-poll --disable-internal-dns --enable-stacktrace --enable-removal-policies="heap,lru" --enable-delay-pools --enable-storeio="aufs,coss,diskd,ufs"
wwwtest137#make
wwwtest137#make install
因为是测试的,所以相关的参数可能并不是比较完善的,但是使用是没有问题的。
3. 配置:以下是部分关键配置,其他与2.5的相同
#服务器IP 192.168.1.1
#监听服务器的80端口,透明代理,支持域名和IP的虚拟主机
http_port 192.168.1.1:80 transparent vhost vport
#限制同一IP客户端的最大连接数
acl OverConnLimit maxconn 16
http_access deny OverConnLimit
#防止天涯盗链,转嫁给百度
acl tianya referer_regex -i tianya
http_access deny tianya
deny_info http://www.baidu.com/logs.gif tianya
#防止被人利用为HTTP代理,设置允许访问的IP地址
acl myip dst 192.168.1.1
http_access deny !myip
#防止百度机器人爬死服务器
acl AntiBaidu req_header User-Agent Baiduspider
http_access deny AntiBaidu
#允许本地管理
acl Manager proto cache_object
acl Localhost src 127.0.0.1 192.168.1.1
http_access allow Manager Localhost
http_access deny Manager
#仅仅允许80端口的代理
acl Safe_ports port 80 # http
http_access deny !Safe_ports
http_access allow all
#Squid信息设置
visible_hostname www.test137.com
cache_mgr webmaster@test137.com
#基本设置
cache_effective_user squid
cache_effective_group squid
tcp_recv_bufsize 65535 bytes
#2.5的反向代理加速配置
#httpd_accel_host 127.0.0.1
#httpd_accel_port 80
#httpd_accel_single_host on
#httpd_accel_uses_host_header on
#httpd_accel_with_proxy on
#2.6的反向代理加速配置
#代理到本机的80端口的服务,仅仅做为原始内容服务器
cache_peer 127.0.0.1 parent 80 0 no-query originserver
#错误文档
error_directory /usr/local/squid/share/errors/Simplify_Chinese
#单台使用,不使用该功能
icp_port 0
http服务器,监听到127.0.0.1的80端口。
5. 数据走向:
访问者=>192.168.1.1:80=>127.0.0.1:80
6. 测试:
/usr/local/squid/sbin/squid -z
/usr/local/squid/sbin/squid -NCd1
好了,现在访问你的服务器看看,已经好了。
为了测试是否可用,把http服务器给停了,你就可以看到squid2.6的信息了。
另外,我们设置:
SQUID监听外部IP的80端口
HTTP服务器监听本机127.0.0.1的80端口
这样子不用任何防火墙参与,即可完成web反向代理加速。
Tags: squid
.net 2.0的URL重写导致的Bug及其解决方法
作者:admin 日期:2008-09-28
最近在服务器的日志中出现许多Web事件的警告信息。时间间隔非常规律,一分钟出现一至两次,其错误信息摘取关键部分如下:
事件类型: 警告
事件来源: ASP.NET 2.0.50727.0
事件种类: Web 事件
事件 ID: 1309
日期: 2008-1-13
事件: 14:43:41
用户: N/A
描述:
事件代码: 3005
事件消息: 发生了未处理的异常。
事件时间: 2008-1-13 14:43:41
事件时间(UTC): 2008-1-13 6:43:41
事件 ID: f94c4a45b696449db6df2a3d571059e3
事件序列: 110527
事件匹配项: 9121
事件详细信息代码: 0
异常信息:
异常类型: HttpException
异常消息: 无法使用前导 .. 在顶级目录上退出。
请求信息:
请求 URL: http://dormforce.net/Music/*****.aspx?id=7085&id2=633358175566250000
请求路径: /Music/*****.aspx
用户主机地址: 66.249.66.38
用户:
是否已经过身份验证: False
身份验证类型:
线程帐户名: NT AUTHORITY\NETWORK SERVICE
线程信息:
线程 ID: 1
线程帐户名: NT AUTHORITY\NETWORK SERVICE
是否正在模拟: False
堆栈跟踪: 在 System.Web.Util.UrlPath.ReduceVirtualPath(String path)
在 System.Web.Util.UrlPath.Reduce(String path)
在 System.Web.Util.UrlPath.Combine(String appPath, String basepath, String relative)
在 System.Web.HttpResponse.ApplyAppPathModifier(String virtualPath)
在 System.Web.UI.HtmlControls.HtmlForm.GetActionAttribute()
在 System.Web.UI.HtmlControls.HtmlForm.RenderAttributes(HtmlTextWriter writer)
在 System.Web.UI.HtmlControls.HtmlControl.RenderBeginTag(HtmlTextWriter writer)
在 System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output)
在 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
在 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
在 System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer)
在 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
在 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
在 System.Web.UI.Page.Render(HtmlTextWriter writer)
在 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
在 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
在 System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
最初以为是源代码中的问题,打开源码仔细分析没有找到逻辑上的错误,不得其解。查找主机的IP地址,发现居然是GoogleBot 搜寻引擎机器人,后来在网上看到一篇文章,Get GoogleBot to crash your .NET 2.0 site
服务器的大用户量的承载方案 Nginx Squid Apache PHP MySQL
作者:admin 日期:2008-09-12
squid 2.6版安装配置
作者:admin 日期:2008-08-21
1、 下载squid 2.6版的软件
官方网址:http://www.squid-cache.org/
到那里去下载最新版的 squid软件
将此软件包上传至 web主机。并在主机上将下载下来的软件包解压。如果你下载的 gz
包的话。就用tar zxvf XXXXX.gz (XXXX.gz 为你下载来的软件包名) 如果你下载的是 gz2
包。那么就用 tar jxvf XXXX.gz2(XXXX.gz2 为你下载来的软件包名)
2、 进入你解压出来的那个目录。然后执行编译安装
./configure
--exec_prefix=/usr/local/squid
--bindir=/usr/sbin
--libexecdir=/usr/lib/squid
--sysconfdir=/etc/squid
--enable-poll
--enable-snmp
--enable-removal-policies="heap,lru"
--enable-storeio="aufs,coss,diskd,null,ufs"
--enable-ssl
--with-openssl=/usr/kerberos
--enable-delay-pools
--enable-linux-netfilter
--with-pthreads --enable-auth="basic"
--with-winbind-auth-challenge
--enable-useragent-log
--enable-referer-log
--disable-dependency-tracking
--enable-cachemgr-hostname=localhost
--disable-ident-lookups
--enable-truncate
--enable-underscores
--datadir=/usr/share/squid
--enable-basic-auth-helpers="NCSA"
--enable-err-language="Simplify_Chinese"
--enable-default-err-language="Simplify_Chinese"
编译完后再执行
make
make install
好了。安装完毕后,修改目录权限,默认是以"nobody"用户运行squid.所以我们要为
/usr/local/squid/var 设置相应的权限,否则会报以下错误
FATAL: Failed to make swap directory /usr/local/squid/var/cache: (13) Permission denied
Squid Cache (Version 2.5.STABLE13): Terminated abnormally.
CPU Usage: 0.000 seconds = 0.000 user + 0.000 sys
Maximum Resident Size: 0 KB
Page faults with physical i/o: 4
或者以下错误
FATAL: Cannot open '/usr/local/squid/var/logs/access.log' for writing.
The parent directory must be writeable by the
user 'nobody', which is the cache_effective_user
set in squid.conf.
最简单的处理办法就是
chown -R nobody:nobody /usr/local/squid/var
ok,生成缓存目录
/usr/local/squid/sbin/squid -z
然后启动squid,测试一下是否成功
/usr/local/squid/bin/Runcache
默认端口是3128,用ie测试一下,如果能看到中文的拒绝访问错误提示,就说明安装正确,
并且已经使用.
以后就可以直接/usr/local/squid/bin/Runcache & 后台运行即可,
现在我们开始讲如何配置 squid.conf 文件
visible_hostname localhost #你的主机名可以是localhost
http_port 211.XX.XX.XXX:80 vhost vport #你需要做 squid服务器的IP及端口号
icp_port 0
cache_mem 900 MB #squid 所使用的内存
cache_swap_low 90 #缓存最低使用
cache_swap_high 95 #缓存最高使用
maximum_object_size 20000 KB #当大于200000K 时不对文件进
maximum_object_size_in_memory 4096 KB #放入内存的最小大小
cache_dir ufs /dev/shm/tmp 1000 16 256 #这里我们会在后面再讲
cache_store_log none
cache_vary on #apache 的一个新特性。
emulate_httpd_log on #日志
cache_mgr tpsys@126.com #设置管理员的邮箱
logfile_rotate 0 #日志不保存
logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs %<st "%{Referer}>h"
"%{User-Agent}>h" %Ss:%Sh #日志格式
pid_filename /home/squid/squid.pid #pid文件
cache_log /home/squid/var/logs/cache.log #日志
access_log /home/squid/var/logs/access.log combined #日志
acl all src 0.0.0.0/0.0.0.0 #允许所有地址访问
acl QUERY urlpath_regex cgi-bin .php .cgi .avi .wmv .rm .ram .mpg .mpeg .zip .exe .rar 对这一些
扩名的文件不缓存
cache deny QUERY
acl picurl url_regex -i \.bmp$ \.png$ \.jpg$ \.gif$ \.jpeg$ \.rm$ #主要是防盗连。
acl mystie1 referer_regex -i .5i.la #对5i.la防盗连
http_access allow mystie1 picurl
acl mystie3 referer_regex -i .wg333.com#对 wg333.com防盗连
http_access allow mystie3 picurl
acl mystie4 referer_regex -i .99doc.com#对99doc.com防盗连
http_access allow mystie4 picurl
acl mystie2 referer_regex -i .orasos.com#对 orasos.com防盗连
http_access allow mystie2 picurl
acl nullref referer_regex -i ^$
http_access allow nullref
acl hasref referer_regex -i .+
http_access deny hasref picurl
acl Safe_ports port 80 # http # 开放80端口允许进来。
acl Safe_ports port 21 # ftp # 开放21端口允许进来。
http_access deny !Safe_ports
tcp_recv_bufsize 65535 bytes
acl OverConnLimit maxconn 36 #同一个客户端最多只允许连入36 个连接
http_access deny OverConnLimit
acl tianya referer_regex -i tianya
http_access deny tianya
deny_info http://www.baidu.com/logs.gif tianya
refresh_pattern -i .html 1440 100% 129600 reload-into-ims #对HTML 进行缓存
refresh_pattern -i .shtml 1440 100% 129600 reload-into-ims #对SHTML进行缓存
refresh_pattern -i .htm 1440 100% 129600 reload-into-ims #对HTM进行缓存
refresh_pattern -i .gif 1440 100% 129600 reload-into-ims #对GIF进行缓存
refresh_pattern -i .swf 1440 100% 129600 reload-into-ims #对SWF进行缓存
refresh_pattern -i .png 1440 100% 129600 reload-into-ims #对 PNG进行缓存
refresh_pattern -i .bmp 1440 100% 129600 reload-into-ims #对BMP进行缓存
refresh_pattern -i .css 1440 100% 129600 reload-into-ims#对 CSS进行缓存
refresh_pattern -i .jpg 1440 100% 129600 reload-into-ims #对 JPG 进行缓存
refresh_pattern -i .txt 1440 100% 129600 reload-into-ims #对TXT进行缓存
refresh_pattern -i .rhtml 1440 100% 129600 reload-into-ims #对RHTML进行缓存
refresh_pattern -i .xml 1440 100% 129600 reload-into-ims #对XML进行缓存
#以下内容和squid 2.5有所不一样。2.6 中需要通过 cache_peer来设定指向主机,如果你需要
做虚拟主机的话。你可以省略 name=a 这个关建字 举例说明
cache_peer 192.168.8.105 parent 80 0 no-query originserver name=a
#每一个name 关建字。必须要和下面的 cache_peer_domain 一起来使用。
cache_peer 192.168.8.161 parent 888 0 no-query originserver name=b
#这里的888 和 808 分别指的是你的apache 或者 IIS 绑定的主机头里的端口号。我们这里
是为了安全,所以不采用80端口
cache_peer 192.168.8.88 parent 808 0 no-query originserver name=c
#808后面的0 为 icp_port 0 这什值。我们目前用不到。所以先不管。你只要写0 就行
cache_peer_domain b .orasos.com
#比如这一句话的意思就是。当orasos.com这外域来访问 squid时。Squid通确定他使用的是
什么域名 这里使用的是 orasos.com 然后来查询 cache_peer_domain 中有没有这个域名。如
果有则取这个域名的cache_peer的name 值 我们这里是b 然后再和cache_peer中去比对。
有没有name=b这个主机指向。如果有,就从这个主机指向那里取数据
cache_peer_domain a .5i.la
cache_peer_domain a .99doc.com
cache_peer_domain a .wg333.com
cache_effective_user nobody
cache_effective_group nobody
好了。写了这么多。安装和配置就搞定了。
如果你能看的明白话。我想你装一个Squid起来的话。是绝对不会在问题了的。
批量清除Squid缓存的小工具
作者:admin 日期:2008-08-11
http://www.wa.apana.org.au/~dean/squidpurge/
wget http://www.wa.apana.org.au/~dean/sources/purge-20040201-src.tar.gz
tar zxvf purge-20040201-src.tar.gz
test






