2015年5月7日 星期四

rvm rubies installing

System : Ubuntu


RVM Ruby 安裝

# 先查詢可安裝的Ruby列表
  • rvm list known
# 安裝 Ruby
  • rvm install 2.1.4       //會跳出詢問要輸入 ubuntu password
       ====== 密碼詢問的提示 =======

       Updating system..ubuntu password required for 'apt-get --quiet --yes update':

       在這時後,輸入ubuntu的密碼後按下Enter就會開始安裝Ruby


#安裝 第二套 ruby
  • rvm install 2.0.0-p643

#查詢安裝狀態
  • rvm list
==========  rvm list 輸出結果  ========================

        ubuntu@ubuntu:~$ rvm list

        rvm rubies

        => ruby-2.0.0-p643 [ x86_64 ]
         * ruby-2.1.4 [ x86_64 ]

        # => - current
        # =* - current && default
        #  * - default


# 切換使用版本
  • rvm use 2.1.4   //current 會切換成 2.1.4

# 設定預設版本
  • rvm 2.1.4 --default

# 查詢目前機器Ruby資訊
  • rvm info






#如果想切回原本系統上的 Ruby  (已經使用了rvm 這個除非有特殊需求,不然就少用吧)

  • rvm system



rvm list command

System : Ubuntu

rvm is ruby version manager tools.


#列出已經安裝的Ruby版本。
  • rvm list rubies    or   rvm list

 #列出預設的ruby版本
  •  rvm list default

 #列出可以安裝的Ruby
  • rvm list known 

 #只列出已經安裝Ruby版本的字串,並不顯示當前使用版本,預設版本等資訊
  • rvm list strings

 
#列出預設Ruby版本,純版本字串
  • rvm list default string


參考資料料:

install RVM (Ubuntu)

System : Ubuntu

RVM (Ruby Version Manage)

讓你可以容易在多個Ruby版本中切換使用。


安裝:
  • gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

  •  \curl -sSL https://get.rvm.io | bash -s stable

  • 登出主機,重新登入。(實體主機可能需要重開機) or   source ~/.profile

  • rvm -v  //查看運作版本

PS:
  
      RVM 安裝需要 curl ,如果缺少
  • sudo apt-get install curl      //ubuntu
  • sduo brew install curl         //mac


      MAC沒有gpg命令需要:
  • sudo brew install gnupg
  • sudo brew install gnupg2

      RVM移除:
  • rvm implode
  • rm -rf ~/.rvm
   

     PS. 有時RVM會無法下載安裝,是因為gpg安裝出問題,此時將 ~/.gnupg 整個刪除之後再
  • gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
           另外有可能發生的是 ~/.gnupg的檔案群組與權限都不對也會造成無法安裝。



參考資料:
  • https://rvm.io/
  • 高見龍先生 RVM and Gemsets
  • http://ruby-on-rails-book.kejyun.com/install/install-rvm-ruby-rails.html

2015年5月6日 星期三

Redis install (Ubuntu apt-get install)

1. sudo apt-get update  //更新套件清單   
    安裝成功後,Redis會自動啟動


2. 查詢啟動:
        
ps aux | grep redis

redis  1505  0.0  0.6  39856  6692 ?        Ssl  18:17   0:00 /usr/bin/redis-server 127.0.0.1:6379      
ubuntu    1523  0.0  0.2  11752  2176 pts/0    S+   18:19   0:00 grep --color=auto redis
        
netstat -nlt | grep 6379

tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN

或是

sudo /etc/init.d/redis-server status

redis-server is running


3. Redis Configuration
  •  /etc/redis/redis.conf
4. Redis Shell
  • redis-cli
5. Shell TEST
  • 127.0.0.1:6379> ping
      PONG   //傳回PONG代表正常運作




 6. shutdown
  • 127.0.0.1:6379> SHUTDOWN

7. exit
  •  127.0.0.1:6379> exit

8. 啟動
  • redis-server

    or
  • redis-server  /etc/redis/redis.conf

小技巧:
    redis shell裏面可以使用tab鍵來自動完成指令。



參考:
  • apt-get 指令快查 

    http://blog.xuite.net/jyoutw/xtech/39380855-Ubuntu+%E6%96%87%E5%AD%97%E6%A8%A1%E5%BC%8F%E5%A5%97%E4%BB%B6%E7%AE%A1%E7%90%86%E6%8C%87%E4%BB%A4
  • redis非apt-get 安裝法

    http://redis.io/topics/quickstart
  • https://www.linode.com/docs/databases/redis/redis-on-ubuntu-12-04-precise-pangolin
  • http://redisdoc.com/server/shutdown.html
  • http://www.w3cschool.cc/redis/server-shutdown.html
  • 指令查詢
    http://redisdoc.com/

ubuntu mongoDB 3.0 install

  1. sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
  2. echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
  3. sudo apt-get update
  4. 安裝特定版本mongoDB

    sudo apt-get install -y mongodb-org=3.0.2 mongodb-org-server=3.0.2 mongodb-org-shell=3.0.2 mongodb-org-mongos=3.0.2 mongodb-org-tools=3.0.2
  5. 防止mongodb被 apt-get 升級。

    echo "mongodb-org hold" | sudo dpkg --set-selections
    echo "mongodb-org-server hold" | sudo dpkg --set-selections
    echo "mongodb-org-shell hold" | sudo dpkg --set-selections
    echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
    echo "mongodb-org-tools hold" | sudo dpkg --set-selections

  6. edit mongodb config

    sudo vim /etc/mongod.conf

    #這行是控管mongodb可以來訪的 IP,如果在aws上因為控管可由aws設定,所以可以註解掉,或是也可以用逗號區隔加入允許的ip,例如如 127.0.0.1,10.0.122.10
    bind_ip = 127.0.0.1

  7.  start mongo

    sudo mongod --fork --config /etc/mongod.conf
    # --fork 背景執行  --config 載入設定檔
  8. 進入mongo shell
    mongo

  9. 離開 mongo shell
    exit
  10. 查看mongodb 運行

    ps aux | grep mongo
  11. stop mongo
    進入mongodb shell

    a. mongo
    b. use admin
    c. db.shutdownServer()
    d. exit
參考:
  • http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/

VirtualBox NAT + Host-only (Ubuntu)

virtualBox

設定 ->  網路 ->
  • 界面卡1 選 NAT
  • 界面卡2 選 僅限主機界面卡
兩界面卡用預設值即可


linux 中
  • sudo vim /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet static
address 192.168.56.1
netmask 255.255.255.0
#network 192.168.56.0
#broadcast 192.168.56.255
gateway 192.168.56.254
#dns-search cloudspace.local
#dns-nameservers 8.8.8.8 8.8.4.4
 
or 
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet dhcp
 
 
ps. 在virtualBox linux 中可利用 route查詢 default Gateway 來填入 
 
  • sudo /etc/init.d/networking restart 
 
資料來源:
  • http://askubuntu.com/questions/446183/how-to-set-up-nat-and-host-only-networking-with-static-ip-address-in-virtualbox 
 


Ubuntu 網卡設定DHCP


  1. sudo  vim /etc/network/interfaces
  2. 將 iface eth0 inet static 改成 iface eth0 inetdhcp
  3. sudo /etc/init.d/networking restart
VirtualBox就重開機一下吧。
PS. 如果你有第二張網卡 





auto eth1
iface eth1 inetdhcp


PS. 如果想用固定IP
#Class C 設法
iface eth0 inet static 
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1


資料來源:
  • http://askubuntu.com/questions/446183/how-to-set-up-nat-and-host-only-networking-with-static-ip-address-in-virtualbox