Google App Engineのライセンスが届いたので、Hello Worldしてみました。
WindowsやMacのローカル環境構築は、他のサイトにありましたがLinux環境はなかったので一緒に作ってみます。
環境
OS : CentOS 32bit(i386)
Python : 2.5.2
注意 : すでにVMWareかなにかでCentOSが導入されていることを前提に書いていきます。
WindowsやMacのローカル環境構築は、他のサイトにありましたがLinux環境はなかったので一緒に作ってみます。
環境
OS : CentOS 32bit(i386)
Python : 2.5.2
注意 : すでにVMWareかなにかでCentOSが導入されていることを前提に書いていきます。
なにはともあれまず、Google App Engine用のユーザを作成します。
Linux ユーザ作成
# useradd google # passwd google Changing password for user google. New UNIX password: パスワード入力 Retype new UNIX password: もう一度パスワード入力 passwd: all authentication tokens updated successfully.
Googleユーザへ # su - google
Python インストール(2.5.2の場合です。そのとき最新の2.5.xをいれましょう)
Download 2.5.2
$ wget http://www.python.org/ftp/python/2.5.2/Python-2.5.2.tgz $ tar xzvf Python-2.5.2.tgz $ cd Python-2.5.2 $ mkdir -p ~/ll/py/ $ ./configure --prefix=/home/google/ll/py/ SSLに対応 ./counfigureの実行後、makeの前に [ Modules/Setup ]を以下のように修正します。204行目ぐらい -- ここから #SSL=/usr/local/ssl #_ssl _ssl.c \ # -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ # -L$(SSL)/lib -lssl -lcrypto + SSL=/usr + _ssl _ssl.c \ + -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ + -L$(SSL)/lib -lssl -lcrypto -- ここまで $ make $ make install インストールしたPythonを参照するように環境変数を変更します。 $ vi ~/.bashrc -- 追記 export PATH=/home/google/ll/py/bin:$PATH export PYTHONPATH=/home/google/ll/py/ -- $ source ~/.bashrc 以下のような結果が出力されれば環境変数の変更ができています。 $ which python ~/ll/py/bin/python $ python -V Python 2.5.2
Google App Engine SDK インストール(Version1.0.1の場合です。)
Google App Engine SDK Download Site
ホームディレクトリへ移動
$ cd
$ wget http://googleappengine.googlecode.com/files/google_appengine_1.0.1.zip
$ unzip google_appengine_1.0.1.zip
$ cd google_appengine
ローカル環境のテストサーバ起動オプションです。
$ python dev_appserver.py --help
Runs a development application server for an application.
dev_appserver.py [options] <application root>
Application root must be the path to the application to run in this server.
Must contain a valid app.yaml or app.yml file.
Options:
--help, -h View this helpful message.
--debug, -d Use debug logging. (Default false)
--clear_datastore, -c Clear the Datastore on startup. (Default false)
--address=ADDRESS, -a ADDRESS
Address to which this server should bind. (Default
localhost).
--port=PORT, -p PORT Port for the server to run on. (Default 8080)
--datastore_path=PATH Path to use for storing Datastore file stub data.
(Default /tmp/dev_appserver.datastore)
--history_path=PATH Path to use for storing Datastore history.
(Default /tmp/dev_appserver.datastore.history)
--require_indexes Disallows queries that require composite indexes
not defined in index.yaml.
--smtp_host=HOSTNAME SMTP host to send test mail to. Leaving this
unset will disable SMTP mail sending.
(Default '')
--smtp_port=PORT SMTP port to send test mail to.
(Default 25)
--smtp_user=USER SMTP user to connect as. Stub will only attempt
to login if this field is non-empty.
(Default '').
--smtp_password=PASSWORD Password for SMTP server.
(Default '')
--enable_sendmail Enable sendmail when SMTP not configured.
(Default false)
--auth_domain Authorization domain that this app runs in.
(Default gmail.com)
--debug_imports Enables debug logging for module imports, showing
search paths used for finding modules and any
errors encountered during the import process.
Google App Engine スタートアップ(実際にHello World!!をローカル環境で動かしてみます)
注意: Google Startupに沿っています
URL (基本的にはこちらと同じことをやります。)
ホームディレクトリへ移動 $ cd アプリケーションの環境設定を行います。 $ vi ~/hello/app.yaml -- ここから application: hello version: 1 runtime: python api_version: 1 handlers: - url: /.* script: helloworld.py -- ここまで $ vi ~/hello/helloworld.py -- ここから print 'Content-Type: text/plain' print '' print 'Hello, world!' -- ここまで
では、実際にテストサーバ実行して見ます。
$ mkdir -p /home/google/tmp $ $ python ~/google_appengine/dev_appserver.py --address=0.0.0.0 --port=8000 --datastore_path=/home/google/tmp/dev_appserver.datastore --history_path=/home/google/tmp/dev_appserver.datastore.history ~/hello/ Allow dev_appserver to check for updates on startup? (Y/n): Y dev_appserver will check for updates on startup. To change this setting, edit /home/google/.appcfg_nag INFO 2008-04-22 19:31:07,284 __init__.py] Checking for updates to the SDK. INFO 2008-04-22 19:31:07,779 __init__.py] The SDK is up to date. WARNING 2008-04-22 19:31:07,780 __init__.py] Could not read datastore data from /home/google/tmp/dev_appserver.datastore WARNING 2008-04-22 19:31:07,780 __init__.py] Could not read datastore data from /home/google/tmp/dev_appserver.datastore.history INFO 2008-04-22 19:31:07,793 __init__.py] Running application hello on port 8000: http://0.0.0.0:8000
http://ホスト名もしくはIPアドレス:8000/
○ 次回は、実際にGoogle App Engineにアプリケーションを作成し、Hello World!!をアップロードしてみます。




Leave a comment