{"id":13717,"date":"2019-04-05T10:04:29","date_gmt":"2019-04-05T10:04:29","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=13717"},"modified":"2019-04-05T10:04:29","modified_gmt":"2019-04-05T10:04:29","slug":"how-to-install-elixir-and-phoenix-framework-on-ubuntu-16-04","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/05\/how-to-install-elixir-and-phoenix-framework-on-ubuntu-16-04\/","title":{"rendered":"How to Install Elixir and Phoenix Framework on Ubuntu 16.04"},"content":{"rendered":"<p>This tutorial will show you how to install Elixir and Phoenix frameworks on a Vultr Ubuntu 16.04 server instance for development purposes.<\/p>\n<h2 id=\"Prerequisites\">Prerequisites<\/h2>\n<ul>\n<li>A new Vultr Ubuntu 16.04 server instance<\/li>\n<li>Logged in as a non-root sudo user.<\/li>\n<\/ul>\n<p>Update the system:<\/p>\n<pre><code>sudo apt-get update\r\n<\/code><\/pre>\n<h2 id=\"Install_Erlang\">Install Erlang<\/h2>\n<p>Install Erlang with the following commands:<\/p>\n<pre><code>cd ~\r\nwget https:\/\/packages.erlang-solutions.com\/erlang-solutions_1.0_all.deb \r\nsudo dpkg -i erlang-solutions_1.0_all.deb\r\nsudo apt-get update\r\nsudo apt-get install esl-erlang\r\n<\/code><\/pre>\n<p>You can verify the installation:<\/p>\n<pre><code>erl\r\n<\/code><\/pre>\n<p>This will take you to the Erlang shell with following output:<\/p>\n<pre><code>Erlang\/OTP 21 [erts-10.1] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [hipe]\r\n\r\nEshell V10.1  (abort with ^G)\r\n1&gt;    \r\n<\/code><\/pre>\n<p>Press\u00a0<kbd>CTRL<\/kbd>\u00a0+\u00a0<kbd>C<\/kbd>\u00a0twice to exit the Erlang shell.<\/p>\n<h2 id=\"Install_Elixir\">Install Elixir<\/h2>\n<p>Install Elixir with\u00a0<code>apt-get<\/code>:<\/p>\n<pre><code>sudo apt-get install elixir\r\n<\/code><\/pre>\n<p>Now you can verify the Elixir installation:<\/p>\n<pre><code>elixir -v\r\n<\/code><\/pre>\n<p>This will show the following output:<\/p>\n<pre><code>Erlang\/OTP 21 [erts-10.1] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [hipe]\r\n\r\nElixir 1.7.3 (compiled with Erlang\/OTP 20)\r\n<\/code><\/pre>\n<p>Now you have Elixir 1.7.3 installed on your system.<\/p>\n<h2 id=\"Install_Phoenix\">Install Phoenix<\/h2>\n<p>If we have just installed Elixir for the first time, we will need to install the Hex package manager as well. Hex is necessary to get a Phoenix app running, and to install any extra dependencies we might need along the way.<\/p>\n<p>Type this command to install Hex:<\/p>\n<pre><code>mix local.hex\r\n<\/code><\/pre>\n<p>Now we can proceed to install Phoenix:<\/p>\n<pre><code>mix archive.install https:\/\/github.com\/phoenixframework\/archives\/raw\/master\/phx_new.ez\r\n<\/code><\/pre>\n<h2 id=\"Install_Node_js\">Install Node.js<\/h2>\n<p>Phoenix uses brunch.io to compile static assets, (javascript, css and more), so you will need to install Node.js.<\/p>\n<p>The recommended way to install Node.js is via\u00a0<code>nvm<\/code>\u00a0(node version manager).<\/p>\n<p>To install\u00a0<code>nvm<\/code>\u00a0we run this command:<\/p>\n<pre><code>curl -o- https:\/\/raw.githubusercontent.com\/creationix\/nvm\/v0.33.11\/install.sh | bash\r\n<\/code><\/pre>\n<p>To find out the versions of Node.js that are available for installation, you can type the following:<\/p>\n<pre><code>nvm ls-remote\r\n<\/code><\/pre>\n<p>This will output:<\/p>\n<pre><code>Output\r\n...\r\n     v8.8.1\r\n     v8.9.0   (LTS: Carbon)\r\n     v8.9.1   (LTS: Carbon)\r\n     v8.9.2   (LTS: Carbon)\r\n     v8.9.3   (LTS: Carbon)\r\n     v8.9.4   (LTS: Carbon)\r\n    v8.10.0   (LTS: Carbon)\r\n    v8.11.0   (LTS: Carbon)\r\n    v8.11.1   (LTS: Carbon)\r\n    v8.11.2   (LTS: Carbon)\r\n    v8.11.3   (LTS: Carbon)\r\n    v8.11.4   (LTS: Carbon)\r\n-&gt;  v8.12.0   (Latest LTS: Carbon)      \r\n...\r\n<\/code><\/pre>\n<p>Install the version you would like with the following command:<\/p>\n<pre><code>nvm install 8.12.0\r\n<\/code><\/pre>\n<p><strong>Note:<\/strong>\u00a0<em>If you would like to use a different version, replace\u00a0<code>8.12.0<\/code>\u00a0with the version you would like.<\/em><\/p>\n<p>Tell\u00a0<code>nvm<\/code>\u00a0to use the version we just downloaded:<\/p>\n<pre><code>nvm use 8.12.0\r\n<\/code><\/pre>\n<p>Verify node has successfully installed:<\/p>\n<pre><code>node -v\r\n<\/code><\/pre>\n<h2 id=\"Install_PostgreSQL\">Install PostgreSQL<\/h2>\n<p>You can install PostgreSQL easily using the apt packaging system.<\/p>\n<pre><code>sudo apt-get update\r\nsudo apt-get install postgresql postgresql-contrib\r\n<\/code><\/pre>\n<p>Open the PostgreSQL shell:<\/p>\n<pre><code>sudo -u postgres psql\r\n<\/code><\/pre>\n<p>Change the\u00a0<code>postgres<\/code>\u00a0password to a secure password:<\/p>\n<pre><code>\\password postgres    \r\n<\/code><\/pre>\n<p>After successfully changing the password, you can exit the PostgreSQL shell:<\/p>\n<pre><code>\\q\r\n<\/code><\/pre>\n<p>Restart the PostgreSQL service:<\/p>\n<pre><code>sudo systemctl restart postgresql.service\r\n<\/code><\/pre>\n<h2 id=\"Install_inotify_tools\">Install\u00a0<code>inotify-tools<\/code><\/h2>\n<p>This is a Linux-only filesystem watcher that Phoenix uses for live code reloading:<\/p>\n<pre><code>sudo apt-get install inotify-tools\r\n<\/code><\/pre>\n<h2 id=\"Create_a_Phoenix_application\">Create a Phoenix application<\/h2>\n<p>Create a new application:<\/p>\n<pre><code>mix phoenix.new ~\/phoenix_project_test\r\n<\/code><\/pre>\n<p>If the command returns the following error:<\/p>\n<pre><code>** (Mix) The task \"phx.new\" could not be found\r\n<\/code><\/pre>\n<p>You can fix it with the following command:<\/p>\n<pre><code>mix archive.install https:\/\/raw.githubusercontent.com\/phoenixframework\/archives\/master\/phx_new.ez\r\n<\/code><\/pre>\n<p>Now rerun the command to create a test Phoenix app:<\/p>\n<pre><code>mix phoenix.new ~\/phoenix_project_test\r\n<\/code><\/pre>\n<p>Change the PostgreSQL password in the config file with the password you set in the previous step:<\/p>\n<pre><code>nano config\/dev.exs    \r\n<\/code><\/pre>\n<p>The application will now be successfully created. Move to the application folder and start it:<\/p>\n<pre><code>cd ~\/phoenix_project_test\r\nmix ecto.create\r\nmix phx.server\r\n<\/code><\/pre>\n<p>Now the Phoenix application is up and running at port\u00a0<code>4000<\/code>.<\/p>\n<p><a href=\"https:\/\/www.vultr.com\/docs\/how-to-install-elixir-and-phoenix-framework-on-ubuntu-16-04\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial will show you how to install Elixir and Phoenix frameworks on a Vultr Ubuntu 16.04 server instance for development purposes. Prerequisites A new Vultr Ubuntu 16.04 server instance Logged in as a non-root sudo user. Update the system: sudo apt-get update Install Erlang Install Erlang with the following commands: cd ~ wget https:\/\/packages.erlang-solutions.com\/erlang-solutions_1.0_all.deb &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/05\/how-to-install-elixir-and-phoenix-framework-on-ubuntu-16-04\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Install Elixir and Phoenix Framework on Ubuntu 16.04&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13717","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13717","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=13717"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13717\/revisions"}],"predecessor-version":[{"id":13718,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13717\/revisions\/13718"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=13717"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=13717"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=13717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}