Skip to content


tinymce在ie6下表现比较差

extended_valid_elements无法使用,HTML代码编辑时内容会消失. IE6下在贴word文档时不能正确转换,ie7和FF下没有问题 IE7下会出现Ø ,FF下没事 讨论http://drupal.org/node/32883 解决方法是入库时用PHP替换http://tinymce.moxiecode.net/punbb/viewtopic.php?id=4352

Posted in Others, 技术.


apache rewrite 针对目录转向

恭喜公司.com再此被百度收录。 网站改版后,由于目录和文件命名的改变,以前收录的URL就是404了,现需转发至资料备份服务器。 使用php的话效率低了,所以用apache直接转发。

  #笨方法 Redirect temp /doc/ http://222.222.222.222/doc/ Redirect temp /news/ http://222.222.222.222/news/ Redirect temp /parttimetalent/ http://222.222.222.222/parttimetalent/ Redirect temp /fulltimetalent/ http://222.222.222.222/fulltimetalent/ Redirect temp /person/ http://222.222.222.222/person/ Redirect temp /ebook/ <a href="http://222.222.222.222/ebook/http://222.222.222.222/ebook/ </coolcode>

#使用正则 RedirectMatch temp ^/(doc|news|parttimetalent|fulltimetalent|person|ebook)/(.*) http://222.222.222.222/$1/$2

#反向代理;对图片、js等目录都需处理,比较麻烦 #需开启proxy_module和proxy_http_module,费资源 ProxyPass /doc/ http://222.222.222.222/doc/ ProxyPass /Include/ http://222.222.222.222/Include/ ProxyPassReverse /doc/ http://222.222.222.222/doc/

关于在转向时使用301还是302,可以参考 http://www.chinamyhosting.com/seoblog/2006/04/12/301-redirect/

如果想收录新站就用301,保持原站索引用302

Posted in Apache, 技术.

Tagged with , .


apache 进程 cpu 和 找不到图片

发布新版首页时,高峰时 task达到800,cpu 60% keepAlive off后 下降至3百多到,cpu 10~40%. 补上一张找不到的ICON后 下降至3百不到,cpu 10%.

404的图片对apache的进程和cpu还是有点影响的,10~30%左右

Posted in Apache, 其它, 分析报告, 技术.

Tagged with .


apache关闭某目录的PHP解析

可以在http.conf的目录区域增加”php_flag engine”参数,关闭对某个目录的php解析,起到保护的作用。

    DocumentRoot /opt/htdocs/www     ServerName local.c1gstudio.com     php_flag engine Off     AddOutputFilterByType DEFLATE text/html text/plain text/xml

 

关闭后php文件将会变成可下载的纯文本文件,所以请小心使用。

Posted in Apache, PHP, 技术.

Tagged with , .


apache下rewrite防盗链

在http.conf中添加模块

LoadModule rewrite_module modules/mod_rewrite.so #可能需要的其它相关模块 LoadModule mime_module modules/mod_mime.so LoadModule setenvif_module modules/mod_setenvif.so LoadModule headers_module modules/mod_headers.so

rewrite方式 可以自定的我内容,如显示友好的图片 可以地址中带URL进行破解 充许空referer 在根目录下新建allow目录存放允许访问的内容,如leech.gif

RewriteEngine on RewriteCond %{REQUEST_URI} ^/allow RewriteRule ^.*$ – [L] RewriteCond %{REQUEST_FILENAME} \.(gif|jpg|jpeg|png|swf|css|rar|zip)$ [NC] RewriteCond %{HTTP_REFERER} !^$ [NC] #空referer RewriteCond %{HTTP_REFERER} !192.168.1.111 [NC] RewriteCond %{HTTP_REFERER} !192.168.1.221 [NC] RewriteCond %{HTTP_REFERER} !domain\.com [NC] RewriteCond %{HTTP_REFERER} !domain\.net [NC] RewriteCond %{HTTP_REFERER} !anotherdomain\.com [NC] RewriteRule (.*) /allow/leech.gif [R,NC,L]

SetEnv方式 直接转到403页面去,如果请求是图片的话,那就是一个红X

