1、安裝寶塔
#CentOS系統 wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh #Ubuntu系統 wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && sudo bash install.sh #Debian系統 wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && bash install.sh
安裝完成后,進入面板,點擊左側軟件商店,然后安裝 PM2管理器
、MongoDB
、Nginx
(使用域名訪問才需要安裝,反之不用)。
2、安裝fiora
Xshell 連接小雞后:
#拉取源碼並存放於/opt文件夾 git clone https://github.com/yinxin630/fiora.git -b master /opt/fiora cd /opt/fiora #安裝依賴,這里不能用npm,需要用yarn來安裝 npm i -g yarn yarn #構建 npm run build #轉移產物 npm run move-dist #啟動 npm start
運行后打開ip:9200
,注冊一個賬號,然后可以看SSH
客戶端運行日志,獲取自己的userId
。
如果ip:9200
打不開的,可以檢查下防火牆,CentOS
系統可以使用以下命令:
#CentOS 6 iptables -I INPUT -p tcp --dport 9200 -j ACCEPT service iptables save service iptables restart #CentOS 7 firewall-cmd --zone=public --add-port=9200/tcp --permanent firewall-cmd --reload
接下來新建Systemd
配置文件 ,再將自己的賬號設置成管理員,先使用Ctrl+C
斷開運行。
#先給node做個軟連接,不然后面會啟動失敗 ln -sf $(which node) /usr/bin/node #修改運行端口,可以默認
export Administrator=【替換你userID】 Port=9200 #以下命令一起復制進SSH客戶端運行 cat > /etc/systemd/system/fiora.service <<EOF [Unit] Description=fiora After=network.target Wants=network.target [Service] Type=simple PIDFile=/var/run/fiora.pid ExecStart=$(command -v npm) start WorkingDirectory=/opt/fiora Environment=NODE_ENV=production Administrator=$Administrator Port=$Port User=root Restart=on-failure RestartSec=42s [Install] WantedBy=multi-user.target EOF
#設置開機啟動
systemctl start fiora
# 在開機時啟用服務
systemctl enable fiora
# 在開機時禁用服務
systemctl disable fiora
3、域名反代
1.寶塔面板里面,先點擊左側網站,添加站點,然后再點擊添加好了的域名
2.網址 - 域名 - 設置- 反向代理 - 增加反向代理
# 目標URL http://127.0.0.1:9200