再度转移

April 3rd, 2008

盘古网络前几天停了我的虚拟主机帐号,理由是我没有备案,然而我在miibeian.gov.cn上却发现不能备案新的网站,05年时我曾经备案过自己的第一个独立blog,虽然那个域名早已经不用了。无奈之下,只好将techpush.com和thinkinglog.info再度迁移到国外的主机上,早知如此,就不“回国”了。。。

又和谐了

March 16th, 2008

单位消息,youtube.com在大陆又被封了(我为什么要说“又”呢?),前一段时间youtube曾经短暂的不能访问,但很快就好了,这次不知道是暂时性的还是永久性的(如wikipedia),联想到最近的某某大会以及西*藏*事件,被封的原因不难猜测,也好,用金玉米的话说就是:

See no evil, hear no evil…

Microsoft Office Live

March 4th, 2008

微软的在线Office服务已经正式开放了,但很可惜,我用的是Linux+Firefox,该服务并不支持,所以我不得不对微软说:去你妈的吧,老子不用了!继续Google Docs

blog的站外备份

March 3rd, 2008

对于大多数Wordpress用户而言,blog的备份是通过使用Wordpress Databackup这样的插件或者直接利用mysql备份来完成的,现在一个叫作Jonas Lejon、来自瑞典的小伙子创建了一个blog备份服务网站:Blogbackupr,该网站可以帮助blogger在站外备份自己blog的文章,并且支持所有具备RSS输出功能的blog服务(这基本涵盖了所有blog类型),同时对于Wordpress.com、blogger.com上的blog以及使用Wordpress搭建的blog还支持备份后的自动恢复(提醒一下:如果是后者,备份和恢复需要用户提供blog的帐号和密码),不得不说Lejon的创意不错,特别是对非Wordpress用户,有兴趣的朋友不妨试试看。

blogbackupr

看看你的主机上还有谁

January 29th, 2008

yougetsignal.com上提供了一系列的web工具,其中一个可以查看你的网站所在的服务器上还有其他哪些站点,这对于使用虚拟主机的朋友会很有用,看看在同一台服务器上除了你之外还有谁,借此可以认识不少朋友,毕竟都是一个战壕里的:)

yougetsignal

Wordpress的Category not updated问题

January 28th, 2008

当在wordpress中更改category的名称和slug时,有时会遇到无法更新的问题,提示“category not updated“,这时你需要检查一下是否slug有重名的情况,一般都是由于这个原因造成的,其实wordpress应该明确提示类别重名的信息才对。

备忘:在Slicehost VPS上安装Nginx+Fastcgi+eAccelerator+Zend Optimizer

January 27th, 2008

使用Slicehost的VPS(256M Slice)有一个月了,但相对国外的共享虚拟主机(比如我此前所用的Dreamhost)并没有感觉到速度上的优势,除了Wordpress本身性能较差外,恐怕与我并未对VPS做性能优化有关,因为Slicehost的VPS主机给了用户完全的操作权限,这意味着你可以随心所欲地安装软件、更改设置,但同时你也不再享有服务商事先做好各种的系统优化,比如安装Zend Optimizer--现在这些事情必须由你自己来完成。所以,作为一个半吊子Linux用户,我只好借助Google边查边干,所幸,整个过程还算顺利,目前在我的VPS上安装了Nginx、Fastcgi、eAccelerator和Zend Optimizer,Nginx+Fastcgi用以替换Apache,Zend Optimizer用来加速PHP性能,eAccelerator则利用缓存提高站点性能,经过这番优化,网站速度的确比以前大有改观,此文是整个安装过程的备忘,由于我选用的Linux发行版为Debian ETCH,所以在其他Linux上可能会有些不同,应酌情调整。

在安装Nginx之前,先装好Fastcgi:

