AppFog 的小試用


昨天收到 AppFog 的邀請信
所以作了簡單的試用,記錄一下步驟

由於線上的 Web Console 個人認為不太好用
所以直接用套件方式進行佈置好了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# 先安裝套件
gem install af

# 登入帳戶
af login

# 切換到專案中
cd ~/Desktop/appfog

# 建立 Appname 和 網址
# appname : test
# site url: test.aws.af.cm
af push test --url test.aws.af.cm

# 之後會再要求你設定這個 App 的資料
---
Would you like to deploy from the current directory? [Yn]: Y
Detected a PHP Application, is this correct? [Yn]: Y
Memory Reservation [Default:128M] (64M, 128M, 256M, 512M, 1G or 2G)
Creating Application: OK
Would you like to bind any services to 'test'? [yN]: y
Would you like to use an existing provisioned service [yN]? y
The following provisioned services are available:
1. mysql-XXXXX
Please select one you wish to provision: 1
Binding Service: OK
Uploading Application:
Checking for available resources: OK
Packing application: OK
Uploading (0K): OK
Push Status: OK
Staging Application: OK
Starting Application: OK
---

# 備注
* appfog 本身支持 git 和類似於 ftp 的佈署
* 這裡使用的是後者,因為不想特別去建立 Public Git
* 如果本身已有 Public Git 的可以通過 Web Console 來建立較方便

* 以套件操作方式,想得知 MySQL 的 addon 連線資料
* 可以通過以下方式查看

echo "<?php print_r( getenv('VCAP_SERVICES') ); ?>" > test.php

* 之後再通過以下指令提交更新到 appfog

af update test

* 提交後就可以在網址中查看 test.php 得知訊息