Stay Hungry.Stay Foolish.
phoenix app生产环境部署

生成安全key

mix phoenix.gen.secret

生产环境安全配置

添加配置文件config/prod.secret.exs

use Mix.Config

# In this file, we keep production configuration that
# you likely want to automate and keep it away from
# your version control system.

# You can generate a new secret by running:
#
#     mix phoenix.gen.secret
config :foo, Foo.Endpoint,
  secret_key_base: "A LONG SECRET"

# Configure your database
config :foo, Foo.Repo,
  adapter: Ecto.Adapters.Postgres,
  username: "postgres",
  password: "postgres",
  database: "foo_prod",
  size: 20 # The amount of database connections in the pool

部署

$ mix deps.get --only prod
$ MIX_ENV=prod mix compile

# Compile assets
$ brunch build --production
$ MIX_ENV=prod mix phoenix.digest

# Custom tasks (like DB migrations)
$ MIX_ENV=prod mix ecto.migrate

# Finally run the server
$ PORT=4000 MIX_ENV=prod mix phoenix.server

具体可以参考官方文档

自由转载-非商用-非衍生-保持署名(创意共享3.0许可证
评论

暂无评论~~