sudo apt-get install gcc
sudo apt-get install build-essential
sudo apt-get install gcc g++ build-essential libssl-dev libreadline5-dev zlib1g-dev linux-headers-generic
sudo apt-get install zlib1g-dev libssl-dev libreadline5-dev libxml2-dev
sudo apt-get install libcurl4-openssl-dev libssl-dev zlib1g-dev libreadline5-dev
sudo apt-get install curl git-core
sudo apt-get install bison build-essential zlib1g zlib1g-dev libssl-dev libreadline5-dev libxml2-dev subversion autoconf
mlzboy@mlzboy:~$ bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head ) % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 109 986 109 986 0 0 957 0 0:00:01 0:00:01 --:--:-- 4268 Initialized empty Git repository in /home/mlzboy/.rvm/src/rvm/.git/ remote: Counting objects: 16240, done. remote: Compressing objects: 100% (4166/4166), done. remote: Total 16240 (delta 10951), reused 15861 (delta 10649) Receiving objects: 100% (16240/16240), 2.91 MiB | 197 KiB/s, done. Resolving deltas: 100% (10951/10951), done. RVM: Shell scripts enabling management of multiple ruby environments. RTFM: http://rvm.beginrescueend.com/ HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net) Installing RVM to /home/mlzboy/.rvm/ Correct permissions for base binaries in /home/mlzboy/.rvm/bin... Copying manpages into place. Notes for Linux ( DISTRIB_ID=Ubuntu DISTRIB_RELEASE=10.04 DISTRIB_CODENAME=lucid DISTRIB_DESCRIPTION="Ubuntu 10.04.1 LTS" ) NOTE: 'ruby' represents Matz's Ruby Interpreter (MRI) (1.8.X, 1.9.X) This is the *original* / standard Ruby Language Interpreter 'ree' represents Ruby Enterprise Edition 'rbx' represents Rubinius bash >= 3.2 is required curl is required git is required (>= 1.7 recommended) patch is required (for ree and some ruby-head's). If you wish to install rbx and/or Ruby 1.9 head (MRI) (eg. 1.9.2-head), then you must install and use rvm 1.8.7 first. If you wish to have the 'pretty colors' again, set 'export rvm_pretty_print_flag=1' in ~/.rvmrc. dependencies: # For RVM rvm: bash curl git # For JRuby (if you wish to use it) you will need: jruby: aptitude install curl sun-java6-bin sun-java6-jre sun-java6-jdk # For Ruby (MRI & ree) you should install the following OS dependencies: ruby: aptitude install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf # In addition to ruby: dependencies, ruby-head: subversion # For IronRuby (if you wish to use it) you will need: ironruby: aptitude install curl mono-2.0-devel You must now complete the install by loading RVM in new shells. 1) Place the folowing line at the end of your shell's loading files (.bashrc or .bash_profile for bash and .zshrc for zsh), after all PATH/variable settings: [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session. You only need to add this line the first time you install rvm. 2) Ensure that there is no 'return' from inside the ~/.bashrc file, otherwise rvm may be prevented from working properly. This means that if you see something like: '[ -z "$PS1" ] && return' then you change this line to: if [[ -n "$PS1" ]] ; then # ... original content that was below the '&& return' line ... fi # <= be sure to close the if at the end of the .bashrc. # This is a good place to source rvm v v v [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session. EOF - This marks the end of the .bashrc file Be absolutely *sure* to REMOVE the '&& return'. If you wish to DRY up your config you can 'source ~/.bashrc' at the bottom of your .bash_profile. Placing all non-interactive (non login) items in the .bashrc, including the 'source' line above and any environment settings. 3) CLOSE THIS SHELL and open a new one in order to use rvm. WARNING: you have a 'return' statement in your ~/.bashrc This could cause some features of RVM to not work. This means that if you see something like: '[ -z "$PS1" ] && return' then you change this line to: if [[ -n "$PS1" ]] ; then # ... original content that was below the '&& return' line ... fi # <= be sure to close the if at the end of the .bashrc. # This is a good place to source rvm v v v [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session. EOF - This marks the end of the .bashrc file Even if you are using zsh you should still adjust the ~/.bashrc If you have any questions about this please visit #rvm on irc.freenode.net. Installation of RVM to /home/mlzboy/.rvm/ is complete. mlzboy, Thank you very much for using RVM! I sincerely hope that RVM helps to make your work both easier and more enjoyable. If you have any questions, issues and/or ideas for improvement please join#rvm on irc.freenode.net and let me know, note you must register (http://bit.ly/5mGjlm) and identify (/msg nickserv <nick> <pass>) to talk, this prevents spambots from ruining our day. My irc nickname is 'wayneeseguin' and I hang out in #rvm typically ~09:00-17:00EDT and again from ~21:00EDT-~23:00EDT If I do not respond right away, please hang around after asking your question, I will respond as soon as I am back. It is best to talk in #rvm itself as then other users can help out should I be offline. Be sure to get head often as rvm development happens fast, you can do this by running 'rvm get head' followed by 'rvm reload' or opening a new shell w⦿‿⦿t ~ Wayne mlzboy@mlzboy:~$
$ rvm notes
测试安装是否成功
- type rvm | head -n1
应输出
- rvm is a function
rvm list
rvm use ree --default
rvm install 1.9.2
1.9.2 > dict={}
=> {}
1.9.2 > dict["z"]=1
=> 1
1.9.2 > dict["a"]=2
ree 1.8.7和1.9.2执行上述两段代码的效果是不一样的,我的程序依赖于这项功能,所以不能使用ree,期待它升到1.9吧,不过得很长时间估计rvm install 1.9.2不需要sudo
关于gems
每个ruby解释器默认有一个名字为global的gemset,可以创建自己的gemset,通过rvm 1.8.7@gemset的方法来切换不同的gemset
gems之间可以进行同步,支持export/import/copy等操作
这个需要花费30分钟在我这里,放到海外估计会很快,在本地虚拟机编译更耗时在安装的时候 如果时间过长 或是出错可到~/.rvm/log下查看具体的日志mlzboy@mlzboy:~$ rvm listrvm rubies=> ree-1.8.7-2010.02 [ i386 ]ruby-1.9.2-p0 [ i386 ]mlzboy@mlzboy:~$ rvm 1.9.2 --defaultmlzboy@mlzboy:~$安装nginx
sudo apt-get install libpcre3-dev
sudo
apt-get
install
libpcre3 libpcre3-dev
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install openssl libssl-dev
sudo apt-get install build-essential libpcre3-dev libssl-dev libxslt-dev libgd2-xpm-dev libgeoip-dev zlib1g-dev
sudo apt-get install libpcre3 && \
sudo apt-get install zlib1g && \
sudo apt-get install libpcre3-dev && \
sudo apt-get install zlib1g-dev && \
sudo apt-get install libssl && \
sudo apt-get install libssl-dev
gem install -V passenger
rvmsudo passenger-install-nginx-module
选择自己编译安装
nginx安装路径/usr/local/nginx
外加参数
--with-http_flv_module --with-http_gzip_static_module
另外: 如果不想使用 passenger 自带脚本编译 nginx, 也可以手工编译 nginx 时加入 –add-module=’/home/jerry//opt/passenger/ext/nginx 参数, 来启用 passenger 模块. Nginx with Passenger support was successfully installed. The Nginx configuration file (/usr/local/nginx/conf/nginx.conf) must contain the correct configuration options in order for Phusion Passenger to function correctly. This installer has already modified the configuration file for you! The following configuration snippet was inserted: http { ... passenger_root /home/mlzboy/.rvm/gems/ruby-1.9.2-p0/gems/passenger-3.0.1; passenger_ruby /home/mlzboy/.rvm/wrappers/ruby-1.9.2-p0/ruby; ... } After you start Nginx, you are ready to deploy any number of Ruby on Rails applications on Nginx. Press ENTER to continue. mysql安装sudo apt-get install mysql-server-5.1
mysql配置记录 重启mysql服务 sudo service mysql restart 命令行 mysql -u root -p 命令行下查看utf8相关 show variables like 'character%'; show variables like '%time_zone%' 配置文件所在路径: sudo vi /etc/mysql/my.cnf 配置文件的更改以下两段 [client] default-character-set=utf8 port = 3306 socket = /var/run/mysqld/mysqld.sock [mysqld] default-character-set=utf8 init_connect='SET NAMES utf8' default-time-zone = '+8:00'
mysql> show variables like '%time_zone%'; 时区设置sudo tzselect
mlzboy@mlzboy:~$ sudo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
mlzboy@mlzboy:~$ sudo ntpdate cn.pool.ntp.org
10 Dec 14:04:43 ntpdate[1789]: step time server 114.80.81.1 offset 45.904550 sec
mlzboy@mlzboy:~$
mlzboy@mlzboy:~$ date
Fri Dec 10 14:04:45 CST 2010
mysql -u root -p
select now();
rvm gemset create b2c2
rvm 1.9.2@b2c2 --default
gem install rails#有bundler这里其实不需要了
sudo apt-get install imagemagick
paperclip插件需要这个库预先装,一般情况下已经装了
安装rails3的mysql2 gem需要sudo apt-get install libmysql-ruby libmysqlclient-dev
安装sqlite3-rubygem需要下面这个库的支持
这时候应该只需安装sqlite3-ruby,由于缺少sqlite3.h,因此我们需要先安装 ubuntu下的libsqlite3-dev包
- sudo apt-get install libsqlite3-dev
进入b2c2进行
gem install bundler
bundle install#其实由于使用了bundle install 不需要单独再安装gem install rails
目前还在开发环境的部署,转到生产,可能还有一些局部要调整的地方
rake db:drop:all#清除掉各种环境下的数据库
rake db:create
mysql -uroot -p
show databases;
rake db:schema:load
rvm wrapper 1.9.2@b2c2 passenger
解压缩每日备份的mysql
gunzip 2010-12-10.gz
使用rails console 进去后能看到具体的当前的版本
mlzboy@mlzboy:~/b2c2$ rails c
Loading development environment (Rails 3.0.1)
1.9.2@b2c2 >
mysql允许远程访问
在Ubuntu下MySQL缺省是只允许本地访问的,如果你要其他机器也能远程够访问这台Mysql数据库的话,需要设置一些东西,下面我们一步步地来:
一、配置文件的修改
1.#sudo vim /etc/mysql/my.conf
找到 bind-address = 127.0.0.1
注释掉这句话
二、Mysql数据库的修改
1) [root@etc etc]# mysql -u root -p
Enter password:
2)mysql> use mysql;
3)mysql> select host,user,password from user;
4)grant all privileges on *.* to root@192.168.1.100 identified by 'password'
注意: (1)192.168.15.101是欲连接到此Mysql数据库的客户端的IP地址,而不是Mysql数据库所在数据库服务器的IP地址,切记
(2)password就是Mysql数据库root用户的password,根据实际情况需要修改
mysql> grant all privileges on *.* to root@192.168.1.100 identified by 'password' -> ; Query OK, 0 rows affected (0.03 sec) mysql> select host,user,password from user; +---------------+------------------+-------------------------------------------+ | host | user | password | +---------------+------------------+-------------------------------------------+ | localhost | root | *4846ACFC90DAF95D62142025B486A2636DF4AD89 | | mlzboy | root | *4846ACFC90DAF95D62142025B486A2636DF4AD89 | | 127.0.0.1 | root | *4846ACFC90DAF95D62142025B486A2636DF4AD89 | | localhost | debian-sys-maint | *7FDB132DBC12819B1396F47F5404E76AA25AE519 | | 192.168.1.100 | root | *4846ACFC90DAF95D62142025B486A2636DF4AD89 | +---------------+------------------+-------------------------------------------+ 5 rows in set (0.00 sec) mysql> 注意,这里的mysql的用户名是root
查看 mysql版本信息,
mlzboy@mlzboy:~/b2c2$ mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 37 Server version: 5.1.41-3ubuntu12.7 (Ubuntu) Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> \s -------------- mysql Ver 14.14 Distrib 5.1.41, for debian-linux-gnu (i486) using readline 6.1 Connection id: 37 SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 5.1.41-3ubuntu12.7 (Ubuntu) Protocol version: 10 Connection: Localhost via UNIX socket Client characterset: utf8 Server characterset: utf8 UNIX socket: /var/run/mysqld/mysqld.sock Uptime: 3 min 19 sec Threads: 3 Questions: 128 Slow queries: 0 Opens: 99 Flush tables: 1 Open tables: 23 Queries per second avg: 0.643 --------------
mysql 查看时区
SELECT @@global.time_zone, @@session.time_zone;
查看时区
mysql> show variables like '%time_zone%';
删除数据库
drop database b2c2_development
直接从备份文件中导入完整的备份数据库
备份数据库
mysqldump --database b2c2_development -uroot -pzhoubt >20101210.sql
还原数据库mysql -uroot -pxxx <201010.sql再总结一下,这一块的做法现在数据库的这一块不用使用相关rake db:drop:all和rake db:create rake db:schema:load等工作了,使用mysql的每日备份,直接还原一个完整的数据库,立马可用。因为本身就有一些内置的配置型数据,不适合,从头添加
reference:
http://rvm.beginrescueend.com/integration/passenger/
http://ivice.javaeye.com/blog/730795
http://myrev.javaeye.com/blog/792845