欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

play framework学习笔记之 部署项目 log4jlighttpdGAEApacheJPA 

程序员文章站 2024-03-20 15:47:22
...

Deployment options,部署的选择

1,

最简单和最健壮的项目部署方式是 without 容器

你可以把端口修改到80

You can use a frontal HTTP server like Lighttpd or Apache

当然你如果希望用到虚拟主机这样的功能,你也可以使用一些HTTP SERVER像apache,Lighttpd。让HTTP server转发。

2,部署在tomcat这样的servlet容器里面,支持tomcat6

需要打包成war

命令

play war myapp -o myapp.war

3,部署到GAE

安装play的GAE模块

play install gae

部署到GAE的命令

play gae:deploy myapp

项目部署的步骤

Set the framework in prod mode:

%production.application.mode=prod

Define a real database:

%production.db.url=jdbc:mysql://localhost/prod

%production.db.driver=com.mysql.jdbc.Driver

%production.db.user=root

%production.db.pass=1515312

Disable JPA automatic schema update:

%production.jpa.ddl=create

Define a secure secret key:

%production.application.secret=c12d1c59af499d20f4955d07255ed8ea333

log4j.rootLogger=ERROR, Rolling

log4j.logger.play=INFO

# Rolling files

log4j.appender.Rolling=org.apache.log4j.RollingFileAppender

log4j.appender.Rolling.File=application.log

log4j.appender.Rolling.MaxFileSize=1MB

log4j.appender.Rolling.MaxBackupIndex=100

log4j.appender.Rolling.layout=org.apache.log4j.PatternLayout

log4j.appender.Rolling.layout.ConversionPattern=%d{ABSOLUTE} %-5p ~ %m%n

%production.http.port=80

Set-up with lighttpd

This example shows you how to configurelighttpdas a front-end web server. Note that you can do the same with Apache, but if you only need virtual hosting or load balancing, lighttpd is a very good choice and much easier to configure!

The/etc/lighttpd/lighttpd.conffile should define things like this:

server.modules = (
      "mod_access",
      "mod_proxy",
      "mod_accesslog" 
)
...
$HTTP["host"] =~ "www.myapp.com" {
    proxy.balance = "round-robin" proxy.server = ( "/" =>
        ( ( "host" => "127.0.0.1", "port" => 9000 ) ) )
}
 
$HTTP["host"] =~ "www.loadbalancedapp.com" {
    proxy.balance = "round-robin" proxy.server = ( "/" => ( 
          ( "host" => "127.0.0.1", "port" => 9000 ), 
          ( "host" => "127.0.0.1", "port" => 9001 ) ) 
    )
}

Set-up with Apache

The example below shows a simple set-up withApache httpd serverrunning in front of a standard Play configuration.

LoadModule proxy_module modules/mod_proxy.so
...
<VirtualHost *:80>
  ProxyPreserveHost On
  ServerName www.loadbalancedapp.com
  ProxyPass / http://127.0.0.1:9000/
  ProxyPassReverse / http://127.0.0.1:9000/
</VirtualHost>
apache的其他配置,暂时 略去。