Elixir 如何让Phoenix在端口4000上收听?
我正在尝试让我的Phoenix应用程序在端口4000上侦听,但它不起作用。首先,我使用Elixir 如何让Phoenix在端口4000上收听?,elixir,phoenix-framework,Elixir,Phoenix Framework,我正在尝试让我的Phoenix应用程序在端口4000上侦听,但它不起作用。首先,我使用MIX\u ENV=prod MIX release--ENV=prod生成我的生产应用程序。然后,我将\u build目录同步到我的服务器。然后我运行PORT=4000./\u build/prod/rel/rumbl/bin/rumbl start。然后当我curl localhost:4000时,我没有得到响应 这是我的配置/prod.exs: use Mix.Config config :rumbl,
MIX\u ENV=prod MIX release--ENV=prod
生成我的生产应用程序。然后,我将\u build
目录同步到我的服务器。然后我运行PORT=4000./\u build/prod/rel/rumbl/bin/rumbl start
。然后当我curl localhost:4000
时,我没有得到响应
这是我的配置/prod.exs
:
use Mix.Config
config :rumbl, Rumbl.Endpoint,
http: [port: {:system, "PORT"}],
url: [host: "localhost", port: {:system, "PORT"}],
cache_static_manifest: "priv/static/manifest.json"
config :logger, level: :info
import_config "prod.secret.exs"
问题在于:
http: [port: {:system, "4000"}],
应改为:
http: [port: {:system, "PORT"}],
系统环境变量PORT
应设置并导出:
export PORT=4000
e、 g.在您的shell配置文件中。您还需要添加
load_from_system_env: true,
server: true,
root: ".",
将行添加到您的配置中
如果不想配置它,只需执行以下操作:
http: [port: "4000"],
{:system,“4000”}
基本上是试图读取env变量4000
旁注:最好让下一行与此设置完全对应:
url: [host: "localhost", port: {:system, "PORT"}],
我修改了配置文件以使用系统变量,但仍然无法访问该站点。我已更新了答案:
load\u from\u system\u env:true
matters。