How To Install Phoenix Framework on CentOS 7

Phoenix is an emerging Elixir-based web development framework. It is intended to supply high development productivity, rich features, and strong runtime functionality.

Table of Contents

Step 1. First let’s start by ensuring your system is up-to-date.

Step 2. Installing Required Packages.

Step 3. Installing Erlang.

Step 3. Installing Elixir.

Step 4. Installing Phoenix Framework.

Step 5. Installing PostgreSQL.

Step 6. Installing inotify-tools.

Step 7. Create a Phoenix application.

Step 8. Accessing Phoenix Framework.

Prerequisites

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root accge of Linount, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation the Phoenix Framework on a CentOS 7 server.
Install Phoenix Framework on CentOS 7

Step 1. First let’s start by ensuring your system is up-to-date.

yum clean all
yum -y install epel-release
yum -y update

Step 2. Installing Required Packages.

Install necessary packages:

yum install gcc gcc-c++ glibc-devel make ncurses-devel openssl-devel autoconf java-1.8.0-openjdk-devel wxBase.x86_64

Step 3. Installing Erlang.

First, Add Erlang official repository to install the latest Erlang:

wget http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
rpm -Uvh erlang-solutions-1.0-1.noarch.rpm

Install Erlang using command:

yum update
yum install erlang

Verify whether Erlangis installed or not by using the following command:

erl

Step 3. Installing Elixir.

First, Git clone to the Elixir repository:

git clone https://github.com/elixir-lang/elixir.git

Next, Go to the elixir directory:

cd elixir/
make clean test

Now, It is highly recommended to add Elixir’s bin path to your PATH environment variable:

export PATH="$PATH:/root/elixir/bin"

Verify whether Elixiris installed or not by using the following command:

iex

Step 4. Installing Phoenix Framework.

Use the following command to install Phoenix:

mix archive.install https://github.com/phoenixframework/archives/raw/master/phoenix_new.ez

Step 5. Installing PostgreSQL.

You can install PostgreSQL using YUM:

yum install -y postgresql-server
postgresql-setup initdb

Start the postgresql service:

systemctl start postgresql.service
systemctl enable postgresql.service

Set a password for the default PostgreSQL user “postgres”:

sudo -u postgres psql

Setup the database user authentication method:

nano /var/lib/pgsql/data/pg_hba.conf

Find the following section:

# IPv4 local connections:
host all all 127.0.0.1/32 ident
# IPv6 local connections:
host all all ::1/128 ident

Modify the authentication method of IPv4 local connections to md5:

# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all

Restart the postgresql service to take effect:

systemctl restart postgresql.service

Step 6. Installing inotify-tools.

Use the following command to install a required component “inotify-tools”:

yum install inotify-tools

Step 7. Create a Phoenix application.

Assume that you want to create a Phoenix application in the directory ~/idroot_project_1:

mix phoenix.new ~/wpcademy_project_1

This command will create the application directory ~/idroot_project_1 for you. Get into the directory and create a database:

cd ~/wpcademy_project_1
mix ecto.create

Fire up your application with the following command:

mix phoenix.server

Step 8. Accessing Phoenix Framework.

Phoenix Framework will be available on HTTP port 4000 by default. Open your favorite browser and navigate to http://yourdomain.com:4000/ or http://server-ip:4000 and complete the required the steps to finish the installation.

Congratulation’s! You have successfully installed Phoenix Framework. Thanks for using this tutorial for installing Phoenix Framework on CentOS 7 systems. For additional help or useful information, we recommend you to check the official Phoenix Framework web site.

Leave a Reply