SetEnvIfNoCase Referer “^http://192.168.1.111″/ local_ref=1 SetEnvIfNoCase Referer “^http://192.168.1.221″/ local_ref=1 SetEnvIfNoCase Referer “^http://.*\.domain\.com” local_ref=1 SetEnvIfNoCase Referer “.*\.domain\.com” local_ref=1 SetEnvIfNoCase Referer “^http://domain.com”/ local_ref=1 SetEnvIfNoCase Referer “^http://*\.domain\.net” local_ref=1 SetEnvIfNoCase Referer “.*\.domain\.net” local_ref=1 SetEnvIfNoCase Referer “^http://domain\.net”/ local_ref=1 SetEnvIfNoCase Referer “^http://*\.anotherdomain\.com” local_ref=1 SetEnvIfNoCase Referer “.*\.anotherdomain\.com” local_ref=1 SetEnv NoLOG 1 Order Allow,Deny Allow from env=local_ref

参考 http://blogsdiy.org/2007-04/prevent-hotlinking/

Posted in Apache, 技术.

Tagged with , .


iptables小记

开启 /etc/init.d/iptables start

关闭 /etc/init.d/iptables stop

设定每次开启不启动该服务项目,可以使用 chkconfig 来关闭。 chkconfig iptables off

查看当前iptables iptables -L

保存规则 iptables-save > /etc/sysconfig/iptables

恢复规则 iptables-restore < /etc/sysconfig/iptables

禁止123.456.789.0-123.456.789.255的流进和流出 iptables -t filter -A INPUT -s 123.456.789.0/24 -j DROP iptables -t filter -A OUTPUT -d 123.456.789.0/24 -j DROP

删除规则 iptables -t filter -D OUTPUT -d 123.456.789.0/24 -j DROP

禁止流进ip段 iptables -I INPUT -s 211.0.0.0/8 -j DROP

iptables -I INPUT -s 211.1.0.0/16 -j DROP iptables -I INPUT -s 211.2.0.0/16 -j DROP iptables -I INPUT -s 211.3.0.0/16 -j DROP

iptables -I INPUT -s 61.37.80.0/24 -j DROP iptables -I INPUT -s 61.37.81.0/24 -j DROP

默认策略: iptables -P INPUT ACCEPT iptables -P OUTPUT DROP iptables -P FORWARD DROP 接受所有ssh连接: iptables -A INPUT -p tcp -m tcp -s 0/0 –dport 22 -j ACCEPT 管理FTP连接: iptables -A INPUT -p tcp -m tcp –dport 21 -j ACCEPT iptables -A INPUT -p tcp -s 127.0.0.1/8 -d 0/0 –destination-port 20 –syn -j ACCEPT iptables -A INPUT -p tcp -s 127.0.0.1/8 -d 0/0 –destination-port 21 –syn -j ACCEPT

监视SNMP: iptables -A INPUT -p udp -m udp –dport 161 -j ACCEPT iptables -A INPUT -p udp -m udp –sport 1023:2999 -j ACCEPT 管理POP电子邮件: iptables -A INPUT -p tcp -m tcp –dport 110 -j ACCEPT –syn HTTPS服务: iptables -A INPUT -p tcp -m tcp –dport 443 -j ACCEPT –syn SMTP连接: iptables -A INPUT -p tcp -m tcp –dport 25 -j ACCEPT –syn 管理HTTP: iptables -A INPUT -p tcp -m tcp –dport 80 -j ACCEPT –syn 管理MySQL数据库: iptables -A INPUT -p tcp -m tcp –dport 3306 -j ACCEPT –syn iptables -A INPUT -p udp -m udp –dport 3306 -j ACCEPT

IMAP邮件服务: iptables -A INPUT -p tcp -m tcp –dport 143 -j ACCEPT –syn

管理DNS服务: iptables -A INPUT -p tcp -m tcp –dport 53 -j ACCEPT –syn iptables -A INPUT -p udp -m udp –dport 53 -j ACCEPT iptables -A INPUT -p udp -m udp -s 0/0 -d 0/0 –sport 53 -j ACCEPT

管理本地主机连接: iptables -A INPUT -i lo -j ACCEPT -m tcp

丢弃所有其它的新请求: iptables -A INPUT -p tcp -m tcp -j REJECT –syn iptables -A INPUT -p udp -m udp -j REJECT

防止SYN洪水攻击: iptables -A INPUT -p tcp –syn -m limit –limit 5/second -j ACCEPT

屏蔽恶意主机(比如,192.168.0.8): iptables -A INPUT -p tcp -m tcp -s 192.168.0.8 -j DROP

