Once we have a working application, we're ready to deploy it. If you're not quite finished with your own application, don't worry. Just follow the Up and Running Guide to create a basic application to work with.
When preparing an application for deployment, static assets may require special handling. In order to create gzipped digests with a manifest for our static assets, the current Phoenix master branch includes a phoenix.digest
mix task. (This will be included in the upcoming 0.12.0 release.) This task is designed to be run after brunch build --production
, or whichever build command is correct for your application.
Now that we've got our application prepared for production, getting it running in a production environment is extremely simple. All we need to do is run this command.
MIX_ENV=prod PORT=4001 iex -S mix phoenix.server
We can run our application detached from the iex console. This effectively daemonizes the process so it can run independently in the background. The command to do that looks like the following.
MIX_ENV=prod PORT=4001 elixir --detached -S mix phoenix.server
Running the application in detached mode allows us to keep the application running even after we terminate the shell connection with the server.
For guidance on deploying with Erlang style releases, please check out the Advanced Deployment Guide
Note, with new Phoenix projects created using Elixir 1.0.4, protocol consolidation happens automatically when we start a Phoenix server with MIX_ENV=prod
. (Actually, any Phoenix specific mix task will consolidate protocols when invoked with MIX_ENV=prod
.)
For more information on this, and on running production Elixir applications in general, please see this Plataformatec Blog entry.