Nginx是俄罗斯出品的一款Web服务器软件,相比Apache更加小巧,占用资源更少,速度更快,在我这台只有256M内存的VPS上,显然Nginx更适合.

  • 安装fastcgi
  • sudo apt-get install php5-cgi libfcgi0c2

  • 下载Fastcgi的执行脚本:
  • cd /etc/init.d/
    sudo wget -O php-fastcgi http://techpush.com/wp-content/uploads/php-fastcgiinit.txt #php-fastcgi也可改为其他名字

  • 给php-fastcgi加上执行权限
  • sudo chmod +x php-fastcgi

  • 下载fastcgi的配置文件:
  • cd /etc/default/
    sudo wget -O php-fastcgi http://techpush.com/wp-content/uploads/php-fastcgidefault.txt

  • 将php-fastcgi这个执行脚本添加的系统的启动服务中:
  • sudo update-rc.d php-fastcgi defaults 19 21

  • 现在尝试启动fastcgi:
  • sudo invoke-rc.d php-fastcgi start(或者sudo /etc/init.d/php-fastcgi start)

  • 正常情况下,fastcgi应该成功启动了,可以用ps -aux查看是否有php-cgi进程,如果你更改了php.ini,必须重启fastcgi。
  • 注意: 最好将php.ini中的memory_limit调大,否则可能会遇到内存不够的情况。

安装Nginx:

Debian或者Ubuntu的源中有nginx,但版本比较老了,所以还是从官方网站上下载最新版本安装,当然这需要编译才行

  • 安装编译nginx所需的依赖环境:
  • sudo apt-get install zlib1g-dev libpcre3-dev libssl-dev libgcrypt11-dev

  • 下载最新版本的nginx(当前最新稳定版为0.5.35):
  • cd ~/src
    wget -c http://sysoev.ru/nginx/nginx-0.5.35.tar.gz

  • 编译安装:
  • tar zxvf nginx-0.5.35.tar.gz
    ./configure –sbin-path=/usr/sbin/nginx –conf-path=/etc/nginx/nginx.conf –pid-path=/var/run/nginx.pid –error-log-path=/var/log/nginx/error.log –http-log-path=/var/log/nginx/access.log –user=www-data –group=www-data –with-http_ssl_module –with-http_stub_status_module –with-http_realip_module –with-http_addition_module –with-http_sub_module –with-http_dav_module –with-http_flv_module –http-client-body-temp-path=/var/cache/nginx/client_body_temp –http-proxy-temp-path=/var/cache/nginx/proxy_temp –http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp –with-sha1=/usr/lib #此处的各项配置可根据你自己的实际需要来确定
    make
    sudo make install
    sudo mkdir /var/cache/nginx
    sudo chown www-data:www-data /var/cache/nginx

  • 安装nginx的执行脚本:
  • cd /etc/init.d/
    sudo wget -O nginx http://techpush.com/wp-content/uploads/nginxinit.txt
    sudo chmod +x nginx
    sudo update-rc.d nginx defaults

  • 使nginx支持fastcgi:
  • cd /etc/nginx
    sudo wget -O fastcgi_params http://techpush.com/wp-content/uploads/fastcgi_params.txt

  • 修改nginx的配置:
  • 如果你是严格按照上述流程操作的,那么nginx的配置文件应该在/etc/nginx/目录下,使用一个文本编辑器编辑nginx.conf
    sudo vi nginx.conf
    具体的配置方法可以参考官方wiki,或者我的配置示例文件
    这里需要做说明的有两点:
    虚拟主机的配置:

    server {

    listen 80;
    server_name www.domain1.com;
    rewrite ^/(.*) http://domain1.com permanent;

    }

    server {

    listen 80;
    server_name domain1.com;

    access_log /home/demo/public_html/domain1.com/logs/access.log;
    error_log /home/demo/public_html/domain1.com/logs/error.log;

    location / {

    root /home/demo/public_html/domain1.com/public/;
    index index.html index.php;

    }

    }

    由于nginx不支持apache的rewrite规则(.htaccess),因此对于Wordpress用户,如果想使用简洁的永久链接格式,需要在虚拟主机配置段中加入如下语句:

    location / {
    index index.php index.html;
    if (!-e $request_filename) {
    rewrite ^/(.+)$ /blog/index.php?q=$1 last;
    }
    }

  • 配置完毕后,启动nginx
  • sudo invoke-rc.d nginx start

    下次更改nginx的配置,可以不用重启nginx而使配置生效(这点比apache强):

    sudo kill -HUP `cat /var/run/nginx.pid`

安装Zend Optimizer

安装Zend Optimizer最为简单,到Zend官方网站下载相应CPU的版本,解压后运行./install.sh(如果你是通过远程终端安装,则运行./install-tty)按照屏幕提示操作即可,注意php.ini文件的位置在/etc/php5/cgi/目录中。

安装eAccelerator

