2012年11月24日星期六

通过Firebug来查看访问一个网址所发送的所有HTTP Request

通过Firebug来查看访问一个网址所发送的所有HTTP Request
1.点击导航工具栏的Firebug图标


2.打开Firebug窗口后,选择“Net”——“All”,Domain列中就是访问一个网址后,发送的所有HTTP Request所对应的网址,其中Romote IP列中的0.0.0.0表示该网址是通过Socks 5代理来访问的,没有通过代理访问的网址在Remote IP列中会显示该域名所对应的IP和端口号

备注:
1.有时访问一个网址打不开,并不是因为该网址无法访问,而是访问这个网址时会有很多链接到其它网址的HTTP Request,如果这些被链接到的网址无法访问,就会造成该网址打不开的假象,其实是隐藏在该网址背后的一些网址无法访问(比如访问Google Analytics时就会访问很多其它的网址,而这些网址很可能被国内屏蔽了,这时就会造成Google Analytics无法正常访问的现象)。

2011年10月24日星期一

各种域名邮箱与企业邮箱的简单对比

各种域名邮箱与企业邮箱的简单对比

电子邮件虽然出现很长一段时间了,但作为现代企业,一些商务事宜还是需要用到email,如果公司的员工每人使用一个不同域名的邮箱,就会给人一种不规范或是不专业的感觉,这可能会降低商务伙伴对公司形象的认可,所以公司的员工使用一个具有统一域名邮箱是很有必要的。

1.Google企业应用套件
优点:
免费、安全、功能强大,可以使用Google的其他服务,如Google Docs、Google Calendar等
缺点:
有时候速度很慢,慢到让人想崩溃,虽然这不是Google的错,邮件账号有限制,最多50人 ,现在有些已经降到10人了。

