👉OCI환경설정 / OCI environment settings
👉npm init 했을때 다음과 같이 npm이 없다면 npm설치합니다.
If npm is not present when you run npm init, install npm.
ubuntu@app-20251223-1824:~/dockerApp/routes$ npm init
Command 'npm' not found, but can be installed with:
sudo apt install npm
sudo apt install npm
👉nodejs 최신버전 설치 / Install the latest version of nodejs
# NVM 설치 스크립트 실행 (공식 GitHub에서 가져옴)
# Run the NVM installation script (from the official GitHub)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
# 쉘 재시작하거나 설정 적용
# Restart shell or apply settings
source ~/.bashrc # 또는 ~/.zshrc nếu Zsh 사용 중
# (터미널 재시작해도 됨)
# 설치 확인 / Check installation
nvm --version
# 최신 Current 버전 설치 / Install the latest Current version
nvm install node # 현재 v25.2.1 설치됨
# 또는 최신 LTS 버전 설치
# or install the latest LTS version
nvm install --lts
# 사용 중인 버전 확인
# Check the version you are using
node -v
npm -v
👉mysql 설치 하기 / Install mysql
sudo apt update
sudo apt install mysql-server
✔️다음과 같은 명령어로 mysql실행 상태를 확인 합니다.
Check the mysql execution status with the following command.
service mysql status
#또는 / or
sudo systemctl status mysql
✔️그러면 다음과 같이 active 메세지가 보이면 정상 설치된 것입니다.
If you see an active message like this, it means it was installed successfully.
● mysql.service - MySQL Community Server
Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)
Active: active (running) since Wed 2025-12-24 07:05:58 UTC; 1min 42s ago
Process: 27273 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 27287 (mysqld)
Status: "Server is operational"
Tasks: 37 (limit: 14233)
Memory: 365.5M (peak: 379.8M)
CPU: 806ms
CGroup: /system.slice/mysql.service
└─27287 /usr/sbin/mysqld
Dec 24 07:05:57 app-20251223-1824 systemd[1]: Starting mysql.service - MySQL Community Server...
Dec 24 07:05:58 app-20251223-1824 systemd[1]: Started mysql.service - MySQL Community Server.
✔️mysql secure installation을 실행합니다.
Run mysql secure installation.
✔️아래 설정을 참조하세요 / See settings below
ubuntu@app-20251223-1824:~/dockerApp/routes$ sudo mysql_secure_installation
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
Skipping password set for root as authentication with auth_socket is used by default.
If you would like to use password authentication instead, this can be done with the "ALTER_USER" command.
See https://dev.mysql.com/doc/refman/8.0/en/alter-user.html#alter-user-password-management for more information.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
✔️OCI방화벽 오픈 / OCI Firewall Open
— 일단 전체 오픈 설정함 / First, set the entire open
✔️iptables방화벽 오픈 / Open iptables firewall
⭐주의:22번포트는 절대 막지마세요 다시 로그인 못합니다.(vm삭제해야 함)
Caution: Never block port 22. You will not be able to log in again (you will need to delete the VM).
— iptables persistant설치(셋팅 영구저장)
Install iptables persistent (permanently save settings)
sudo apt update
sudo apt install iptables-persistent
✔️방화벽 오픈
# 3000번 오픈 / 3000 open
sudo iptables -I INPUT 1 -p tcp --dport 3000 -j ACCEPT
# 확인 (1번에 있어야 함) / Check (should be at 1)
sudo iptables -L INPUT --line-numbers -v -n
# 영구 저장 / Save permanently
sudo netfilter-persistent save
⭐방화벽 규칙 삭제하려면(2번을 삭제하는 경우)
To delete a firewall rule (if deleting step 2)
— 실행 후 원래 2번이었던 규칙이 사라지고, 아래 규칙들이 하나씩 위로 올라옵니다 (3번 → 2번, 4번 → 3번 …)
After execution, the original rule number 2 disappears, and the rules below move up one by one (number 3 → number 2, number 4 → number 3…)
sudo iptables -D INPUT 2
✔️방화벽 설정(필수적으로 오픈해야 하는 포트)
Firewall settings (ports that must be opened)
# 8000번 포트 허용 (맨 위에 삽입)
sudo iptables -I INPUT 1 -p tcp --dport 8000 -j ACCEPT
# 443번 포트 허용 (HTTPS, 맨 위에 삽입 → 이제 1번이 됨)
sudo iptables -I INPUT 1 -p tcp --dport 443 -j ACCEPT
# 80번 포트 허용 (HTTP, 맨 위에 삽입 → 이제 1번이 됨)
sudo iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT
#3306번 포트허용 (MYSQL포트)
sudo iptables -I INPUT 1 -p tcp --dport 3306 -j ACCEPT
# 영구저장
sudo netfilter-persistent save
✔️최종 iptables방화벽 셋팅 확인
Check the final iptables firewall settings
ubuntu@app-20251223-1824:~/dockerApp$ sudo iptables -L INPUT --line-numbers -v -n
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
1 9 942 ACCEPT 6 -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:3306
2 24531 1855K ACCEPT 6 -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
3 8 384 ACCEPT 6 -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:443
4 53 2720 ACCEPT 6 -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8000
5 20 1338 ACCEPT 6 -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:3000
6 34403 403M ACCEPT 0 -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
7 1235 83838 ACCEPT 1 -- * * 0.0.0.0/0 0.0.0.0/0
8 256 25388 ACCEPT 0 -- lo * 0.0.0.0/0 0.0.0.0/0
9 7 332 ACCEPT 6 -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
10 1187 53712 REJECT 0 -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
11 0 0 ufw-before-logging-input 0 -- * * 0.0.0.0/0 0.0.0.0/0
12 0 0 ufw-before-input 0 -- * * 0.0.0.0/0 0.0.0.0/0
13 0 0 ufw-after-input 0 -- * * 0.0.0.0/0 0.0.0.0/0
14 0 0 ufw-after-logging-input 0 -- * * 0.0.0.0/0 0.0.0.0/0
15 0 0 ufw-reject-input 0 -- * * 0.0.0.0/0 0.0.0.0/0
16 0 0 ufw-track-input 0 -- * * 0.0.0.0/0 0.0.0.0/0
17 0 0 ACCEPT 0 -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
✔️mysql계정 추가 / Add a mysql account
— root로 접속 / Connect as root
sudo mysql -u root -p
— 사용자 계정 추가 / Add user account
CREATE DATABASE myapp CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER 'myapp'@'%' IDENTIFIED BY 'Myapp@1234';
GRANT ALL PRIVILEGES ON myapp.* TO 'myapp'@'%';
FLUSH PRIVILEGES;
EXIT;
— mysql접속 허용 / Allow mysql access
-127.0.0.1 : MySQL이 로컬 루프백(자기 자신)에서만 연결을 받아들임
127.0.0.1: MySQL accepts connections only on the local loopback (itself)
-0.0.0.0 : 모든 네트워크 인터페이스에서 연결을 받아들임
0.0.0.0: Accept connections on all network interfaces
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
이 줄을 / Change this line
bind-address = 127.0.0.1
이렇게 바꿉니다. / to this
bind-address = 0.0.0.0
— mysql 재시작 / restart mysql
sudo systemctl restart mysql
👉여기까지 완료하면 환경설정이 완료됩니다.
Once you’ve completed this, your setup is complete.