Hi…
I am new to Phoenix.
Just managed to set up a simple Webpage und deploy it to Ubuntu on a VPS.
Starting mix phx.server on the VPS I get:
19:44:50.607 [info] Running BlogxWeb.Endpoint with Bandit 1.6.7 at :::4000 (http)
19:44:50.727 [info] Running BlogxWeb.Endpoint with Bandit 1.6.7 at 0.0.0.0:4001 (https)
19:44:50.748 [info] Access BlogxWeb.Endpoint at https://domain.de
So far so good, the page is visable.
But when I close the console… the Server stops.
What needs to be done that the server keeps on serving?
Greetings
Werner
A simple way would be to use the screen
CLI tool.
A better solution (for production) would be to start your webserver via systemd.
See: Elixir apps as systemd services - info & wiki
2 Likes
I’d start with the official Phoenix deployment guide:
https://hexdocs.pm/phoenix/deployment.html
5 Likes
You should definitely also read this (it explains releases, which are very useful), but note that it only contains instructions for PaaS platforms and building Docker containers - nothing about deploying to a VPS or systemd.
You should however consider building a release (as explained in the docs) and then running it under systemd, as that is the best approach. You don’t have to use Docker if you don’t want to, releases can work either way.
5 Likes
Instead of running your deployed app using mix phx.server
you should build a “release” and run that.
Documentation: mix release — Mix v1.18.2
To test this locally, just run mix release
. Read the output to see how it works. It is pretty simple.
_build/dev/rel/my_app/bin/my_app start
will start the Phoenix application.
If you want to open an iex shell in this running app:
_build/dev/rel/my_app/bin/my_app remote
6 Likes
psantos
February 21, 2025, 8:53pm
7
Checkout my blog post, it explains how to deploy Phoenix app using Kamal
3 Likes
Thank you for your replies…I will study all of them…Great to have support.
Have a nice Weekend…
Werner
2 Likes
JeyHey
February 22, 2025, 12:17pm
9
If not done already, create a release like so:
setenv MIX_ENV prod
mix release
Then start like so
_build/prod/rel/my_great_app/bin/my_great_app daemon
Try this
elixir --erl "-detached" -S mix phx.server
This would keep the server running in background.
4 Likes
nature
February 26, 2025, 5:01am
11
For me I used a service called Gigalixir. I wrote on article on it that I think you might find quite useful. Here’s the link
https://medium.com/@nature066/deploying-your-phoenix-api-to-gigalixir-with-github-actions-fd88ae92d6da
1 Like
nature
March 1, 2025, 11:19am
12
It worked o but how do i see the logs that is been generated on this detached server, is that possible?
If you are using liveview you can enable logging errors in browser console .
Otherwise you can create a release , run it in the background and attach to it when you want to see the logs. But you would lose hot code reloading while development.
1 Like