» Archive for October, 2006

UTF-8,Ruby on Rails under Ubuntu

Friday, October 20th, 2006 by rubypdf

I installed Ruby on Rails under Ubuntu(from /var/lib/locales/supported.d/local, I know, my default charset is en_US.UTF-8 UTF-8), and create a demo, by default, mysql (table type is MyISAM)supports UTF-8. But when I input Chinese character and save to database, the output on the web is UTF-8 code, not what I want, why? After searching, I got the answer , I need modify app/controller/application.rb just like this:

class ApplicationController < ActionController::Base
before_filter :set_charset

def set_charset
@headers["Content-Type"] = "text/html; charset=utf-8"
end
end

P.S.
My environment:
Server:
OS: Ubuntu 6.06.1 on Vmware(default charset is en_US.UTF-8 UTF-8)
Ruby: 1.8.4
Rails: 1.1.6
Mysql: 5.0.2
Mongrel: 0.3.13.4
Client:
Firefox: 1.5.0.6
IE: 6.0

ADSL & Ubuntu Desktop 6.06.1 LiveCD

Thursday, October 19th, 2006 by rubypdf

I try Ubuntu Desktop LiveCD at home, and post my first blog at Ubuntu.
My PC is very old (bought at 2001), CPU is Celeron 700, Memory is 512M.
I use ADSL, so before left office, I have gotten how to use adsl in Ubuntu, it is very easy, just run
pppoeconf
and type the name/password.
it is no bad.

Vmware Workstation虚拟机下安装Ubuntu Server

Thursday, October 19th, 2006 by rubypdf

因为工作的需要,开始学习Linux,看到网上Ubuntu比较火,就选择从Ubuntu开始学习Linux。
开始安装之前,先对Ubuntu做个简单的介绍(摘自Ubuntu中文网)

Ubuntu 是一个完全基于 Linux 的操作系统,它不但免费,而且有专业人员和业余爱好者共同为其提供技术支持。爱好者的数量是很大的,我们希望你也能加入!
Ubuntu 爱好者社群背后的理念是“Ubuntu 哲学”:软件应该是免费的,世界各地的用户都应能够用上以他们自己的语言为界面语言的软件,他们能力上的缺失也不应该成为使用软件的障碍。此外,他们也应该拥有按照个人需要任意定制和修改软件的自由。
这些自由令 Ubuntu 与商业软件有着根本性的不同:你不但可以免费获得软件,而且还拥有依个人需要修改软件的自由。
Ubuntu 既适合服务器、也适合个人家用。目前的 Ubuntu 版本支持 PC(Intel x86)、64-bit PC(AMD 64)和PowerPC(苹果 iBook 和 Powerbook,G4 和 G5)结构。
Ubuntu 包括超过一万六千种软件,但其核心桌面组件的大小不超过一张 CD 光盘的容量。Ubuntu 可以胜任所有常规桌面工作,从文字处理、试算表到网络服务器到编程工具。详情查看 Ubuntu 于桌面 Ubuntu 于服务器.

我的操作系统环境是Windows XP
准备工作:
安装Vmware,这个没有什么特别的,这里就不介绍了。
获得Ubuntu Server:
通过Shipit - Ubuntu 光盘发行系统免费订购光盘版,不过因为需要4-6个星期,所以如果你的带宽还可以接收的话,建议还是自己下载Ubuntu Server最新版本吧,速度还是很快的。
安装Ubuntu Server:

  • 运行Vmware
  • 创建新的Virtual Machine
  • Virtual Machine Configuration选Typical
  • Guest Operation System选Linux,Version选Ubuntu
  • Network connection选Use bridged networking
  • Disk capacity你看着办吧,我选的是2G。
  • Start the Virtual machine
  • 安装时选择LAMP Server版本(这个自带了Apache2,PHP5,Perl5)
  • 接下来的工作就不多说了,语言版本建议选择英文,不然安装好的操作系统有乱码。

安装成功后,我做了如下工作:

  • 修改root的密码,我喜欢在root环境下工作,这样就没有必要每次都在命令前面写sudo了
  • sudo passwd root
    密码自己设。

  • 备份并更新sources.list
  • cd /etc/apt
    mv sources.list sources.list.1
    wget http://blog.rubypdf.com/wp-download/sources.list
    apt-get update

  • 为了便于远程控制(Vmware下使用很不方便),安装sshd
  • apt-get install openssh-server
    下载windows版本的ssh,我选择的是putty,这样就可以方便地在windows环境下操作Ubuntu了。

  • 另外推荐一款web版本的管理程序webmin
  • 下载webmin1.300
    安装:dpkg --install webmin_1.300_all.deb
    自动安装成功后,就可以通过http://localhost:10000/进行管理了(默认用户名和密码分别是root/password)。