检查防火墙日志: iptables -A INPUT -j LOG –log-level alert iptables -A INPUT -j LOG –log-prefix “Dropped: ”

做 NAT: iptables -A POSTROUTING -t nat -o eth0 -s 192.168.1.0/24 -d 0/0 -j MASQUERADE iptables -A FORWARD -t filter -o eth0 -m state –state NEW,ESTABLISHED,RELATED -j ACCEPT iptables -A FORWARD -t filter -i eth0 -m state –state ESTABLISHED,RELATED -j ACCEPT

清空所有规则: iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X

http://bbs.chinaunix.net/thread-216752-1-1.html

Posted in Linux 命令, 技术.

Tagged with .


前端开发工程师的工具箱 2007-09-25

来自TAOBAO的UED推荐

http://docs.google.com/Present?docid=dgr8f7vc_46gmggrv&fs=true

Google Presentation 目前的功能相比PowerPoint还很简单,只能插入图片和文本,不支持动画。但相信这些功能很快就会出现。

creasemonkey fiddle Internet Explorer Developer Toolbar ie7pro firebug yslow web develop

Posted in HTML/XHTML/CSS, 技术.


php session 多级目录

这是一个提高大量会话性能的好主意。 ; 注意0: “N;[MODE;]/path”两边的双引号不能省略。 ; 注意1: [MODE;]并不会改写进程的umask。 ; 注意2: php不会自动创建这些文件夹结构。请使用ext/session目录下的mod_files.sh脚本创建。 ; 注意3: 如果该文件夹可以被不安全的用户访问(比如默认的”/tmp”),那么将会带来安全漏洞。 ; 注意4: 当N>0时自动垃圾回收将会失效,具体参见下面有关垃圾搜集的部分。

修改 php.ini的 session.save_path 选项,大致如下:

#注意linux下的tmpwatch会对/tmp目录下长时间(10天左右)不访问的文件和目录删除 #解决方法  https://blog.c1gstudio.com/archives/600

session.save_path = “1;/tmp/session”

php5无session.hash_bits_per_character时值为6 范围为 : 0-9, a-z, A-Z, “-“, “,” 建目录命令可参考php/ext/session/mod_files.sh

session回收命令 /usr/bin/find /tmp/session -name ‘sess_*’ -type f -mmin +120 | /usr/bin/xargs /bin/rm -f

设一crontab /1 * /bin/sh /opt/session_gc.sh

/sbin/service crond reload

================ 最后注意crontab是没有环境变量的,命令需带路径 sh文件最好在linux上编辑,不要在win下写好再传,最后一个换行符导致 invalid option — Try `/bin/rm –help’ for more information.浪费了我好多时间

Posted in linux 维护优化, PHP, 技术.

Tagged with , .


apache优化

原始设置

#Timeout 300 #KeepAlive On #MaxKeepAliveRequests 100 #KeepAliveTimeout 5 #ServerSignature Off

#

# StartServers 5 # MinSpareServers 5 # MaxSpareServers 10 # MaxClients 256 # MaxRequestsPerChild 0 #

高峰时访问很慢

ps -aux | grep httpd|wc -l

进程到250就上不去了。

暂时改一下keepAlive看看情况, 修改设置

#Timeout 150 #KeepAlive Off #MaxKeepAliveRequests 60 #KeepAliveTimeout 5 #ServerSignature Off

访问速度一下上去了,进程也就130左右

再次修改配置

#Timeout 180 #KeepAlive On #MaxKeepAliveRequests 64 #KeepAliveTimeout 5 #ServerSignature Off

#

# ServerLimit 1000 # StartServers 10 # MinSpareServers 10 # MaxSpareServers 20 # MaxClients 512 # MaxRequestsPerChild 100000 #

进程稳定在330,就是载入图片有点慢

Posted in linux 维护优化, 技术.


linux的默认字符集?

env |grep LANG
LANG=zh_CN.GB18030 LANGUAGE=zh_CN.GB18030:zh_CN.GB2312:zh_CN

cat /etc/sysconfig/i18n LANG=”zh_CN.GB18030″ LANGUAGE=”zh_CN.GB18030:zh_CN.GB2312:zh_CN” SUPPORTED=”zh_CN.UTF-8:zh_CN:zh:en_US.UTF-8:en_US:en” SYSFONT=”lat0-sun16″

Posted in LINUX, 技术.