-
Notifications
You must be signed in to change notification settings - Fork 7
๐ชต 3. ์ธํ๋ผ ์ค์ต(2) : ๋์ปค ์์ด ๋ฐฐํฌํ๊ธฐ
ssum1ra edited this page Dec 5, 2024
·
1 revision
# 1. ๊ธฐ๋ณธ ์
๋ฐ์ดํธ
sudo apt update
sudo apt upgrade -y
# 2. Node.js ์ค์น
# node.js 20.0 ๋ฒ์ ์ผ๋ก ์ค์น
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs
# 3. Nginx ์ค์น
# 2024-11-11 ๊ธฐ์ค ubuntu-22.04์์์๋ฌ
~~sudo apt install nginx -y~~
# ๊ณต์๋ฌธ์ ์ฐธ๊ณ ํด์ ์ค์น
~~~~https://nginx.org/en/linux_packages.html#Ubuntu
# 4. PM2 ์ค์น
sudo npm install -g pm2
# 5. git ์ค์น
sudo apt install git -y
-
curl ๋ช ๋ น ์ฌ์ฉ ์ , ํฌํธ๋ฅผ ์ด์ด๋์ด์ผ ํ๋ค.
-
๋๋ ํ ๋ฆฌ ๊ถํ ์ค์ (์ฐธ๊ณ )
# ์ผ๋ฐ์ ์ธ nginx ์ค์ ์์ # ํ์ฌ ๋ฐฐํฌ ๊ณผ์ ์์ ์ฌ์ฉํ๊ณ ์์ง ์๋ค. sudo chown -R $USER:$USER /var/www/html ls -ld /var/www/html
-
/var/www/html
: ์น ์๋ฒ๊ฐ ๊ธฐ๋ณธ์ ์ผ๋ก ์น ํ์ผ์ ์ ๊ณตํ๋ ๋ฃจํธ ๋๋ ํฐ๋ฆฌ
-
# ๋ฆฌํฌ์งํ ๋ฆฌ ํด๋ก
~$ git clone [๋ฆฌํฌ์งํ ๋ฆฌ์ฃผ์]
~/[project ์ด๋ฆ]/client$ npm run build
sudo systemctl start nginx # Nginx ์๋น์ค๋ฅผ ์ฆ์ ์์
sudo systemctl enable nginx # ์๋ฒ ๋ถํ
์ Nginx๊ฐ ์๋์ผ๋ก ์์๋๋๋ก ์ค์
sudo mkdir -p /etc/nginx/sites-available # ์ฌ์ดํธ๋ณ ์ค์ ํ์ผ์ ์ ์ฅํ ๋๋ ํฐ๋ฆฌ ์์ฑ
sudo mkdir -p /etc/nginx/sites-enabled # ํ์ฑํ๋ ์ฌ์ดํธ ์ค์ ํ์ผ์ ์ํ ๋๋ ํฐ๋ฆฌ ์์ฑ
sudo vim /etc/nginx/nginx.conf
# Nginx๊ฐ ๊ฐ ์ฌ์ดํธ์ ๋ํ ์ค์ ํ์ผ์ ์๋์ผ๋ก ์ธ์ํ๊ณ ์ ์ฉํ๋๋ก
http {
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*; # ์ถ๊ฐ
...
}
sudo vim /etc/nginx/sites-available/[ํ๋ก์ ํธ ๋ช
]
server {
listen 80; # HTTP ๊ธฐ๋ณธ ํฌํธ 80์์ ์์ฒญ์ ์์
server_name [์ธ์คํด์ค์_PUBLIC_IP]; # ์๋ฒ์ ๊ณต์ธ IP ์ฃผ์ ๋๋ ๋๋ฉ์ธ ์ด๋ฆ ์ง์
location / {
root /home/ncloud/whiteboard/client/dist; # ์ ์ ํ์ผ์ ๋ฃจํธ ๊ฒฝ๋ก ์ค์
try_files $uri $uri/ /index.html; # ์์ฒญํ ํ์ผ์ด ์์ ๊ฒฝ์ฐ index.html๋ก ๋์ฒด (SPA ์ง์)
index index.html; # ๊ธฐ๋ณธ ์ธ๋ฑ์ค ํ์ผ ์ค์
}
# WebSocket์ ์ํ Socket.IO ํ๋ก์ ์ค์
location /socket.io/ {
proxy_pass http://localhost:3000; # ๋ก์ปฌ ์๋ฒ์ 3000 ํฌํธ๋ก ์์ฒญ์ ํ๋ก์
proxy_http_version 1.1; # WebSocket์ ์ํด HTTP/1.1 ์ฌ์ฉ
proxy_set_header Upgrade $http_upgrade; # WebSocket ์ฐ๊ฒฐ ์
๊ทธ๋ ์ด๋ ์์ฒญ
proxy_set_header Connection "upgrade"; # WebSocket ์ฐ๊ฒฐ ์
๊ทธ๋ ์ด๋ ์ค์
proxy_set_header Host $host; # ์๋ณธ ์์ฒญ์ ํธ์คํธ ํค๋ ์ ์ง
proxy_cache_bypass $http_upgrade; # WebSocket ์ฐ๊ฒฐ ์ ์บ์ ์ฐํ
proxy_read_timeout 86400s; # ํ๋ก์ ์ฝ๊ธฐ ํ์์์ ์ค์ (24์๊ฐ)
proxy_send_timeout 86400s; # ํ๋ก์ ์ ์ก ํ์์์ ์ค์ (24์๊ฐ)
}
# REST API (ํ์ํ ๊ฒฝ์ฐ)
location /api/ {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
# ์ฌ์ดํธ ์ค์ ํ์ผ์ ํ์ฑํํ๊ธฐ ์ํด ์ฌ๋ณผ๋ฆญ ๋งํฌ ์์ฑ
sudo ln -s /etc/nginx/sites-available/[ํ๋ก์ ํธ ๋ช
] /etc/nginx/sites-enabled/
# ์ค๋ฅ๊ฐ ์๋์ง ํ
์คํธ
sudo nginx -t
# Nginx ์๋น์ค๋ฅผ ์ฌ์์ํ์ฌ ๋ณ๊ฒฝ๋ ์ค์ ์ ์ฉ
sudo systemctl restart nginx
- Nginx๋ ์ ์ ํ์ผ์ ์ง์ ์๋นํ๋ฉด์, ํด๋ผ์ด์ธํธ์ ๋์ ์์ฒญ์ ๋ฐฑ์๋ ์๋ฒ๋ก ์ ๋ฌํ๋ ๋ฆฌ๋ฒ์ค ํ๋ก์ ์๋ฒ ์ญํ ์ ๋์์ ์ํํ๋ค.
~/[project ์ด๋ฆ]/server$ npm install -g @nestjs/cli
~/[project ์ด๋ฆ]/server$ npm run build
# PM2๋ฅผ ์ฌ์ฉํด dist/main.js ํ์ผ์ "whiteboard-server"๋ผ๋ ์ด๋ฆ์ผ๋ก ๋ฐฑ๊ทธ๋ผ์ด๋์์ ์คํ
~/[project ์ด๋ฆ]/server$ pm2 start dist/main.js --name "whiteboard-server"
# PM2 ๋ก๊ทธ
pm2 log
- PM2 (์ถํ ์์ฑ)
- ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ฐ๋ชฌ(๋ฐฑ๊ทธ๋ผ์ด๋) ๋ชจ๋๋ก ์คํํ๋ฏ๋ก, SSH ์ธ์ ์ด ์ข ๋ฃ๋๋๋ผ๋ ์ ํ๋ฆฌ์ผ์ด์ ์ด ๊ณ์ ์คํ๋๋ค.
- ๊ธฐํ ๊ธฐ๋ฅ
sudo chown -R $USER:$USER ~/whiteboard/client/dist
sudo chmod -R 755 ~/whiteboard/client/dist
~/[ํ๋ก์ ํธ ๋ช
]/client/dist$ sudo tail -f /var/log/nginx/error.log
2024/11/11 17:26:55 [crit] 3326#3326: *5 stat() "/home/ncloud/whiteboard/client/dist/index.html" failed (13: Permission denied), client: 121.136.217.193, server: 223.130.137.162, request: "GET /favicon.ico HTTP/1.1", host: "223.130.137.162", referrer: "http://223.130.137.162/"
2024/11/11 17:26:55 [crit] 3326#3326: *5 stat() "/home/ncloud/whiteboard/client/dist/index.html" failed (13: Permission denied), client: 121.136.217.193, server: 223.130.137.162, request: "GET /favicon.ico HTTP/1.1", host: "223.130.137.162", referrer: "http://223.130.137.162/"
2024/11/11 17:26:55 [crit] 3326#3326: *5 stat() "/home/ncloud/whiteboard/client/dist/index.html" failed (13: Permission denied), client: 121.136.217.193, server: 223.130.137.162, request: "GET /favicon.ico HTTP/1.1", host: "223.130.137.162", referrer: "http://223.130.137.162/"
2024/11/11 17:26:55 [crit] 3326#3326: *5 stat() "/home/ncloud/whiteboard/client/dist/index.html" failed (13: Permission denied), client: 121.136.217.193, server: 223.130.137.162, request: "GET /favicon.ico HTTP/1.1", host: "223.130.137.162", referrer: "http://223.130.137.162/"
2024/11/11 17:26:55 [crit] 3326#3326: *5 stat() "/home/ncloud/whiteboard/client/dist/index.html" failed (13: Permission denied), client: 121.136.217.193, server: 223.130.137.162, request: "GET /favicon.ico HTTP/1.1", host: "223.130.137.162", referrer: "http://223.130.137.162/"
2024/11/11 17:26:55 [crit] 3326#3326: *5 stat() "/home/ncloud/whiteboard/client/dist/index.html" failed (13: Permission denied), client: 121.136.217.193, server: 223.130.137.162, request: "GET /favicon.ico HTTP/1.1", host: "223.130.137.162", referrer: "http://223.130.137.162/"
2024/11/11 17:26:55 [crit] 3326#3326: *5 stat() "/home/ncloud/whiteboard/client/dist/index.html" failed (13: Permission denied), client: 121.136.217.193, server: 223.130.137.162, request: "GET /favicon.ico HTTP/1.1", host: "223.130.137.162", referrer: "http://223.130.137.162/"
2024/11/11 17:26:55 [crit] 3326#3326: *5 stat() "/home/ncloud/whiteboard/client/dist/index.html" failed (13: Permission denied), client: 121.136.217.193, server: 223.130.137.162, request: "GET /favicon.ico HTTP/1.1", host: "223.130.137.162", referrer: "http://223.130.137.162/"
2024/11/11 17:26:55 [crit] 3326#3326: *5 stat() "/home/ncloud/whiteboard/client/dist/index.html" failed (13: Permission denied), client: 121.136.217.193, server: 223.130.137.162, request: "GET /favicon.ico HTTP/1.1", host: "223.130.137.162", referrer: "http://223.130.137.162/"
2024/11/11 17:26:55 [error] 3326#3326: *5 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 121.136.217.193, server: 223.130.137.162, request: "GET /favicon.ico HTTP/1.1", host: "223.130.137.162", referrer: "http://223.130.137.162/"
- nginx๊ฐ dist ํด๋์ ํ์ผ๋ค์ ์ ๊ทผํ ๊ถํ์ด ์๋ค๋ ์๋ฏธ
sudo chmod 755 /home/ncloud
-
/home/ncloud
๋๋ ํ ๋ฆฌ๋ถํฐ ์ ๊ทผ ๊ถํ์ด ํ์- Nginx๊ฐ
/home/ncloud/whiteboard/client/dist/index.html
์ ์ ๊ทผํ ์ ์์ผ๋ ค๋ฉด ์์ ๋๋ ํฐ๋ฆฌ์๋ Nginx๊ฐ ์ฝ๊ธฐ ๋ฐ ์คํํ ์ ์๋ ๊ถํ์ด ํ์ํ๋ค.
- Nginx๊ฐ
# ํ๋ก ํธ์๋ ๋ค์ ๋น๋
cd ~/whiteboard/client
npm run build
# ๋ฐฑ์๋ ์ฌ์์
cd ~/whiteboard/server
npm run build
pm2 restart whiteboard-server
- AWS์ S3์ ์ ์ฌ
- ์์ฑ๋ ๋ฒํท์ ์ด๋ฆ์ ๋ณ๊ฒฝ ๋ถ๊ฐ๋ฅ
- ๋ฒํท ์ด๋ฆ์ ๊ฐ์ฒด์ ๋ํ ๋๋ฉ์ธ์ ํ์ฉ
- ๋ฐฐํฌํ ๊ฑฐ๋ฉด ๋ฐ๋์ ๊ณต๊ฐ
http://test-web30.s3-website.kr.object.ncloudstorage.com
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors({
origin: 'http://test-web30.s3-website.kr.object.ncloudstorage.com',
credentials: true,
});
app.useWebSocketAdapter(new IoAdapter(app));
await app.listen(3000);
}
bootstrap();
const newSocket = io('http://223.130.137.162:3000', {
transports: ['websocket'],
reconnection: true,
});
-
Nginx ์ค์ง
sudo systemctl stop nginx sudo systemctl disable nginx # ์ํ ํ์ธ sudo systemctl status nginx
- ํ์ํ ๋, ๋ง์ด๊ทธ๋ ์ด์
- ์ปค์คํ ๋๋ฉ์ธ ์ค์ ๊ฐ๋ฅ
- nginx: Linux packages
- ์์ฒญ์ ๋ณด๋๋๋ฐ ์๋ฌด ๋ฐ์์ด ์๋ค?
- ํฌํธ ๋ฌธ์ ์ผ ๊ฐ๋ฅ์ฑ์ด ํผ
- ACG ๊ด๋ฆฌ ์ ํ์
- 1. ๊ฐ๋ฐ ํ๊ฒฝ ์ธํ ๋ฐ ํ๋ก์ ํธ ๋ฌธ์ํ
- 2. ์ค์๊ฐ ํต์
- 3. ์ธํ๋ผ ๋ฐ CI/CD
- 4. ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์์ด Canvas ๊ตฌํํ๊ธฐ
- 5. ์บ๋ฒ์ค ๋๊ธฐํ๋ฅผ ์ํ ์์ CRDT ๊ตฌํ๊ธฐ
-
6. ์ปดํฌ๋ํธ ํจํด๋ถํฐ ์น์์ผ๊น์ง, ํจ์จ์ ์ธ FE ์ค๊ณ
- ์ข์ ์ปดํฌ๋ํธ๋ ๋ฌด์์ธ๊ฐ? + Headless Pattern
- ํจ์จ์ ์ธ UI ์ปดํฌ๋ํธ ์คํ์ผ๋ง: Tailwind CSS + cn.ts
- Tailwind CSS๋ก ๋์์ธ ์์คํ ๋ฐ UI ์ปดํฌ๋ํธ ์ธํ
- ์น์์ผ ํด๋ผ์ด์ธํธ ๊ตฌํ๊ธฐ: React ํ๊ฒฝ์์ ํจ์จ์ ์ธ ์น์์ผ ์ํคํ ์ฒ
- ์น์์ผ ํด๋ผ์ด์ธํธ ์ฝ๋ ๋ถ์ ๋ฐ ๊ณต์
- 7. ํธ๋ฌ๋ธ ์ํ ๋ฐ ์ฑ๋ฅ/UX ๊ฐ์
- 1์ฃผ์ฐจ ๊ธฐ์ ๊ณต์
- 2์ฃผ์ฐจ ๋ฐ๋ชจ ๋ฐ์ด
- 3์ฃผ์ฐจ ๋ฐ๋ชจ ๋ฐ์ด
- 4์ฃผ์ฐจ ๋ฐ๋ชจ ๋ฐ์ด
- 5์ฃผ์ฐจ ๋ฐ๋ชจ ๋ฐ์ด
- WEEK 06 ์ฃผ๊ฐ ๊ณํ
- WEEK 06 ๋ฐ์ผ๋ฆฌ ์คํฌ๋ผ
- WEEK 06 ์ฃผ๊ฐ ํ๊ณ