风卷残云般部署好一个Phoenix应用,在Ubuntu服务器上
2016-08-21 00:00
393 查看
注意,编译项目文件时所使用的操作系统要与服务器一致,例如需要运行在Ubuntu64上的项目,就需要在Ubuntu64的环境里编译。
elixir
phoenix
postgreSQL
nginx
修改
预编译静态资源
生成发布包
测试发布
没有错误的话,我们的应用会运行在http://localhost:8888/
登陆服务器,并解压
启动应用
配置nginx
重启nginx
一切顺利的话,你可以在你设置的
服务器上先安装好
erlangelixir
phoenix
postgreSQL
nginx
以下操作在本地进行
添加exrm依赖{:exrm, "~> 1.0"}到
mix.exs文件
修改
config/prod.exs
# Configures the endpoint config :hello_phoenix, HelloPhoenix.Endpoint, http: [port: 8888], url: [host: "example.com"], root: ".", cache_static_manifest: "priv/static/manifest.json", server: true, version: Mix.Project.config[:version]
预编译静态资源
$ MIX_ENV=prod mix phoenix.digest ==> ranch (compile) . . . Check your digested files at 'priv/static'.
生成发布包
MIX_ENV=prod mix compile
MIX_ENV=prod mix release
测试发布
rel/hello_phoenix/bin/hello_phoenix console
没有错误的话,我们的应用会运行在http://localhost:8888/
发布
将发布包发送到服务器$ scp -i ~/.ssh/id_rsa.pub rel/hello_phoenix-0.0.1.tar.gz ubuntu@hostname.com:/home/ubuntu hello_phoenix-0.0.1.tar.gz 100% 18MB 80.0KB/s 03:48
登陆服务器,并解压
$ ssh -i ~/.ssh/id_rsa.pub ubuntu@hostname.com $ sudo mkdir -p /app $ sudo chown ubuntu:ubuntu /app $ cd /app $ tar xfz /home/ubuntu/hello_phoenix-0.0.1.tar.gz
以下在服务器进行
让应用在系统启动时启动sudo vi /etc/init/hello_phoenix.conf
description "hello_phoenix" ## Uncomment the following two lines to run the ## application as www-data:www-data #setuid www-data #setgid www-data start on runlevel [2345] stop on runlevel [016] expect stop respawn env MIX_ENV=prod export MIX_ENV ## Uncomment the following two lines if we configured ## our port with an environment variable. env PORT=8888 export PORT ## Add app HOME directory. env HOME=/app export HOME pre-start exec /bin/sh /app/bin/hello_phoenix start post-stop exec /bin/sh /app/bin/hello_phoenix stop
启动应用
sudo start hello_phoenix
配置nginx
$ sudo touch /etc/nginx/sites-available/hello_phoenix $ sudo ln -s /etc/nginx/sites-available/hello_phoenix /etc/nginx/sites-enabled $ sudo vi /etc/nginx/sites-available/hello_phoenix
upstream hello_phoenix { server 127.0.0.1:8888; } # The following map statement is required # if you plan to support channels. See https://www.nginx.com/blog/websocket-nginx/ map $http_upgrade $connection_upgrade { default upgrade; '' close; } server{ listen 80; server_name .hostname.com; location / { try_files $uri @proxy; } location @proxy { include proxy_params; proxy_redirect off; proxy_pass http://hello_phoenix; # The following two headers need to be set in order # to keep the websocket connection open. Otherwise you'll see # HTTP 400's being returned from websocket connections. proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } }
重启nginx
sudo service nginx restart
一切顺利的话,你可以在你设置的http://hostname.com/
访问Phoenix应用了。
相关文章推荐
- 部署一个BIRT报告到你的应用服务器(转自ECLIPSE中国社区)
- 如何在Ubuntu 14.04服务器上自动化部署Spring Boot的应用
- 在Ubuntu 14.04 下部署Apache2服务器并发布Django 1.7.6 Web应用(本机)
- 使用passenger+nginx在Ubuntu14.04服务器上部署rails应用填坑记
- 如何在Ubuntu 14.04服务器上自动化部署Spring Boot的应用
- apache服务器安装以及使用passenger插件部署rails应用,基于ubuntu 12.04 LTS
- 一个Web应用部署到Tomcat服务器上之后的目录结构是怎样的?以及web工程与maven web工程的目录结构
- 在Ubuntu 14.04的生产环境上部署一个Symfony应用
- 一个Web应用(比如网站)是如何部署在多个web服务器上的?同步软件有讲到
- apache服务器安装以及使用passenger插件部署rails应用,基于ubuntu 12.04 LTS
- 从零开始在阿里云服务器(Ubuntu)上部署Rails应用
- 皕杰报表在金蝶应用服务器(apusic-5.1)中的部署
- App-V 序列化服务器的部署及序列化的具体应用
- 我在Google AppEngine上部署了一个Java应用(OpenID测试)
- 关于多个应用在同一个server中部署时出现cookies被覆盖的解决方案
- 一个IIS应用的web服务器负载性能数据
- .NET Framework 4.0 中如何把一个程序部署到全局应用缓存(GAC)
- apusic培训整理(服务器安装、应用部署、建立集群)
- 小弟想做一个应用软件,功能就是对internet上面服务器的access数据库进行读写。
- 在本机环境中搭建一个真正的web网站环境(和网站部署到服务器上效果一致)