1、安裝命令行工具vmc
ubuntu@ip-10-128-97-185:~$ gem install vmc
Successfully installed spruz-0.2.13
Successfully installed json_pure-1.5.4
Successfully installed rubyzip2-2.0.1
Successfully installed terminal-table-1.4.4
Successfully installed interact-0.2
Successfully installed vmc-0.3.13
6 gems installed
2、使用vmc命令設置target
ubuntu@ip-10-128-97-185:~$ vmc target api.cloudfoundry.com
Succesfully targeted to [http://api.cloudfoundry.com]
3、登錄,這時會用到你在cloundfoundry的賬戶信息
ubuntu@ip-10-128-97-185:~$ vmc login
Email: [email protected]
Password: ********
Successfully logged into [http://api.cloudfoundry.com]
4、創建測試文件
ubuntu@ip-10-128-97-185:~$ mkdir cloudfoundry
ubuntu@ip-10-128-97-185:~$ cd cloudfoundry/
ubuntu@ip-10-128-97-185:~/cloudfoundry$
ubuntu@ip-10-128-97-185:~/cloudfoundry/hello$ nano hello.rb
require 'sinatra'
get '/' do
"Hello*from*Cloud*Foundry"
end
5、上傳
ubuntu@ip-10-128-97-185:~/cloudfoundry/hello$ vmc push
Would you like to deploy from the current directory? [Yn]:
Application Name: douyw
Application Deployed URL ["douyw.cloudfoundry.com"]:
Detected a Sinatra Application, is this correct? [Yn]:
Memory Reservation ("64M", "128M", "256M", "512M", "1G", "2G") ["128M"]:
Creating Application: OK
Would you like to bind any services to 'douyw'? [yN]:
Uploading Application:
Checking for available resources: OK
Packing application: OK
Uploading (0K): OK
Push Status: OK
Staging Application: OK
Starting Application: OK
ubuntu@ip-10-128-97-185:~/cloudfoundry/hello$
注意:上面的douyw爲應用程序名,是自己輸入的。6、打開瀏覽器瀏覽:http://douyw.cloudfoundry.com
這時已經發布完成。下面是對上傳文件修改之後的步驟。
7、重新編輯並再次上傳:
ubuntu@ip-10-128-97-185:~/cloudfoundry/hello$ nano hello.rb
再次上傳
ubuntu@ip-10-128-97-185:~/cloudfoundry/hello$ vmc update douyw
Uploading Application:
Checking for available resources: OK
Packing application: OK
Uploading (0K): OK
Push Status: OK
Stopping Application: OK
Staging Application: OK
Starting Application: OK
然後刷新瀏覽器,顯示結果最終爲:
Hello from Cloud Foundry and EC2