Running a Phoenix server (Elixir) on Replit
Here's a quick tutorial on how to get a Phoenix server up and running on Replit.
Phoenix is a web development framework in Elixir (similar to Django for Python or Rails for Ruby).
Let's get started with a new Elixir repl - I'm calling this 'FirstPhoenix'.
1 - Install Hex:
You will need the Hex package manager - Elixir's package manager to run Phoenix. In your shell type
mix local.hex, then type 'Y' when asked if you want to install Hex.
2 - Install Phoenix:
Now, install Phoenix with
mix archive.install hex phx_new 1.5.9 (1.5.9 is the latest version on July 21, 2021. You can refer to Phoenix installation documentation here). Type 'Y' when asked 'Are you sure you want to install "phx_new-1.5.9.ez"?"
--no-webpack for this.
We're also not adding support for any databases (such as PostgreSQL) at the moment and will use the
--no-ecto flag while creating the server.
To create a new Phoenix server type
mix phx.new first --no-webpack --no-ecto in the shell. Type 'Y' when you're asked "Fetch and install dependencies?"
4 - Installing inotify-tools:
There's one more task before we get the server up and running. Go to the server directory using
cd first and start the server using
mix phx.server. You get an error!
We need to install inotify-tools. (You can find the github repo here )
(You may need to use ctrl+C to get the shell prompt).
Go back to the parent directory with
cd ... In the shell, type
Go to your server directory with
cd first and then run
iex -S mix phx.server
You will be asked if you want to install rebar3. Type 'Y'.
You should see the server running after a few seconds.
If you don't see the Phoenix page in the Viewer panel, click on 'Open in a new tab'
And it's running!!
Since we started the server with 'iex -S mix', you can use iex commands and functions in the shell, as you would in any other iex session.
If you're starting out as a beginner in Elixir and/or Functional Programming, check out the following tutorials:
Say hello on Twitter