一、安装ubuntu
从官网下载wibi和合适的ubuntu版本,将下载的wibi和ubuntu放在同一目录下,断开网络,打开wibi即可
二、安装ruby, rails
1 、安装mysql
$sudo apt-get install mysql-server
// 期间要设置mysql 登录密码
$mysql -u root -p
// 输入密码登入mysql
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 64
Server version: 5.1.49-1ubuntu8.1 (Ubuntu)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
mysql> exit
Bye
2 、安装ruby
$sudo apt-get install build-essential ruby ri rdoc irb ruby-dev libmysql-ruby
// 确认是否安装成功
$ruby -v
ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-linux]
$ri -v
ri v1.0.1 – 20041108
$rdoc -v
RDoc V1.0.1 - 20041108
$irb -v
irb 0.9.5(05/04/13)
3 、安装rubygems
$sudo apt-get install rubygems
// 确认
$gem -v
1.3.7
4 、安装rails
$sudo apt-get install rails
// 确认
$rails -v
Rails 2.3.5
5 、$ rails -d mysql demo
create
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create config/initializers
create config/locales
create db
…........
$cd demo
$ruby script/server
=> Booting WEBrick
=> Rails 2.3.5 application starting on http://127.0.0.1:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-02-20 21:05:33] INFO WEBrick 1.3.1
[2011-02-20 21:05:33] INFO ruby 1.8.7 (2010-06-23) [i686-linux]
[2011-02-20 21:05:33] INFO WEBrick::HTTPServer#start: pid=6675 port=3000
打开http://127.0.0.1:3000 ,即可看到rails 欢迎画面
// 在终端中按键ctrl+c 即可退出服务器
6 、新建controller
$cd demo
$ruby script/generate controller say hello
//hello 为controller 中的action
$ruby script/server
打开http://127.0.0.1:3000 /say/hello ,会发现出错,因为还没有建数据库
7 、打开/demo/config/database.yml 文件,进行如下编辑
development:
adapter: mysql
encoding: utf8
reconnect: false
database: demo_development //database 名
pool: 5
username: root
password: *** // 密码
socket: /var/run/mysqld/mysqld.sock
8 、建数据库,之后也可以通过phpmyadmin 进行建库及其他数据库的操作
$mysql -u root -p
输入密码
>create database demo_development;
Query OK, 1 row affected (0.03 sec)
>use demo_development
Database changed
>exit
Bye
三、安装phpmyadmin
1 、安装apache2
$ sudo apt-get install apache2
// 提示安装成功后在浏览器中打开:http://localhost ,可以看到It works !说明安装成功!默认安装目录为:/etc/apache2 ,web 页目录:/var/www ,执行文件目录:/usr/sbin
2 、安装php5
$sudo apt-get install libapache2-mod-php5
$sudo apt-get install php5
3 、安装phpmyadmin
$sudo apt-get install phpmyadmin
// 默认安装在/usr/share 目录下, 复制到/var/www 目录下
$sudo mv /usr/share/phpmyadmin /var/www
// 重启apache
$sudo /usr/sbin/apache2ctl restart
4 、打开http://localhost/phpmyadmin ,用户名root 及刚设置的密码登录phpmyadmin