Qiita
Node-REDをVagrant上で立ち上げて、ブラウザで確認すると同内容です。
# cat /etc/debian_version
9.5
構築
割愛
sudo su -
apt-get update
apt-get upgrade -y
apt-get install -y vim
curl https://gist.githubusercontent.com/iganari/a2baec1af976425cc8e21ccd68cf5585/raw/b6fce2cc91e1c77da759af1d2ea7b771b597787f/_vimrc -o /root/.vimrc
ls -la /usr/bin/vim.basic
unlink /etc/alternatives/editor
ln -s /usr/bin/vim.basic /etc/alternatives/editor
apt --purge remove -y nano
rm -rfv /etc/localtime &&\
ln -s /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
echo 'LANG="en_US.UTF-8"' > /etc/default/locale
nodejs version8 をインストールする
- 既存のnodejsを削除して、公式からインストールスクリプトを用いてインストール
- 意図したnodejsをインストールした後にNode-REDもインストール
apt remove --purge -y nodejs
curl -sL https://deb.nodesource.com/setup_8.x | /bin/bash
apt-get install -y nodejs
npm install -g --unsafe-perm node-red
- なぜ、nodejsはv8なのか :thinking_face:
作業ユーザ作成
username='node-red'
useradd -m -s /bin/bash ${username}
echo "${username} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/${username}
chmod 0440 /etc/sudoers.d/${username}
cp /root/.vimrc /home/${username}/.vimrc
chown ${username}:${username} /home/${username}/.vimrc
Node-RED をnpmからインストールする
su - node-red
- 専用のディスクトリを作成し、node-redをインストール
mkdir /opt/nodered-vagrant
chmod 0777 -R /opt/nodered-vagrant
cd /opt/nodered-vagrant
npm install node-red
sudo su -
wget "https://raw.githubusercontent.com/iganari/nodered-vagrant/master/bin/usr/bin/node-red-start" -O /usr/bin/node-red-start
wget "https://raw.githubusercontent.com/iganari/nodered-vagrant/master/bin/usr/bin/node-red-stop" -O /usr/bin/node-red-stop
chmod 0755 /usr/bin/node-red-st*
chown root:root /usr/bin/node-red-st*
wget "https://raw.githubusercontent.com/iganari/nodered-vagrant/master/bin/etc/systemd/system/node-red.service" -O /etc/systemd/system/node-red.service
chmod 0755 /etc/systemd/system/node-red.service
chown root:root /etc/systemd/system/node-red.service
systemctl start node-red
systemctl enable node-red
ブラウザで確認
http://192.168.33.131:1880/
ソース全体
簡単な構築方法含め、以下のレポジトリにまとめたので確認してみて下さい :blush:
https://github.com/iganari/nodered-vagrant