http://bart.eaccelerator.net/source/获取源代码,最新版本为0.9.5.2

    编译eAccelerator需要autoconf,automake,没有的话自己先安装一下

  • 编译安装:
  • phpize
    ./configure
    make
    sudo make install

  • 完成后,手动编辑php.ini文件,在最后加上如下语句:
  • zend_extension=”/usr/lib/php5/20060613/eaccelerator.so”
    eaccelerator.shm_size=”16″
    eaccelerator.cache_dir=”/tmp/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″

    注意eaccelerator.so文件的位置要写对,另外要建立eaccelerator目录:

    sudo mkdir /tmp/eaccelerator
    sudo chmod 0777 /tmp/eaccelerator

  • 重启fastcgi:
  • sudo invoke-rc.d php-fastcgi restart

  • 对于wordpress用户,可以开启wordpress自己的cache功能提高性能:
  • 编辑wp-config.php,加上一句:

    // Enable the WordPress Object Cache:
    define(ENABLE_CACHE, true);

    在wp-content目录下建立cache文件夹并赋予777权限

    mkdir ./wp-content/cache
    chmod 0777 ./wp-content/cache

至此大功告成!

本文参考了:
nginx + PHP + FastCGI:轻型网页伺服器« 豆腐!
eAccelerator的安装和性能比较
wordpress在nginx下的rewrite设置

空间转移到盘古网络

January 25th, 2008

尽管还有2个月才到期,但我已经将techpush.com从Dreamhost转移到了盘古网络和Wordpress中文团队所合作推出的专业Wordpress博客主机上,每年200元人民币,很便宜了,速度目前来说我也比较满意,不过DH的域名解析似乎还不太稳定,有待观察。

清理主题文件,加速Wordpress

January 23rd, 2008

Wordpress性能差、速度慢是出了名的,加速Wordpress除了安装一些缓存/静态化插件,例如WP-CacheWP-Super-CacheCos-Html-Cache,还可以通过清理主题文件中的一些数据库查询语句,减少Http请求次数,达到优化的目的。

Wordpress主题文件中经常会用到的查询语句主要有以下几个,这些语句完全可以去除或转化为静态方式而无须访问数据库 :

<html xmlns=”http://www.w3.org/1999/xhtml” <?php language_attributes() ?>> 转化为
<html lang=”zh-CN dir=”ltr xmlns=”http://www.w3.org/1999/xhtml>

<meta http-equiv=”content-type” content=”<?php bloginfo(’html_type’) ?>; charset=<?php bloginfo(’charset’) ?>” /> 转化为
<meta content=”text/html; charset=UTF-8 http-equiv=”content-type/>

<meta name=”description” content=”<?php bloginfo(’description’) ?>” />转化为
<meta name=”description” content=”这里直接输入你的博客简介” />

<meta name=”generator” content=”WordPress <?php bloginfo(’version’) ?>” /> 这句可以删除

<link rel=”stylesheet” type=”text/css” href=”<?php bloginfo(’stylesheet_url’); ?>” /> 直接写出style.css文件的链接地址

<link rel=”alternate” type=”application/rss+xml” href=”<?php bloginfo(’rss2_url’) ?>”  /> 直接写出RSS的链接地址

<link rel=”pingback” href=”<?php bloginfo(’pingback_url’) ?>” /> 直接写出pingback的链接地址

以此类推,凡是可以变为静态方式的地方都直接写出具体内容,这些语句大都存在于header.php和footer.php文件中,通过这番清理,大概可以减少10多次的数据库查询。

想进一步优化Wordpress的朋友还可以参考下面两篇文章介绍的方法 : 《优化Wordpress-wp终极优化手册》、《加快WordPress的页面生成和载入速度》。

注 : 本文参考了Speed up and clean up your WordPress!

在Firefox侧边栏打开Google Calendar

January 22nd, 2008

最近打算好好利用一下Google Calendar来安排自己的生活和工作,但它毕竟是在线服务,在访问上要麻烦些,有两种办法可以更快捷地管理自己的Calendar,一种是利用Mozilla推出的Prism服务,为Google Calendar建立一个桌面版,具体操作请参考Mozilla的说明;另一种方法是在Firefox的侧边栏直接管理Calendar,操作步骤如下:

  1. 添加这个链接到收藏夹:Google Calendar Sidebar
  2. 到收藏夹,右键点击刚才加入的链接,选择”Properties”
  3. 在弹出窗口中选中”Load this bookmark in sidebar”,确定
  4. 点击该链接即可在侧边栏载入Google Calendar,现在使用你的帐号登录进行管理吧

screenshot5.png