分类目录归档:站长文档

全部链接在新窗口中打开

上网提速入口中有很多站外链接, 要让这些链接都在浏览器新窗口中打开, 可以在每个<a>tag中加入target="_blank"标识, 但如果链接很多, 就会有非常大量的重复代码. 其实可以在head中加入<base target="_blank"> tag,让页面内所有链接(包括form提交)都指向新的浏览器窗口, 让代码更加简洁.

发表在 站长文档 | 一条评论

there is no attribute “onClick”

上网加速入口的代码在W3C标签检验器检查时发现了 there is no attribute “onClick”错误. 通过搜索才发现原来XHTML 1.0 Transitional标准不允许attribute中包含大写字母, 将代码中<li id=”search1_tab” class=”btn1″  onClick=”setTab(‘search’,'search1′)”>Google</li>中的”onClick改成onclick后才通过. 类似常见的attribute还有onMouseOver,onFocus等, 虽然大写的好看一些, 但为了通过W3C检验只能改成小写.  当然如果你使用的是html标准的代码(如百度和google使用的代码), 大小写的属性不会带来问题.

发表在 站长文档 | 留下评论

再读李想

这两天一直在读李想的blog和其它想关的文章.

李想应该是所有站长中把执行做得最好的一位.
他网站的成功, 来源于他对 目标-执行-成果 这一简单结构的信仰. 为了达到目标, 他会去做, 而且全力以赴!

读了这些文章, 到现在明白了三点:
1.不一定要当天才. 不一定要做最前卫的事情. 李想做的都是已经有人在做的网站. 但他靠自己的努力把这些网站做得更大.
2.达到目标须要坚持不懈的努力执行. 学习完成目标的能力, 在无数方法中找到真正可以下手的方法.
3.网站须要流量, 特别是刚开始的时候.
和流量相关的关键词: 美女, 免费, 下载. 第一数字平台泡泡网可以做娱乐, 因为娱乐的人流有可能会关注数码产品. 把流量带到网站了, 就迈出了第一步!!

发表在 成败几何, 站长文档 | 留下评论

在ubuntu6.06上安装apache2.2X + mysql + PHP + Ruby on Rails + Mongrel Cluster

到现在已经安装了好几次服务器了。总结出了一些经验,在这里和大家分享一下。

说明
我使用的linux是ubuntu 6.06 server cd版本。选第一项安装最基本的系统文件,不自动安装LAMP服务,因为ubuntu 6.06自带的apache2是2.0X的,不适合做mongrel cluster的前台,安装自带的apache2.0X之后卸载它比较麻烦,所以干脆不要自动安装LAMP服务,而手动安装apache2.2。

ubuntu 6.06 server cd的基本安装只安装系统必要文件,不安装其它服务,甚至连ssh都要手动:
sudo apt-get install ssh
安装,请大家注意要安装上ssh才能远程访问。

安装准备

加本地ubuntu源,加快下载速度
sudo nano /etc/apt/sources.list
加入速度比较快的源,如cn99的:
deb http://ubuntu.cn99.com/ubuntu/ dapper main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ dapper-updates main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ dapper-security main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ dapper-backports main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu-cn/ dapper main restricted universe multiverse

更新系统
sudo apt-get update
sudo apt-get dist-upgrade

准备必要文件
sudo apt-get install build-essential

创建下载源码文件夹

cd ~
mkdir src
cd src

安装zlib
wget http://www.zlib.net/zlib-1.2.3.tar.gz
tar xvfz zlib-1.2.3.tar.gz
cd zlib-1.2.3/
./configure –prefix=/usr/local
make
sudo make install
cd ..

安装Apache2.2
下载安装apche2.2
sudo dpkg –purge apache apache2
wget http://apache.rmplc.co.uk/httpd/httpd-2.2.4.tar.gz
tar xvfz httpd-2.2.4.tar.gz
cd httpd-2.2.4/
./configure –prefix=/usr/local/apache2 –enable-mods-shared=all –enable-deflate –enable-proxy –enable-proxy-balancer –enable-proxy-http
make
sudo make install
cd ..

测试apache2.2
启动apache2.2
sudo /usr/local/apache2/bin/apachectl start
访问测试
http://xxx.xxx.xxx.xxx(服务器IP)
停止apache2.2
sudo /usr/local/apache2/bin/apachectl stop

让apache2.2在系统启动时自动运行
sudo cp /usr/local/apache2/bin/apachectl /etc/init.d/apachectl
sudo chmod +x /etc/init.d/apachectl
sudo nano /etc/init.d/apachectl
修改文件,增加:
#!/bin/sh
#
# chkconfig: – 85 15
# description: Apache is a web server.
sudo /usr/sbin/update-rc.d apachectl defaults

增加apache用户,增强系统安全性
sudo adduser –system apache
sudo nano /usr/local/apache2/conf/httpd.conf
修改文件,将
User daemon
Group daemon
改成:
User apache
Group nogroup

PHP模块安装
如果你不想在服务器中使用php网站,直接跳过本节
下载安装php4(因为我的服务器只是用来运行早点的php程序,php4够用了)
sudo apt-get install flex
wget http://au2.php.net/get/php-4.4.7.tar.gz/from/cn.php.net/mirror
tar xvfz php-4.4.7.tar.gz
cd php-4.4.7
./configure –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql –disable-cgi –with-zlib –with-gettext
make
sudo make install
sudo cp php.ini-dist /usr/local/lib/php.ini
cd ..

设置php
sudo nano /usr/local/apache2/conf/httpd.conf
修改文件,
增加(如果已经加上就不用了)
LoadModule php4_module        modules/libphp4.so

AddType application/x-gzip .gz .tgz
之后增加:
AddType application/x-httpd-php .php
修改
DirectoryIndex index.html

DirectoryIndex index.html index.php default.php

测试php
在网站目录(默认/usr/local/apache2/hdocs/)创建test.php文件,内容
<?php
phpinfo();
?>
然后访问:
http://xxx.xxx.xxx.xxx/test.php
应显示系统php模块信息。

安装MySQL
sudo apt-get install mysql-server mysql-client

修改root用户密码
sudo mysqladmin -u root password 新密码
sudo mysqladmin -u root -h localhost password 新密码

如果要进行其它基本设置,修改/etc/mysql/my.cnf文件。

mysql数据备份与恢复
备份
mysqldump -u 用户名 -p 数据库名 > 备份文件名
恢复
mysql -u 用户名 -p 数据库名 < 备份文件名

安装ruby1.8.6
ubuntu 6.06自带的ruby是1.8.4, 因为在使用1.8.4版的ruby时我遇到mongrel提示ruby版本过旧的问题,所以自行编译安装1.8.6版的ruby.

安装ruby1.8.6
wget http://rubyforge.org/frs/download.php/18421/ruby-1.8.6.tar.gz
sudo tar -xvf ruby-1.8.6.tar.gz
cd ruby-1.8.6
./configure
make test
make
sudo make install

安装ruby1.8.6后在运行script/console时遇到了
      /usr/local/lib/ruby/1.8/irb/completion.rb:10:in `require’:
      no such file to load — readline (LoadError)
错误,解决办法是
安装readline

sudo apt-get install libncurses5-dev libreadline5-dev
cd ext/readline
ruby extconf.rb
make
sudo make install
cd ../../..

ruby gems安装
sudo wget http://rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz
tar -xvzf rubygems-0.9.0.tgz
cd rubygems-0.9.0
sudo ruby setup.rb
sudo gem update –system
cd ..

安装libmysql
sudo apt-get install libmysql-ruby libmysql-ruby1.8 libruby1.8
安装好这个后
irb
irb(main):001:0> require ‘mysql’
还是提示出错,于是我安装mysql gem
sudo gem install mysql
但安装出错。。。。
奇怪的是后来发现RoR网站可以正常运行,没有问题。网友如果解决了这个问题,请留言一下。

安装Rails
sudo gem install rails –include-dependencies
注意linux平台安装过程要选带ruby的rails。

安装Mongrel Cluster
sudo gem install daemons gem_plugin mongrel mongrel_cluster –include-dependencies
同上,linux平台安装过程要选带ruby的程序。

增加一个mongrel用户,增强系统安全性
sudo adduser mongrel
将网站文件归到这个用户
sudo chown -R mongrel:mongrel /www/app
上面/www/app为RoR程序目录

创建mongrel群

sudo mongrel_rails cluster::configure -e production -p 8000 -N 3 -c /www/app -a 127.0.0.1 –user mongrel –group mongrel
其中/www/app为RoR程序目录
8000为mongrel群开始端口
-N 3中的3为mongrel群中的mongrel服务器数量,3表示3个mongrel组成这个群,群使用的端口从8000开始,8000,8001,8002三个。
上面的命令将会在RoR程序/www/app/config目录下生成mongrel_cluster.yml文件。
将新文件归到mongrel用户
sudo chown -R mongrel:mongrel /www/app/config/mongrel_cluster.yml

启动mongrel群测试
在当前RoR程序根目录(如上面的/www/app)下运行
sudo mongrel_rails cluster::start

让mongrel cluster在系统启动时自动运行
sudo mkdir /etc/mongrel_cluster
sudo ln -s /www/app/config/mongrel_cluster.yml /etc/mongrel_cluster/app.yml
sudo cp /usr/local/lib/ruby/gems/1.8/gems/mongrel_cluster-1.0.2/resources/mongrel_cluster /etc/init.d/
上面的/usr/local/lib/ruby/gems/1.8/gems/mongrel_cluster-1.0.2/是mongrel gem所在的目录。
修改mongrel_cluster文件
sudo nano /etc/init.d/mongrel_cluster
在CONF_DIR之上加入一行:
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local:/usr/local/sbin:/usr/local/bin
解决一些情况下因为mongrel找不到程序而不能在系统启动时自动运行的问题。
sudo chmod +x /etc/init.d/mongrel_cluster
sudo /usr/sbin/update-rc.d -f mongrel_cluster defaults
手动修改mongrel cluster的启动顺序,让它在最后运行,解决有可能发生的另一些启动问题。
sudo mv /etc/rc2.d/S20mongrel_cluster /etc/rc2.d/S99mongrel_cluster

让Apache成为mongrel的前台
修改httpd.conf文件(默认在/usr/local/apache2/conf/目录下)
最后加入:
NameVirtualHost 192.168.1.1
<Proxy balancer://cslog_cluster>
  BalancerMember http://127.0.0.1:8000
  BalancerMember http://127.0.0.1:8001
  BalancerMember http://127.0.0.1:8002
</Proxy>

<VirtualHost 192.168.1.1>
    ServerName www.cslog.cn
    DocumentRoot /www/cslog/public
  RewriteEngine On
  RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
  RewriteCond %{SCRIPT_FILENAME} !maintenance.html
  RewriteRule ^.*$ /maintenance.html [L]
  # Rewrite index to check for static index.html
  RewriteRule ^/$ /index.html [QSA]
  # Rewrite to check for Rails cached pages with .html extentions
  RewriteRule ^([^.]+)$ $1.html [QSA]
  # All dynamic requests get sent to the cluster
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule ^/(.*)$ balancer://cslog_cluster%{REQUEST_URI} [P,QSA,L]
  # Deflate for clients that support it.
  AddOutputFilterByType DEFLATE text/html text/plain text/xml
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Error and access logs.
  ErrorLog logs/cslog_error_log
  CustomLog logs/cslog_access_log combined
</VirtualHost>
文件中的cslog_cluster可以自己命名,但要对应。
8000,8001,8002为mongrel群对应的端口。

总结
到这里,ubuntu6.06上的apache2.2, mysql, PHP, Ruby on Rails , Mongrel Cluster安装设置已经完成。下午一次全过程大概用了两个小时,如果写成脚本,应该可以系统自动安装,可以更快完成全过程。

发表在 Ruby on Rails, 站长文档 | 3 条评论

找一个网站流量统计系统

以前用过51yes在线统计,除了有一次感觉到它明显拖慢了网站速度,平时还是不错的。报告也很详细。
用Ruby on Rails后,我找到了两个相关的插件,SitealizerRail_stat,但两个都是在服务器上即时统计的,要用占用系统资源。于是想找个apache日志分析器。一开在google上找counter,结果找到了大量九十年代的东西,很让人怀旧。原来现在流行的关键词是 Log Analysis/Web Statistics。找是我找到了AWStats,这是个用perl语言编写的log免费分析器。从它的Demo来看报告还是比较详细的。基于货比三家的传统想法,又搜索了一会,找到了ClickTracks, 看了它的Flash Overview, 大开眼界!!! 原来现在的网站流量分析思想和技术已经达到了如此之高的境界。。。这样的软件只卖995美元真是物超所值!参观完了走人吧,现实点,再找个免费的。就在这时,Google出现了,Google Analytics!!! 我二话没说就注册了。这个和51yes几乎是一样的,这个比AWStats方便,不用安装。注册后我得到一段javascript代码,然后要做的就是把代码放到每个页面上,以后找个吉日登录Google Analytics页面查看流量。。。

从51yes转到了一圈,回到了原点,只不过换了个牌子。

发表在 站长文档 | 2 条评论

网站作为一个信息供给系统

就目前为止,我对网站作为一个信息供给系统的看法。
当然,网站不止于信息供给功能,人们还可以发布信息和交流信息。

信息供给系统是指一个能向用户提供有用信息的系统。
它是相对的。一个系统能提供的信息对一些用户有价值,对于其他用户可能没有价值。
信息供给系统必需满足两个条件:
1.有价值的信息在系统中存在;

2.用户可以通过某种实际可行的途径得到这部分信息。

信息供给系统的评价标准
对于一个用户,系统属于信息供给系统的条件下,评价它的标准:
1.取得信息的难度(技术难度,视线难度。。)
2.取得信息的用时
3.信息价值的大小,用户最后得到信息后对信息的满意度。信息的相关性,信息的准确度,信息的时效,信息的完整程度。。。

信息供给的途径
1.搜索
优点:直接,快速
缺点:要先得到关键词,很难控制相关性。

2.索引
优点:系统化,用户可以不知道关键词,通过大概的感觉找到信息;可以浏览,让用户得到一片信息,而不是一点
缺点:比较费时(但如果能顺利找到,用户应该不介意)
网页的分类,TAG,导航系统也可以看完一个索引系统。
要使用清晰准确易懂的关键词作为分类名。不要给用户任何“惊喜“
索引分类结构要合理,要让用户一眼能看出来他要的子分类藏哪一主分类之下。
一个终端类目下的条目不应该过多,过多的条目不方便挑选。
索引最好有合理排序功能,通过列表的条件关系,加速信息查找。

信息供给系统的最高目标:
立现你所需,不多,也不少。
立:速度快
现:不费力,主动“现”
你:个性化,针对性
所需:相关性
不多:无干扰信息,无不相关信息
不少:信息量完整。

发表在 信息处理, 站长文档 | 标签为 | 留下评论

Don't Make Me Think( Web Usability)

飞利浦 在广告中说科技应该像打开盒子一样简单.

Don't Make Me Think by Steve Krug
 
Don't Make Me Think!-the first law.
Self-evident,Obvious,Self-explanatory
 
What Make Us Think?
Names, Buttons,Search
Make a list.
 
1.名字要用最通俗的.
2.链接,按钮等元素要有明显特征.
3.查找等功能要傻瓜化.
4.多用通俗的图标代替文字.

The competition is always just one click away!
 
1.The task at hand
2.interests
3.Free,Sex, and our own name
 
IT is a good idea to assume that everything is visual noise until proven otherwise.

2005年12月4日

Don't Make Me Think note 2

Never take more than 3 clicks to get to any page of the site.
Users don't mind a lot of clicks as long as each click is painless and they have continued confidence that they're on the right track.
 
NAV for Windows 95/98 -it makes me think!
 
Omit needless words.
Vigorous writing is concise. A sentence should contain no unnecessary words, a paragraph no unnecessary sentences, for the same reason that a drawing should have no unnecessary lines and a machine no unnecessary parts.
happy  talk must die
instructions must die
 
Navigation
Searcher or Browser
 
Search ->Type a keyword -no needed
 
把LOGO,导航,帮助等不变的内容放到左边,不占用可用空间. 可用空间用来放内容和广告.
 
Every page needs a name
the name needs to be in the right place
 
TABs

2005年12月4日

Don't Make Me Think note 3

HOME PAGE
 
Show me what I'm looking for.
and what I'm not looking for.
 
Create a good impression
 
??????????????????????????????????
What is this?
What can I do here?
What do they have here?
Why should I be here-and not somewhere else?
 
Tagline: 没有围墙的大学
 
Where to start?
Here's where to start if I want to search.
Here's where to start if I want to browse.
Here's where to start if I want to sample their best stuff.

2005年12月13日

Don't Make Me Think note 4

does this pulldown,with these items and this wording in this context on this page create a good experience for most people who are likely to use this site?

and there's really only one way to answer that kind of question:testing.

ask for anyone to test the web, 1 error $6
<the End>

 2006年2月1日
 

发表在 站长文档 | 留下评论

Quick Tips Regarding Web Usability and User Testing note

We think of our site as great piece of art and literature and the user's reality is much closer to "billboard going by at 60 miles an hour."

Fact#1 We Don't Read, We Scan.

Fact#2 We Don't Consider all Options, We Go for What We Like.

Fact#3 We Don't Learn, We Guess.   
     let the instructions be done in a line of words.

Omit Needless Words.

Clear Visual Hierarchy
The more important something is, the more prominent it is.

In latest eye-tracking studies, users decide very quickly which parts of the page have useful info and almost never look at other parts.

Why I return?
High Quality content
Often updated
Minimal download time
Ease of use.
HOME

2005年12月4日

发表在 站长文档 | 留下评论

搞好网站的关键只有一个–实用性

不用太多名词,什么Web2.0,什么RSS,这些我都不懂.
做好网站我觉得最要紧的就是网站要有实用性.
实用性分两点:

一:网站要有用户想要的东西.
就是网站的内容,不是空洞的,不是华而不实的,而是网民他想要的.网民来你的网站是因为他有一种需要,而你的网站能满足他的需求,因此他需要你的网站,因此你的网站有必要存在.
 
二:网站要以最方便,快速的方式提供它的服务.
你的站上有网民要的东西,这是要件之一,你还要让网民能快速方便地找到他所要的服务.现在的网站不计其数,你要生存,你就必须让网民用得舒服.我今天又想到,简单也是种美,简单美.正如大多伟大的物理公式一样.
2005年11月10日 日记

发表在 站长文档 | 留下评论

XHTML Quick Reference

Basic XHTML Rules

    * 使用小写标签:
      <p class="introduction">Paragraph text</p>
    *使用双引号:
      <a href="calendar.php">
    *外部链接使用http://开头:
      <a href="http://www.cnn.com/";>Latest news.</a>
    * <br />,<img />等标签关闭前加一空格。:

      <img src="funnyface.jpg" alt="Me making a funny face." />
    * 标签要关闭:
      <h1>Welcome to English 106</h1>
    * 标签嵌套要顺序进行:

发表在 站长文档 | 留下评论