InstantRails似乎已不再更新,現在可使用RubyStack。
RubyStack是一個安裝檔,不是壓縮檔。它提供安裝時的一個配置導引,除了在安裝的目錄裡,它不會寫入或修改資料到作業系統中。它安裝MYSQL做為一個伺服器,也會在解除安裝時,被完整移除。未來可能對MYSQL提供伺服器或手動執行的選擇。
來自BitNami RubyStack 2.1-0 Quick Start Guide Ruby on Rails
初始假設安裝目錄為 :
Windows : C:\Program Files\Bitnami Rubystack\
Linux : /home/user/rubystack
OS X : /Applications/rubystack/projects/
Rails的應用軟體名稱為 rubystack.
如何開始?
首先執行 Rails 的環境 :
Windows :
Start -> BitNami RubyStack -> Use Ruby [Use BitNami RubyStack Development]
Linux :
/home/user/rubystack/rubyconsole
會打開一個已設定好的命令控制台,方便執行你的命令。
註:在我下載的最新版本,安裝後並不是Use Ruby ,而是 Use BitNami RubyStack Development 。
如何執行或停止 MySQL 及 Apache 伺服器?
Windows :
打開 Rails 環境的命令列控制台後,執行 servicerun.bat 批次檔,啟動或停止伺服器。
啟動伺服器,使用以下命令列:
servicerun.bat START
停止伺服器,使用以下命令列:
servicerun.bat STOP
要確定你在 RubyStack的安裝主目錄下執行 (C:\Program Files\BitNami RubyStack\).
你也可以使用下列方式:
啟動伺服器:
Start -> BitNami RubyStack Development -> BitNami RubyStack Development Service -> Start BitNami RubyStack Development service
停止伺服器:
Start -> BitNami RubyStack Development -> BitNami RubyStack Development Service -> Stop BitNami RubyStack Development service
------------------
Linux : you can start/stop Apache, MySQL and Subversion server with ctlscript.sh. You can type ./ctlscript.sh help to see all options: usage: ./ctlscript.sh help ./ctlscript.sh (start|stop|restart) ./ctlscript.sh (start|stop|restart) mysql ./ctlscript.sh (start|stop|restart) apache ./ctlscript.sh (start|stop|restart) subversion help - this screen start - start the service(s) stop - stop the service(s) restart - restart or start the service(s)
------------------
註:Linux 等系統,我省略了,沒翻譯。
如何執行自己的 web 應用程式?
執行 Start Menu -> "Use Ruby" [Use BitNami RubyStack Development],會開啟指向rails應用程式的目錄,並啟動web 應用程式伺服器。
例:預設的程式名為 rubystack 及放置在
Windows : C:\Documents and Settings\User\BitNami RubyStack
----------------------------
(/home/user/rubystack/projects/ on Linux , /Applications/rubystack/projects/ on OS X)
----------------------------
它會打開命令列控制台,然後執行 :
cd rubystack
ruby script/server
如何存取(瀏覽)我的 web 應用程式?
先確定執行應用程式的伺服器(看:如何執行自己的 web 應用程式?),然後使用瀏覽器指向 http://localhost:3000/
如何停止 web 應用程式?
只要關閉web 應用程式伺服器的執行視窗即可。
如何建立新的 rails web 應用程式?
在 Rails 環境下,執行 "rails" 後接你的web應用程式名稱 : rails my_new_app 這樣會建立一個名為 my_new_app 的新目錄,內已含有相符的檔案目錄構。 接下來是為你的 my_new_app 應用程式,建立資料庫。
如何建立相符合你的 my_new_app 應用程式的 資料庫?
打開 Rails 環境, 連接到 mysql 資料庫 :
windows : "C:\Program Files\BitNami RubyStack\mysql\bin\mysql.exe" -u root --port=your-porthere
Linux : /home/user/rubystack/mysql/bin/mysql -u root --port=your-porthere
然後在 mysql 的命令列下執行下列腳本 :
CREATE DATABASE IF NOT EXISTS my_new_app_production;
CREATE DATABASE IF NOT EXISTS my_new_app_development;
CREATE DATABASE IF NOT EXISTS my_new_app_test;
GRANT ALL PRIVILEGES on my_new_app_test.* to 'rubystack'@'localhost' identified by 'rubystack';
GRANT ALL PRIVILEGES on my_new_app_production.* to 'rubystack'@'localhost';
GRANT ALL PRIVILEGES on my_new_app_development.* to 'rubystack'@'localhost'; flush privileges;
如何配置自己新的 Rails 應用程式到先前建立的資料庫?
你需要建立一個名為 "database.yml" 的檔案,在你的應用程式目錄內的 config 目錄。 在 database.yml檔中,輸入以下內容:
在Windows:
development:
adapter: mysql
database: my_new_app_development
username: rubystack
password: your-password-here
host: localhost
port: ${mysql_port}
test:
adapter: mysql
database: my_new_app_test
username: rubystack
password: your-password-here
port: ${mysql_port}
production:
adapter: mysql
database: my_new_app_production
username: rubystack
password: your-password-here
port: ${mysql_port}
把它存為 "${rails_application_dir}\config\database.yml".
-----------------------
(Linux and OS X you have to replace port: ${mysql_port} with socket: ${installdir}/mysql/tmp/mysql.sock)
-----------------------
如何創建mongrel cluster?
你可以配置 Apache 或 Nginx 作為不同 mongrel processes 的 proxy balancer 。 這些 Mongrel instances 應該使用特殊的 ports ,以使得 web server 能夠重導 the requests 給它們 。
例: 你可以從 ruby 控制台來啟動兩個 mongrels ,並使用 ports 3001, 3002 。
cd rubystack ruby script/server -p 3001 -d ruby script/server -p 3002 -d
--------------------------------
(On Linux and OS X you can use mongrel_cluster plugin to start/restart/stop a group of mongrels easily. You can create a mongrel cluster configuration file running: mongrel_rails cluster::configure -e production -p 3001 -N 2 -C ${rails_application_dir}/config/mongrel_cluster.yml This will create a cluster with two mongrels starting at port 3001 storing the settings in mongrel_cluster.yml. Then, to start the cluster you can type: cd ${rails_application_dir} mongrel_rails cluster::start)
--------------------------------
如何在 Windows 中, 安裝 mongrels 作為 伺服器?
安裝伺服器,如下:
mongrel_rails service::install -N "service_name" -p "port" -c "application_directory"
啟動伺服器你可以使用 Windows service tool 或者輸入 :
net start "service_name"
反安裝伺服器,如下:
mongrel_rails service::remove -N "service_name" 或 sc delete "service_name"