開発環境
- CentOS 6.3
- Play! v2.1.0
- sbt v0.12.2
- jdk v1.6.0_24
jdkはyumなんかで入っているものとして進めていく。
Install Play framework
$ cd ~ $ mkdir workspace $ cd workspace $ wget http://downloads.typesafe.com/play/2.1.0/play-2.1.0.zip $ unzip play-2.1.0.zip $ sudo cp play-2.1.0 /usr/local/すべてのユーザでplayコマンドを使えるようにpathを通す。
$ sudo vi /etc/profile/etc/profile
# added export PATH=$PATH:/usr/local/play-2.1.0
$ source /etc/profileplayコマンド打つ前に、
java.io.FileNotFoundException: /usr/local/play-2.1.0/framework/sbt/boot/update.logとか
Ooops - Something went wrong! Exception:java.io.IOException: Cannot write parent directory: Path(/home/foo/workspace/helloworld/app) of /home/foo/workspace/helloworld/app/controllersとか怒られないようにするためにゴニョゴニョ。
$ sudo touch /usr/local/play-2.1.0/framework/sbt/boot/update.log $ sudo chmod -R a+w /usr/local/play-2.1.0/play new sampleAppってコマンドでアプリの雛形作るときの sampleApp/app/controllers/フォルダが出来ないことに対するピンポイントな対応がいまいちよくわからんです。
【参考】play-mailing-llistでのやりとり
ここいらでplayコマンドが有効化どうかの確認。
$ cd ~/workspace $ play help _ _ _ __ | | __ _ _ _| | | '_ \| |/ _' | || |_| | __/|_|\____|\__ (_) |_| |__/ play! 2.1.0 (using Java 1.6.0_24 and Scala 2.10.0), http://www.playframework.org Welcome to Play 2.1.0! These commands are available: ----------------------------- license Display licensing informations. new [directory] Create a new Play application in the specified directory. You can also browse the complete documentation at http://www.playframework.org.
Install sbt
wget使ってsbt.zipをインスコ。yum使ってinstallしてる人もいるっぽい。$ cd ~/workspace $ wget http://scalasbt.artifactoryonline.com/scalasbt/sbt-native-packages/org/scala-sbt/sbt//0.12.2/sbt.zip $ unzip sbt.zip sbt-launch.jarを/bin/ディレクトリにコピー $ sudo cp sbt/bin/sbt-launch.jar /bin/ $ cd /bin/ $ sudo ls -l | grep sbt $ sudo vi sbt# /bin/sbt 実行権限付与
$ cd /bin/ $ sudo chmod 755 sbt $ sudo chmod 755 sbt-launch.jar $ sudo ls -l | grep sbt -rwxr-xr-x 1 root root 120 4月 29 20:14 2013 sbt -rwxr-xr-x 1 root root 1105354 4月 29 20:02 2013 sbt-launch.jar
アプリの雛形を作る
$ cd ~/workspace $ play new helloworld _ _ _ __ | | __ _ _ _| | | '_ \| |/ _' | || |_| | __/|_|\____|\__ (_) |_| |__/ play! 2.1.0 (using Java 1.6.0_24 and Scala 2.10.0), http://www.playframework.org The new application will be created in /home/ryota/workspace/helloworld What is the application name? [helloworld] > Which template do you want to use for this new application? 1 - Create a simple Scala application 2 - Create a simple Java application > 2 OK, application helloworld is created. Have fun! $ ls helloworld README app conf project public test $ cd helloworld $ sbt [info] Loading project definition from ~/workspace/helloworld/project [info] Set current project to helloworld (in build file:~/workspace/helloworld/) [helloworld] $ reload [helloworld] $ update [helloworld] $ compile [success] Total time: 37 s, completed ごにょごにょ
ApacheとPlay!のNettyを連携
vhost使って、domain/play
にアクセスしたときにhelloworldアプリに飛ぶように設定する。別にこの設定しなくても細かいこと気にしない人はiptablesの9000番port開ければいいと思ふ。
# インクルードするconfigファイルを置くディレクトリを作る $ sudo mkdir /etc/httpd/conf/extras # play用のエラーログ・ファイルを作る $ sudo touch /var/log/play-error_log # インクルードするファイルを作る $ sudo vi /etc/httpd/conf/extras/httpd-play.confhttpd-play.conf
Apache本体のconfigファイルで追加configファイルをインクルードするようにごにょごにょ。ServerAdmin foo@foo.com DocumentRoot "/var/www/html" ServerName play.foo.com Errorlog "/var/log/play-error_log" ProxyPass /play http://127.0.0.1:9000 ProxyPassReverse /play http://127.0.0.1:9000 RequestHeader unset Authorization Order allow,deny Allow from all
/etc/httpd/conf/httpd.conf
### added begin ## Include /etc/httpd/conf/extras/*.conf Include conf/extras/*.conf ### added endApacheの再起動
$ sudo service httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ]helloworldアプリの起動
$ cd ~/workspace/helloworld $ sbt [helloworld] run --- (Running the application from SBT, auto-reloading is enabled) --- [info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000 (Server started, use Ctrl+D to stop and go back to the console...)ブラウザで
http://your-domain-here/play
にアクセスして、Welcome to Play 2.1.0 見たいページ出ればおk。
0 件のコメント:
コメントを投稿