debian 安裝ruby +nginx+apache開發環境.

來源:互聯網
上載者:User

標籤:ruby debian   nginx   apache   rails   

安裝軟體

1.很簡單, 前提你安裝了apache, mysql, nginx 如果沒有 加上.

#apt-get installapache2 nginx

2.開啟apache的重寫.

#a2enmod rewrite

#apt-get install mysql-server

3.下面會安裝ruby, apache的ruby模組, mysql的ruby支援, vim的rails支援.

#apt-get install ruby rails rubygems rake  libapache2-mod-ruby libdbi-ruby libdbd-mysql-ruby vim-rails  ri libruby  libfcgi-ruby1.9.1 libxml-ruby libxml2-dev


查看安裝的ruby版本 
gem 常用命令

  • gem list 列出已經安裝的包
  • gem install xxx 安裝包
  • gem uninstall xxx 卸載安裝包
  • gem query xxx 搜尋包
  • gem cleanup 清除cache
  • gem help 協助.

[email protected]:/home/ruby# gem list*** LOCAL GEMS ***rubyzip (1.1.3)

測試ruby和mysql的連結

編寫一個簡單的指令碼來測試連結, 如果顯示mysql版本就ok了.

#gvim test.rb

# test.rb - test MySQL script using Ruby DBI modulerequire "dbi"begin    # connect to the MySQL server    dbh = DBI.connect("dbi:Mysql:mysql:localhost", "root", "")    # get server version string and display it    row = dbh.select_one("SELECT VERSION()")    puts "Server version: " + row[0]rescue DBI::DatabaseError => e    puts "An error occurred"    puts "Error code: #{e.err}"    puts "Error message: #{e.errstr}"ensure    # disconnect from server    dbh.disconnect if dbhend
<span style="background-color: rgb(102, 102, 102);"><span style="color:#ffffff;">[email protected]:/home/ruby# ruby ./test.rb Server version: 5.5.37-0+wheezy1-log</span></span>


測試 rails
#cd /home/www 先進入apache, nginx的www目錄, 我這裡都設定的一個.#rails new_project 來建立一個rails的project.#cd new_project#rm -rf public/index.html  這裡刪除掉預設頁面,以免一直跳轉到這裡.#vim config/database.yml  修改development開發模式的database: ruby_test #mysql -uroot -p   進入mysql後建一個ruby_test的DB  
[email protected]:/home/www# mysql -u root -pEnter password: Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 40Server version: 5.5.37-0+wheezy1-log (Debian)Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.[email protected](none) 12:02:44>create database ruby_test;Query OK, 1 row affected (0.00 sec)
#script/generate controller Blog        建立一個 Blog 的 controller#script/server                          啟動 server, 就可以由 http://localhost:3000/ 訪問了現在來實現Hello world#vim app/controllers/blog_controller.rb加入def index    render :text => "Hello world"end


debian 安裝ruby +nginx+apache開發環境.

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.