NocoBaseをnode環境でインストールします。
nodejs yarn のインストール
# nvm導入
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
# export以下をコピペして実行
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# bashに反映
source ~/.bashrc
# 確認
nvm -v
nvm install 20
node -v
# v20.18.2
# yarnのインストール
npm install -g yarn
yarn -v
# 1.22.22
nginxのインストール
$ sudo dnf -y install nginx
# nginx を起動する
$ sudo systemctl start nginx.service
# nginx を自動起動
$ sudo systemctl enable nginx.service
EC2のセキュリティグループのインバウンドルールで80ポートを開放する
postgresqlのインストール
sudo dnf install -y postgresql15-server
sudo postgresql-setup initdb
sudo passwd postgres
sudo systemctl start postgresql
sudo systemctl enable postgresql
# postgresqlのバージョンによってはログイン設定を変更する必要がある。
# ページ下部その他に記載
NocoBase install
DB設定を公式から変更。初期DBで接続する
yarn create nocobase-app my-nocobase-app -d postgres \
-e DB_HOST=localhost \
-e DB_PORT=5432 \
-e DB_DATABASE=postgres \
-e DB_USER=postgres \
-e DB_PASSWORD=postgres \
-e TZ=Asia/Tokyo \
-e NOCOBASE_PKG_USERNAME= \
-e NOCOBASE_PKG_PASSWORD=
プロジェクトディレクトリに移動
cd my-nocobase-app
# 依存関係をインストール
yarn install --production
# NocoBase をインストール
yarn nocobase install --lang=ja-JP
# NocoBase を起動
yarn start -d
せっかくなので公式のnginxの設定を利用する
yarn nocobase create-nginx-conf
vim ./storage/nocobase.conf
# server_nameを指定のドメインに書き換えて:wq
cp ./storage/nocobase.conf /etc/nginx/sites-enabled/nocobase.conf
その他
EC2のメモリが少ない環境のためyarn install
すら落ちるので、swap領域とメモリ上限の設定を変更
参考
# bashの設定変更
export NODE_OPTIONS="--max-old-space-size=1024"
# swapつい
sudo dd if=/dev/zero of=/swapfile bs=1M count=2048
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon -s
postgresのログインの初期状態がpeerなので変更
su - postgres
psql
ALTER ROLE postgres PASSWORD 'postgres';
exit
sudo vim /var/lib/pgsql/data/pg_hba.conf
# ident -> passwordに変更
systemctl restart postgresql