Googleのある程度無料で動かせるサーバー(Google App Engine)で
おきまりのページ(helloworld)を作ってみました
ある程度というのは無料とは下記の範疇です
英語なので注意
https://cloud.google.com/appengine/docs/quotas
GOOGLE APP ENGINE SDK のインストール
https://cloud.google.com/appengine/downloads#Google_App_Engine_SDK_for_PHP
ダウンロードして起動すると
python2.7が必要ですよというメッセージが表示される
いれていない人は
Download Python | Python.org
からダウンロードする
(マルチバイト文字の問題があるので2.7.7以上いれたほうがいいです)
お約束のページが表示されるのでしたがってインストール
する
Google Developers Consoleに入ってプロジェクトを作成する
https://console.developers.google.com/project
適当なプロジェクトを入力する(masalibtest)
プロジェクトの作成が終わるとプロジェクトダッシュボードが表示される
Hello Worrdアプリのデプロイをクリックする
言語の選択画面が表示される
サンプルPHPがあるのでそちらをダウンロードする
ダウンロードしたファイルは以下のとおりです
appengine-try-php-master.zipの内容
helloworld.php
<!--?php echo 'Hello, world!';
app.yaml
-
- >||
application: helloworld
version: 1
runtime: php55
api_version: 1
handlers:
- url: /.*
script: helloworld.php
|
C:\test\appengine-try-php-masterに展開しました
コマンドラインを立ち上げて下記のコマンドを実行する
cd C:\test\ appcfg.py -A masalibtest update appengine-try-php-master 10:38 PM Application: masalibtest (was: helloworld); version: 1 10:38 PM Host: appengine.google.com 10:38 PM Starting update of app: masalibtest, version: 1 10:38 PM Getting current resource limits. Your browser has been opened to visit:↓初期の認証ページがたちあがります https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&response_type=code&client_id=550516889912.apps.googleusercontent.com&access_type=offline If your browser is on a different machine then exit and re-run this application with the command-line parameter --noauth_local_webserver
承認を押す
デプロイが開始される
Authentication successful. 10:39 PM Scanning files on local disk. 10:39 PM Cloning 2 application files. 10:40 PM Compilation starting. 10:40 PM Compilation completed. 10:40 PM Starting deployment. 10:40 PM Checking if deployment succeeded. 10:40 PM Deployment successful. 10:40 PM Checking if updated app version is serving. 10:40 PM Completed update of app: masalibtest, version: 1
ブラウザで以下のURLにアクセスする
http://masalibtest.appspot.com/
お決まりのページが表示されました~
思ったより簡単でした
app.yamlファイルでプログラムとプログラムパスを管理するのは
若干めんどくさいけど
raiilsでルールなのでまー仕方がないのかなと思っています
今後
GAEだとsmartyのテンプレートエンジンが使えないらしいので
TWIGというエンジンが使えるそうなのでそちらを調査したいと思います