2.腾讯域名邮箱(http://domain.mail.qq.com)
优点:国内访问速度快
缺点:域名邮箱的使用需和QQ邮箱绑定,域名邮箱和个人邮箱没有分离开,不适合企业用

3.腾讯企业邮箱(http://exmail.qq.com)

2011年10月19日星期三

Linux中自动注销用户

当用户连上服务器后,如果中途走开了,闲置太久就不太好了,此时为了安全起见就需要自动注销当前已登录的用户

方法如下:
编辑用户主目录下面的.bashrc文件,添加如下一行即可:
TMOUT=1800      //表示当前用户多久不操作就注销当前用户,单位为秒

或者:
编辑/etc/profile文件,同样添加一行:
TMOUT=1800     //时间间隔根据不同的环境自行设定

TMOUT=0        //表示永不注销

注:/etc/profile文件中的TMOUT参数对全局有效,即对所有用户均有效;当用户主目录下的
      .bashrc也定义了TMOUT,则以.bashrc文件中的TMOUT值为准,.bashrc文件的优先级高于
      /etc/profile,如果希望root用户例外,可将root用户主目录中.bashrc文件的TMOUT值
      设为0即可。

      修改配置文件后记得source(或者.)一下,使之即时生效。

WordPress必备插件

WordPress版本:3.2.1
WordPress必备插件:

1.Collapsing Categories
多级分类插件

2.Google Analytics for WordPress
看名字就知道了,不解释

3.Quotmarks Replacer
保持特殊字符原本的样子,没装这个插件时"--"会显示为"-"

4.TinyMCE Advanced
增强型编辑器,主要用它的漂亮字体和允许空行功能

5.Twenty Eleven Theme Extensions
在每个页面都显示侧边栏,没装这个插件时,默认只在主页显示侧边栏

6.WP Cleaner
清除自动保存、草稿和修订版本

7.WP Super Settings
关闭烦人的自动保持和修订版本

最近TinyMCE Advanced的允许空行时常失灵,要想打空格,只能麻烦点了。方法如下:
换行时将输入法切换到全角,打个空格即可

Debian下iptables的save、restart及永久保存

系统环境:Debian-6 32-bit
iptables是即时生效的,所以无需重启,如果要停止iptables,请使用iptables -F命令,如果要iptables配置重启后仍然有效,请按如下操作步骤:

1.创建/etc/iptables文件(文件名可以随意取)

2.创建/etc/network/if-pre-up.d/iptables文件,并给予其执行权限
root@godontop:~# touch /etc/network/if-pre-up.d/iptables
root@godontop:~# chmod +x /etc/network/if-pre-up.d/iptables

3.编辑/etc/network/if-pre-up.d/iptables文件,使其内容如下:
#!/bin/sh
/sbin/iptables-restore < /etc/iptables

4.配置iptables,过程略,配置好iptables后,将配置保存到/etc/iptables文件中即可
root@godontop:~# iptables-save > /etc/iptables

iptables -F  //将内存中iptables的所有配置清空,效果等同于停止了iptables

2011年10月16日星期日

信用卡使用要点

1.信用卡(VISA或MASTER)在境外消费是不需要密码的,所以进行境外的网络交易最好使用
   paypal

Debian 5升级至Debian 6

1.使用Debian 5的网络版镜像(debian-5.0.0-i386-netinst.iso)进行最小化安装,下载地址:http://www.yunfile.com

2.系统安装好后,编辑/etc/apt/source.list文件,整个文件只需如下两行即可:
deb http://ftp.us.debian.org/debian/ squeeze main contrib
deb http://security.debian.org/ squeeze/updates main

3.下载Debian 6的PUBLIC KEY
wget http://ftp-master.debian.org/archive-key-6.0.asc

4.导入PUBLIC KEY,命令如下:
apt-key add archive-key-6.0.asc

5.更新源
apt-get update

6.更新现有软件包
apt-get upgrade 

7.更新内核
apt-cache search linux-image-2.6    //查找最适合的内核
apt-get install linux-image-2.6.32-5-686    //更新内核

8.安装udev,之后重启电脑
apt-get install udev

9.版本升级,之后再次重启电脑
apt-get dist-upgrade

注:更新的过程中报过一个小错误,说locale的设置不正确,但并没有影响系统版本的升级,
      可能是因为我很多东西都是选的美国的,但时区选的中国的原因吧,下次全选美国的,
      装好后再更改系统时区。

2011年10月12日星期三

为CentOS-5.5升级PHP到5.2.10

系统环境:CentOS-5.5-x86
PHP默认版本:5.1.6
因最新版的WordPress需要PHP-5.2.4以上版本,所以不得不升级PHP

1.编辑/etc/yum.repos.d/CentOS-Base.repo文件,将下面的内容添加到文件的末尾:
[CentOS-Testing]
name=CentOS-5 Testing
baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/
enabled=0
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing

# CentOS-Testing:
# !!!! CAUTION !!!!
# This repository is a proving grounds for packages on their way to CentOSPlus 
# and CentOS Extras.
# They may or may not replace core CentOS packages, and are not guaranteed to 
# function properly.
# These packages build and install, but are waiting for feedback from testers as 
# to functionality and stability. Packages in this repository will come and go 
# during the development period, so it should not be left enabled or used on 
# production systems without due consideration. 

在CentOS-Base.repo文件中不要启用CentOS-Testing,必要的时候用yum的enablerepo参数就可以了,所以上面enabled参数后面的值是0.

2.检查CentOS-Testing中是否有关于PHP的可用更新;
yum --disablerepo=* --enablerepo=CentOS-Testing check-update php*

3.更新PHP相关的软件
yum --disablerepo=* --enablerepo=CentOS-Testing update php*

2011年10月10日星期一

编译PHP时提示:"configure:error:xml2-config not found. Please check your libxml2 installation."

系统环境:CentOS-5.5-x86

[root@huage php-5.3.8] # ./configure
configure:error:xml2-config not found. Please check your libxml2 installation.

[root@godontop ~]# rpm -qa |grep libxml2
libxml2-2.6.26-2.1.12
libxml2-python-2.6.26-2.1.2.8.el5_5.1

这里显示libxml2是安装了的,但仍提示libxml2可能没装,最后试着安装了libxml2-devel,结果成功编译。

注:如果在编译软件时,如果提示说"你的某个包没有安装",而这个包又的的确确存在于你的
    系统中,这时候很可能是你没有安装这个包对应的开发库(即:如果提示说:"你可
    能没有安装lzo这个软件包,而你系统里又确实装了lzo这个包,那么很可能是你没
    有安装lzo-devel这个包")。如果编译失败是因某个package-devel没有装导致的,系统
    并不会提示说"你的package-devel包没装",它只会提示说"你的package可能没装"。

2011年10月6日星期四

压缩与解压缩之tar

压缩与解压缩之tar
[root@huage ~]#tar -zcvf website.tgz public_html
将当前目录下的public_html目录打包并用gzip压缩,以website.tgz作为文件名

[root@huage ~]#tar -zxvf website.tgz
将website.tgz文件解压到当前目录

[root@huage ~]#tar -zxvf website.tgz -C /var/www
将website.tgz文件解压到指定目录"/var/www"

tar选项:
-z 用gzip压缩
-c 创建新的archive
-v 显示详细信息
-f 指定文件
-C change to directory

2011年10月5日星期三

最后一个男人

    某男对某美眉穷追不舍,美眉不厌其烦:“你省省吧,就算世界上只剩你一个男人,我也不会嫁给你的。”某男颇为不自在,回答说:“如果世界上只剩我一个男人,你以为我还会看上你吗?”

2011年9月30日星期五

linux中的cron服务

[root@huage ~]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 1 * * * root run-parts /etc/cron.daily
03 2 * * 0 root run-parts /etc/cron.weekly
04 3 1 * * root run-parts /etc/cron.monthly

       The first four lines are variables used to configure the environment in which the cron tasks are run. The SHELL variable tells the system which shell environment to use (in this example the bash shell), while the PATH variable defines the path used to execute commands. The output of the cron tasks are emailed to the username defined with the MAILTO variable. If the MAILTO variable is defined as an empty string (MAILTO=""), email is not sent. The HOME variable can be used to set the home directory to use when executing commands or scripts.
 
      As shown in the /etc/crontab file, the run-parts script executes the scripts in the /etc/cron.hourly/, /etc/cron.daily/, /etc/cron.weekly/, and /etc/cron.monthly/ directories on an hourly, daily, weekly, or monthly basis respectively. The files in these directories should be shell scripts.

      If a cron task is required to be executed on a schedule other than hourly, daily, weekly, or monthly, it can be added to the /etc/cron.d/ directory. All files in this directory use the same syntax as /etc/crontab.

      Users other than root can configure cron tasks by using the crontab utility. All user-defined crontabs are stored in the /var/spool/cron/ directory and are executed using the usernames of the users that created them. To create a crontab as a user, login as that user and type the command crontab -e to edit the user's crontab using the editor specified by the VISUAL or EDITOR environment variable. The file uses the same format as /etc/crontab. When the changes to the crontab are saved, the crontab is stored according to username and written to the file /var/spool/cron/username.

      The cron daemon checks the /etc/crontab file, the /etc/cron.d/ directory, and the /var/spool/cron/ directory every minute for any changes. If any changes are found, they are loaded into memory. Thus, the daemon does not need to be restarted if a crontab file is changed.

Controlling Access to Cron
      The /etc/cron.allow and /etc/cron.deny files are used to restrict access to cron. The format of both access control files is one username on each line. Whitespace is not permitted in either file. The cron daemon (crond) does not have to be restarted if the access control files are modified. The access control files are read each time a user tries to add or delete a cron task.

      The root user can always use cron, regardless of the usernames listed in the access control files.

      If the file cron.allow exists, only users listed in it are allowed to use cron, and the cron.deny file is ignored.

      If cron.allow does not exist, users listed in cron.deny are not allowed to use cron.

2011年9月28日星期三

经典实用的Shell命令

1.[root@desktop huage]# yum provides */filename
   查找filename是由哪个RPM包提供

2.[root@desktop huage]# locate filename
   快速查找名为filename的文件

3.[root@desktop huage]#rename .JPG .jpg *.JPG
   批量修改文件的后缀名(适用于redhat分支)

4.[root@desktop huage]#ls |grep jpg|awk -F'.' '{print $1}'|xargs -i mv {}.jpg {}.JPG
   批量修改文件的后缀名(两组单引号之间有个空格)

   [root@desktop huage]# ls |grep jpg|awk -F'.' '{print $1}'|xargs -i -t mv {}.jpg {}.JPG
   批量修改文件的后缀名(-t:详细显示xargs命令后面的操作)

5.[root@Server huage]# ls |grep -v  rpm$ |xargs -i -t rm -rf {}
   删除当前目录下所有后缀不是rpm的文件(包括目录文件)

6.[root@Server huage]# ls -F |egrep -v "rpm$|/$" |xargs -i -t rm -rf {}
   删除当前目录下所有后缀不是rpm的文件(不包括目录文件)

7.[root@Server huage]# find . -type f -print |grep -v rpm$ |xargs -i -t rm -rf {}
   删除当前目录及其子目录下所有后缀不是rpm的文件

8.[root@Server huage]# ls -lSh
   用易于人类读写的单位按从大到小的顺序排序(主要用于文件的排序,不统计目录的具体大小)

9.[root@Server huage]# ls -lShr
   用易于人类读写的单位按从小到大的顺序排序(主要用于文件的排序,不统计目录的具体大小)

10.[root@Server huage]# ls |xargs du -sh |sort -h
     用易于人类读写的单位按从小到大的顺序排序(包括目录)

11.[huage@fedora ~]$ script
     记录接下来的所有终端输出

12.[huage@fedora ~]$ script huage
     记录所有终端输出到文件huage

13.[huage@fedora ~]$ time shell-command
     对shell-command命令计时,time后直接跟shell命令即可

14.[root@Server tmp]# find . -type f -exec chmod 644 {} \;
     或者:
     [root@Server tmp]# find . -type f -exec chmod 644 {} +
     将当前目录及其子目录下的所有文件的权限设为644

15.[root@Server tmp]# find . -type d -exec chmod 755 {} \;
     或者:
     [root@Server tmp]# find . -type d -exec chmod 755 {} +
     将当前目录及其子目录的权限设为755

16.[root@fedora huage]# find . -type f |xargs chmod 644
     将当前目录及其子目录下的所有文件的权限设为644(如果目录名中包含空格,则chmod对该目录无效)

17.[root@fedora huage]# find . -type d |xargs chmod 755
     将当前目录及其子目录的权限设为755(如果目录名中包含空格,则chmod对该目录无效)

注:在18和19例中,如果文件(包括目录文件)名中包含空格,则chmod命令对该文件无效,实际上是xargs命令无法正确处理文件名中包含空格的文件和目录文件。

28.[root@fedora huage]# python -m SimpleHTTPServer
     通过python的SimpleHTTPServer模块来快速搭建一个HTTP Server,之后可以通过 
     http://server-ip:8000或者http://localhost:8000来访问

19.[root@fedora huage]#
mail admin@huage.com -s "Backuping HUA is successfully done" < /root/huage/backup
用一条命令来发送邮件给admin@huage.com,且主题为"Backuping HUA is successfully done",邮件正文内容为"/root/huage/backup"。

20.[root@fedora huage]# mail huage@gmail.com -s "Backuping ADG is successfully done" < /root/hauge/backup-adg -- -f admin@google.com -F "The Admin of Google"

      发送一封主题为"Backuping ADG is successfully done"、邮件正文为"/root/hauge/backup-adg"的内容、发件人为admin@google.com且发件人显示名称为"The Admin of Google"的邮件给huage@gmail.com

21.[root@fedora huage]# du -sh /home/huage/public_html |mail -s "Moving Successful" huage@gmail.com -- -f admin@google.com -F "The Admin of Google"

      发送一封以"Moving Successful"为主题、以"du -sh /home/huage/public_html"输出内容为邮件正文、以admin@google.com为发件人且发件人的显示名称为"The Admin of Google"的邮件给huage@gmail.com

自动备份网站根目录

Auto backup up the root directory of website(自动备份网站根目录):

root@huage [~/huage]# cat /usr/local/bin/hua-backup
#!/bin/bash
HUA=/home/huage/
NAME=hua-`date +%Y%m%d`.tgz
cd $HUA
rm -rf public_html/bmz_cache/*
echo "Cache is cleaned."
tar -zcvf $NAME public_html
echo "The backuping process is successfully done."
mail admin@huage.com -s "Backuping HUA is successfully done" < /root/huage/backup
echo "Everything is successful completion."
exit 0

然后使用"crontab -e"命令编辑root用户的crontab文件,加入如下一行:
"0 0 * * 0 /usr/local/bin/hua-backup >/dev/null 2>&1"
,然后保存文件到"/var/spool/cron/root"就行了。

注:虽然hua-backup脚本放在系统PATH路径中,但/etc/crontab单独定义了"PATH=/sbin:/bin:/usr/sbin:/usr/bin",所以此处的脚步文件仍然要写完整路径,否则计划不能成功执行。

2011年9月27日星期二

你们在哪里

西摩.西蒙斯:多年以后 他们会问我们 
                   他们占领这星球的时候 你们在哪里?
                   我们回答说
                   我们只是袖手旁观
                                              ——变形金刚3 

海盗湾宣言

      请记住,我们是关不掉的!各位,你们可能已经听说了,那些家伙又一次试图关闭我们。他们不会成功的。我们的带宽提供商是好人,所以我们决定把网站搬个地方,不让他们为难。海盗湾是不会沉没的。只要我们愿意,它将永远航行在互联网上。请记住这一点。自从2003年海盗湾上线以来,他们从我们这里得到的,只是一次又一次的失败。

      只要这个世界还有一个热爱自由的人存在,我们就不会下线。

      那些与互联网为敌的人们,你们是不会成功的。(多么激动人心的宣言啊!
    
                                                                                                                ——海盗湾
  

我们被判有罪

我们被判有罪,这真是相当令人惊奇的事,他们也可以罚款我们一亿美元,这无关紧要,因为我们不能也不会做出赔偿。

                          ——海盗湾的四名创始人之一彼得·桑德·科尔米索皮(Peter Sunde Kolmisoppi)

2011年9月26日星期一

Firefox经典实用扩展

1.Adblock Plus
有了Adblock Plus,广告已成往事

2.AutoProxy
翻墙必备,翻墙于无形,撞墙已成往事

3.Domain Hammer SEO Analysis
简洁实用的SEO工具

4.DownThemAll!
下载必备,支持断点续传,同时也能限速

5.Firebug
给力的Web开发工具,也可以用来查看访问一个网址所请求的所有HTTP Request

6.FireGestures
鼠标手势,好网民必备

7.Flagfox
显示当前网站服务器所在的地理位置和域名所属区域

8.Forecastfox
一个非常好的显示天气的扩展

9.IE Tab 2
使Firefox也能使用IE核心浏览一些必需用IE的网站(如网银)

10.LastPass
最好的密码管理工具,没有之一

11.ReminderFox
好用的事件提醒扩展

12.Tab Mix Plus(Firefox Add-ons中已经搜索不到了)
增强标签浏览体验

13.Tamper Data
追踪所有HTTP Request

14.Xmarks
最好的书签同步扩展,没有之一 

用screen命令来管理远程会话

screen -S http:创建一个名为http的会话
screen -ls:列出当前的所有screen会话
screen -d:分离所有会话,切换到Shell控制台
screen -d http:将名为http的会话分离出来
screen -r http:恢复一个状态为Detached的会话
screen -d -r http:先将一个状态为Attached的会话Detached掉,然后再Attached
screen -x   Attach to a not detached screen session. (Multi display mode).
screen -x http:将一个名为http且状态为Attached的screen会话Attach,之后所有处于http screen会话中的虚拟终端的所有操作都将同步,操作任何一个http screen会话,其他的http screen会话会显示相同的操作(适用于一人操作,其他人观看学习)

screen程序的快捷键:
Ctrl-a d:分离当前screen会话(先按住Ctrl,然后依次按a、d键),退到Shell控制台
exit:退出当前的screen终端

Shell Script的基本格式

1.开始行一般是命令解释器,由#!+解释器的路径构成,Shell脚本的命令解释器一般为bash,即/bin/bash,所以Bash Shell脚本的第一行一般为#!/bin/bash;

2.结束行一般是exit 0;

注:在linux的Shell脚本中"#!"是一个双字节的magic number,而在某些BSD系统中,其脚本开始行是由"#! /bin/sh"构成,即"!"感叹号后面加了个空格,然后再加脚本解释器的路径,在这些系统中"#! "是一个4字节的magic number。