Now Loading ...
-
AWS EC2를 활용한 서버 배포
백엔드 개발의 마지막 단계는 개발을 완료한 서버를 배포하는 것이다!
이번 포스팅에서는 express.js로 개발한 서버를 AWS EC2 서비스를 활용하여 배포하는 방법을 단계별로 기록하겠습니다.
AWS EC2가 뭘까?
Amazon EC2(Elastic Compute Cloud)는 AWS(Amazon Web Services)의 클라우드 컴퓨팅 서비스로, 가상 서버인 인스턴스를 제공하여 사용자가 애플리케이션을 실행할 수 있도록 해줍니다.
사용자는 다양한 인스턴스 유형, CPU, 메모리, 스토리지 및 네트워킹 용량 등을 선택하여 필요한 리소스를 갖출 수 있습니다.
주요 특징
가상 서버 제공
EC2는 클라우드 환경에서 사용자가 가상 컴퓨터를 임대하여 애플리케이션을 실행할 수 있게 해줍니다.
다양한 인스턴스 유형
CPU, 메모리, 스토리지, 네트워킹 용량 등을 조합하여 다양한 인스턴스 유형을 제공하며, 애플리케이션의 요구사항에 맞는 인스턴스를 선택할 수 있습니다.
크기 조정 가능
EC2 인스턴스는 필요에 따라 용량을 늘리거나 줄일 수 있으며, 사용량에 따라 지불하는 방식인 온디맨드 인스턴스, 절감형 플랜, 스팟 인스턴스 등 다양한 요금 방식이 있습니다.
안전성
AWS의 강력한 보안 인프라를 활용하여 EC2 인스턴스를 안전하게 운영할 수 있습니다.
간편한 웹 인터페이스
AWS Management Console을 통해 EC2 인스턴스를 생성하고 관리할 수 있습니다.
네트워킹
EC2는 다양한 네트워킹 기능을 제공하며, 인스턴스 간 통신, 외부 접속 등을 설정할 수 있습니다.
다양한 운영체제 지원
EC2는 Windows, Linux, macOS 등 다양한 운영체제를 지원하며, 사용자 환경에 맞는 운영체제를 선택할 수 있습니다.
—
EC2 인스턴스를 사용하면 클라우드 환경에서 애플리케이션을 개발하고 배포할 수 있습니다.
하드웨어 제약 없이 컴퓨팅 용량을 확장할 수 있습니다.
다양한 인스턴스 유형을 활용하여 애플리케이션의 성능을 최적화할 수 있습니다.
사용량에 따라 비용을 지불할 수 있어 비용 효율성을 높일 수 있습니다.
EC2를 활용하여 서버 배포하는 방법은?
EC2로 서버를 배포하려면 당연히 AWS에 회원가입을 해야한다.
그런 다음 EC2 인스턴스를 생성하고 RDS (Relational Database Service)로 데이터베이스를 생성하여 서로 연결해줘야 한다.
이번 포스팅에서는 EC2 인스턴스를 생성하는 방법 위주로 다루고 다음 포스팅에서 RDS 데이터베이스에 대해 다룰 예정이다.
EC2 인스턴스 생성하기
1. 지역 → 아시아 태평양(서울)로 설정
2. EC2 → 인스턴스 시작
3. 서버 선택
4. 인스턴스 유형 선택
5. HTTP, HTTPS 허용
6. 키 페어 생성
7. 인스턴스 시작
EC2 인스턴스에서 프로젝트 실행하기
1. EC2 인스턴스 실행
2. EC2 에서 깃허브 활용 프로젝트 Clone
3. EC2 에서 의존성 패키치 설치
4. .env 파일 추가
5. DB 연결 후 생성
6. 프로젝트 실행
cf. background process : pm2
이번 프로젝트에서 사용한 express.js(node)는 foreground process이기 때문에 터미널이 종료되면 원격 서버도 함께 종료됩니다.
만약 실수로 원격으로 접속해 놓은 shell을 끄면(ubuntu@ 경로에서 exit; 명령어를 입력했거나 개발 환경 창을 종료한 경우) 로컬 경로(C:)로 돌아가고 원격에 접속해 있던 shell이 종료되기 때문에 원격 서버도 함께 종료됩니다.
하루종일 원격 서버에 접속해 두긴 어렵기 때문에 background process를 사용하면 shell의 종료 여부와 관계없이 원격 서버를 계속 실행할 수 있습니다.
background process를 사용하는 방법 중 하나는 pm2 라이브러리를 사용하는 것입니다.
포스팅이 너무 길어져서 pm2 적용도 다음 포스팅에서 다루도록 하겠습니다!
-continue
-
-
-
-
-
-
-
Manage blog comments with Giscus
Giscus is a free comments system powered without your own database. Giscus uses the Github Discussions to store and load associated comments based on a chosen mapping (URL, pathname, title, etc.).
To comment, visitors must authorize the giscus app to post on their behalf using the GitHub OAuth flow. Alternatively, visitors can comment on the GitHub Discussion directly. You can moderate the comments on GitHub.
Prerequisites
Create a github repo
You need a GitHub repository first. If you gonna use GitHub Pages for hosting your website, you can choose the corresponding repository (i.e., [userID].github.io)
The repository should be public, otherwise visitors will not be able to view the discussion.
Turn on Discussion feature
In your GitHub repository Settings, make sure that General > Features > Discussions feature is enabled.
Activate Giscus API
Follow the steps in Configuration guide. Make sure the verification of your repository is successful.
Then, scroll down from the manual page and choose the Discussion Category options. You don’t need to touch other configs.
Copy _config.yml
Now, you get the giscus script. Copy the four properties marked with a red box as shown below:
Paste those values to _config.yml placed in the root directory.
# External API
giscus_repo: "[ENTER REPO HERE]"
giscus_repoId: "[ENTER REPO ID HERE]"
giscus_category: "[ENTER CATEGORY NAME HERE]"
giscus_categoryId: "[ENTER CATEGORY ID HERE]"
-
-
Markdown from A to Z
Headings
To create a heading, add number signs (#) in front of a word or phrase. The number of number signs you use should correspond to the heading level. For example, to create a heading level three (<h3>), use three number signs (e.g., ### My Header).
Markdown
HTML
Rendered Output
# Header 1
<h1>Header 1</h1>
Header 1
## Header 2
<h2>Header 2</h2>
Header 2
### Header 3
<h3>Header 3</h3>
Header 3
Emphasis
You can add emphasis by making text bold or italic.
Bold
To bold text, add two asterisks (e.g., **text** = text) or underscores before and after a word or phrase. To bold the middle of a word for emphasis, add two asterisks without spaces around the letters.
Italic
To italicize text, add one asterisk (e.g., *text* = text) or underscore before and after a word or phrase. To italicize the middle of a word for emphasis, add one asterisk without spaces around the letters.
Blockquotes
To create a blockquote, add a > in front of a paragraph.
> Yongha Kim is the best developer in the world.
>
> Factos 👍👀
Yongha Kim is the best developer in the world.
Factos 👍👀
Lists
You can organize items into ordered and unordered lists.
Ordered Lists
To create an ordered list, add line items with numbers followed by periods. The numbers don’t have to be in numerical order, but the list should start with the number one.
1. First item
2. Second item
3. Third item
4. Fourth item
First item
Second item
Third item
Fourth item
Unordered Lists
To create an unordered list, add dashes (-), asterisks (*), or plus signs (+) in front of line items. Indent one or more items to create a nested list.
* First item
* Second item
* Third item
* Fourth item
First item
Second item
Third item
Fourth item
Code
To denote a word or phrase as code, enclose it in backticks (`).
Markdown
HTML
Rendered Output
At the command prompt, type `nano`.
At the command prompt, type <code>nano</code>.
At the command prompt, type nano.
Escaping Backticks
If the word or phrase you want to denote as code includes one or more backticks, you can escape it by enclosing the word or phrase in double backticks (``).
Markdown
HTML
Rendered Output
``Use `code` in your Markdown file.``
<code>Use `code` in your Markdown file.</code>
Use `code` in your Markdown file.
Code Blocks
To create code blocks that spans multiple lines of code, set the text inside three or more backquotes ( ``` ) or tildes ( ~~~ ).
<html>
<head>
</head>
</html>
def foo():
a = 1
for i in [1,2,3]:
a += i
Horizontal Rules
To create a horizontal rule, use three or more asterisks (***), dashes (---), or underscores (___) on a line by themselves.
***
---
_________________
Links
To create a link, enclose the link text in brackets (e.g., [Blue Archive]) and then follow it immediately with the URL in parentheses (e.g., (https://bluearchive.nexon.com)).
My favorite mobile game is [Blue Archive](https://bluearchive.nexon.com).
The rendered output looks like this:
My favorite mobile game is Blue Archive.
Adding Titles
You can optionally add a title for a link. This will appear as a tooltip when the user hovers over the link. To add a title, enclose it in quotation marks after the URL.
My favorite mobile game is [Blue Archive](https://bluearchive.nexon.com "All senseis are welcome!").
The rendered output looks like this:
My favorite mobile game is Blue Archive.
URLs and Email Addresses
To quickly turn a URL or email address into a link, enclose it in angle brackets.
<https://www.youtube.com/>
<fake@example.com>
The rendered output looks like this:
https://www.youtube.com/
fake@example.com
Images
To add an image, add an exclamation mark (!), followed by alt text in brackets, and the path or URL to the image asset in parentheses. You can optionally add a title in quotation marks after the path or URL.

The rendered output looks like this:
Linking Images
To add a link to an image, enclose the Markdown for the image in brackets, and then add the link in parentheses.
[](https://www.britannica.com/place/La-Mancha)
The rendered output looks like this:
Escaping Characters
To display a literal character that would otherwise be used to format text in a Markdown document, add a backslash (\) in front of the character.
\* Without the backslash, this would be a bullet in an unordered list.
The rendered output looks like this:
* Without the backslash, this would be a bullet in an unordered list.
Characters You Can Escape
You can use a backslash to escape the following characters.
Character
Name
`
backtick
*
asterisk
_
underscore
{}
curly braces
[]
brackets
<>
angle brackets
()
parentheses
#
pound sign
+
plus sign
-
minus sign (hyphen)
.
dot
!
exclamation mark
|
pipe
HTML
Many Markdown applications allow you to use HTML tags in Markdown-formatted text. This is helpful if you prefer certain HTML tags to Markdown syntax. For example, some people find it easier to use HTML tags for images. Using HTML is also helpful when you need to change the attributes of an element, like specifying the color of text or changing the width of an image.
To use HTML, place the tags in the text of your Markdown-formatted file.
This **word** is bold. This <span style="font-style: italic;">word</span> is italic.
The rendered output looks like this:
This word is bold. This word is italic.
Touch background to close