スポンサーリンク

Phoenix1.2.1のインストール(Windows8.1+Vagrant+CentOS7.3+Elixir1.3.4でPhoenix1.2.1)

前回は、なぜか、–no-brunch しないとうまくいかず、CSSやjavascriptがうまくいかない感じであった。

http://twosquirrel.mints.ne.jp/?p=14316

今回は、以下の記事を参考に、もう一度、CentOS7.3に、Phoenixをインストールしてみる。

How to Install the Phoenix Framework on CentOS 7
Modified on: Mon, Jul 11, 2016 at 5:54 pm EST
https://www.vultr.com/docs/how-to-install-the-phoenix-framework-on-centos-7

(環境)
Windows 8.1
VirtualBox 5.1.14
Vagrant 1.9.1
CentOS7.3
Erlang/OTP 19
Elixir 1.3.4
Phoenix 1.2.1

(0-1)VagrantでCentOS7.3のセットアップ

cd c:\vm
mkdir centos73_phoenix5
cd centos73_phoenix5
vagrant init bento/centos-7.3

作成されたVagrantfileを以下のように訂正してから、

vagrant up

image

image

(0-2)TeraTermでログイン

127.0.0.1
2222
vagrant
vagrant

image image

(1)Update the system

sudo yum -y install epel-release
sudo yum -y update

image image

image

sudo reboot

もう一度、TeraTermでログイン

image

(2)Install Erlang

cd ~
wget http://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
sudo rpm -Uvh erlang-solutions-1.0-1.noarch.rpm
sudo yum -y install erlang

image image

image  image

image

Erlangがインストールされたことを確認。

erl

image

Erlang/OTP 19 がインストールされたようである。

Ctrl + C を2回入力してErlang shellから脱出する。

image

(参考)
Erlang
https://packages.erlang-solutions.com/erlang/

(3)Install Elixir

今回は、Elixir 1.3.4 をインストールする。

cd /usr/bin
sudo mkdir elixir
cd /usr/bin/elixir
sudo wget https://github.com/elixir-lang/elixir/releases/download/v1.3.4/Precompiled.zip
sudo yum -y install unzip
sudo unzip Precompiled.zip

image image

image

/usr/bin/elixir/bin/elixir -v

image

Elixir 1.3.4 がインストールされたようである。

PATHを設定する。(これがいつも私には困難!)

sudo vi /etc/profile

image

↓ボタンで一番下へ行き、「o」を押す (→INSERTモードになる)

image

以下の文字列を挿入

export PATH="$PATH:/usr/bin/elixir/bin:/usr/bin/node-v6.9.5-linux-x64/bin"

image

「Esc」+ 「:」+「w」+「q」を順番に押す

image

Enter を押す

image

source /etc/profile

image

elixir -v

image

うむ、ちゃんとelixirにPATHが通ったらしい。。。(ここら辺がいつも面倒)

Hex package manager のインストール

cd ~
mix local.hex

Answer Y during the installation process.

image

(参考)
Elixir
https://github.com/elixir-lang/elixir/releases/

(4)Install Phoenix

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

Answer Y during the installation process.

image

(参考)
Phoenix
http://www.phoenixframework.org/docs/installation

(5)Install Node.js

cd ~
wget https://nodejs.org/download/release/v6.9.5/node-v6.9.5-linux-x64.tar.xz
sudo yum -y install xz
xz -d node-v6.9.5-linux-x64.tar.xz
tar -xvf node-v6.9.5-linux-x64.tar
sudo mv ~/node-v6.9.5-linux-x64 /usr/bin/

image image

image image

image

Node.js v6.9.5 がインストールされたようである。

(参考)
Node.js
https://nodejs.org/ja/download/releases/

(6)Install PostgreSQL

sudo yum install -y postgresql-server
sudo postgresql-setup initdb

image image

image

postgresql serviceの起動

sudo systemctl start postgresql.service
sudo systemctl enable postgresql.service

image

Postgresqlで、ユーザー: postgres のパスワードを設定

sudo -u postgres psql

image

postres=# と表示されたら、

\password postgres

として、任意のパスワード(今回は、postgres とする)を2回入力。

その後、

\q

でpostgresの画面を終了。

image image

Setup the database user authentication method:

sudo vi /var/lib/pgsql/data/pg_hba.conf

image

矢印ボタンで下の方へ行き、# IPv4 local connections: といったところへ行く。

image

「i」を押す。

image

以下のように、2か所の ident を、md5 に書き換える

image

「Esc」+「w」+「q」で、Enter

image

postgresqlの再起動

sudo systemctl restart postgresql.service

image

(7)Intall inotify-tools

sudo yum -y install inotify-tools

image

(8)Create a Phoenix application

今回、

Windows8.1(ホストOS)の、c:/vm/centos73_phoenix5/

CentOS7.3(ゲストOS)の、/vatrant/

の中身が一緒になっている。

cd /vagrant

mix phoenix.new phoenix_project_1

cd phoenix_project_1

mix ecto.create

途中、何か聞かれたら、「Y」と入力して、Enter。

残念ながら、エラー

image

理由は分からない。。。

(9)困ったので、とりあえず、いったん、

vagrant halt

して、

vagrant up

TeraTermでログイン

cd /vagrant

mix phoenix.new sample

何か聞かれたら、 Y と入力してEnter

image

image

しかし、ここまでがんばったのに、

* error command failed to execute, please run the following command again after installation: “npm install && node node_modules/brunch/bin/brunch build”

のエラー。

どうやっても、このエラー解決できない。ググっても私の能力では解決方法が見つからない。

 

https://github.com/npm/npm/issues/12733
ホストOSがWindowsでVagrantを使っていて、ゲストOSがLinuxのときに、npm installするときは、

–nobin-links

を付けた方がよいとかいう噂がちらほら、、、

cd /vagrant/sample
mix ecto.create

npm install –no-bin-links

image

node node_modules/brunch/bin/brunch build

image

mix phoenix.server

image

おっ!初めて、エラーが出ていない。。。

ホストOS(Windows8.1)で、http://localhost:4000

image

これで行けたみたい!

<はまりポイント>

ホストOSがWindowsで、(Vagrantを用いて)ゲストOSがLinux(UbuntuやCentOS)のときに、

mix phoenix.new xxxxxx

すると、

“npm install && node node_modules/brunch/bin/brunch build”

が実行できない。これは、

cd xxxxxx

npm install –no-bin-links
node node_modules/brunch/bin/brunch build

を行うことにより解決できる。(たぶん、、、)

日本語でググっても解決しない場合は、必ず英語でググるようにしないと、、、

(参考)

Erlang
https://packages.erlang-solutions.com/erlang/

Elixir
https://github.com/elixir-lang/elixir/releases/

Node.js
https://nodejs.org/ja/download/releases/

viコマンド集
http://www.ritsumei.ac.jp/~tomori/vi.html

Phoenix
http://www.phoenixframework.org/docs/installation

symlink protocol error #12733
Closed    joenmarz opened this issue on 18 May 2016 · 6 comments
https://github.com/npm/npm/issues/12733

スポンサーリンク