๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Nginx

Nginx ์ปดํŒŒ์ผ ์„ค์น˜

by Soono991 2023. 5. 7.
๐Ÿ’ก ์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” Nginx ์ปดํŒŒ์ผ ์„ค์น˜์— ๋Œ€ํ•ด ์ •๋ฆฌํ•ด ๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

๊ฐ ๋ฆฌ๋ˆ…์Šค ์šด์˜์ฒด์ œ(๋ ˆ๋“œํ–‡, ๋ฐ๋น„์•ˆ)์—์„œ ์ œ๊ณตํ•˜๋Š” ํŒจํ‚ค์ง€ ๊ด€๋ฆฌ ๋„๊ตฌ๋ฅผ ์ด์šฉํ•˜๋ฉด ์†์‰ฝ๊ฒŒ Nginx๋ฅผ ์„ค์น˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ํ•˜์ง€๋งŒ ์ด๋ฒˆ์—๋Š” ์ง์ ‘ Nginx ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ๋‹ค์šด๋กœ๋“œํ•˜๊ณ  ์ปดํŒŒ์ผํ•˜์—ฌ ์„ค์น˜ํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

Red Hat(๋ ˆ๋“œํ–‡) : yum install nginx
Debian(๋ฐ๋น„์•ˆ) : apt-get insall nginx | apt install nginx

 

ํ•„์ˆ˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๊ตฌ์„ฑ

Nginx๋Š” C ์–ธ์–ด๋กœ ์ž‘์„ฑ๋œ ํ”„๋กœ๊ทธ๋žจ์ด๊ธฐ ๋•Œ๋ฌธ์— GCC ์ปดํŒŒ์ผ๋Ÿฌ๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

๊ทธ๋ฆฌ๊ณ  ์ •๊ทœ ํ‘œํ˜„์‹ ํ˜ธํ™˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ธ PCRE ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ํ•„์š”ํ•˜๋ฉฐ, ์—”์ง„์—‘์Šค ๋ชจ๋“ˆ ์••์ถ•์„ ์œ„ํ•ด zlib ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

๋งˆ์ง€๋ง‰์œผ๋กœ ์—”์ง„์—‘์Šค๊ฐ€ ์•ˆ์ „ํ•˜๊ฒŒ ์›น ํŽ˜์ด์ง€๋ฅผ ์ œ๊ณตํ•˜๊ธฐ ์œ„ํ•ด OpenSSL๋„ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

 

  • GCC
  • pcre
  • zlib
  • openssl

์œ„ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋“ค์€ Nginx ์„ค์น˜ ์‹œ ํ•„์š”ํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋“ค์ด๊ธฐ ๋•Œ๋ฌธ์— ์ด ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋“ค๊นŒ์ง€ ์ง์ ‘ ์„ค์น˜ํ•˜์ง€๋Š” ์•Š๊ณ  ํŒจํ‚ค์ง€ ๊ด€๋ฆฌ ๋„๊ตฌ๋ฅผ ํ†ตํ•ด ์„ค์น˜ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

Red Hat(๋ ˆ๋“œํ–‡)
yum groupinstall "Development Tools"
yum intall pcre pcre-devel ๋˜๋Š” intall pcre*
yum intall zlib zlib-devel ๋˜๋Š” intall zlib*
yum intall openssl openssl-devel

Debian(๋ฐ๋น„์•ˆ)
apt-get install build-essential
apt-get install libpcre3 libpcre3-dev
apt-get install zlib1g zlib1g-dev
apt-get install oepnssl libssl-dev

 

Nginx ์†Œ์Šค ์ฝ”๋“œ ๋‹ค์šด๋กœ๋“œ

 

Nginx ๋‹ค์šด๋กœ๋“œ ํŽ˜์ด์ง€

 

Nginx ๋‹ค์šด๋กœ๋“œ ํŽ˜์ด์ง€๋กœ ๊ฐ€์„œ nginx ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ๋‹ค์šด๋กœ๋“œ ํ•ฉ๋‹ˆ๋‹ค.

๊ฐ€์žฅ ์ตœ๊ทผ์ธ 23๋…„ 4์›” 11์ผ์— Nginx 1.24.0 ๋ฒ„์ „์ด stable ๋˜์—ˆ๋‹ค๊ณ  ํ•˜์—ฌ 1.24.0 ๋ฒ„์ „์œผ๋กœ ๋‹ค์šด๋กœ๋“œ ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

 

๋ฆฌ๋ˆ…์Šค์—์„œ ์„ค์น˜๋ฅผ ์ง„ํ–‰ํ•  ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— ๋งํฌ๋ฅผ ํด๋ฆญํ•˜์ง€ ์•Š๊ณ  ๋ณต์‚ฌํ•ฉ๋‹ˆ๋‹ค.

http://nginx.org/download/nginx-1.24.0.tar.gz

 

Nginx๋ฅผ ์„ค์น˜ํ•  src ๋ผ๋Š” ๋””๋ ‰ํ„ฐ๋ฆฌ๋ฅผ ๋งŒ๋“ค๊ณ  ์ด ๋””๋ ‰ํ„ฐ๋ฆฌ์— ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ๋‹ค์šด๋กœ๋“œ ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

mkdir src && cd src    # ๋””๋ ‰ํ„ฐ๋ฆฌ ์ƒ์„ฑ
wget http://nginx.org/download/nginx-1.24.0.tar.gz # Nginx ์†Œ์Šค ๋‹ค์šด๋กœ๋“œ
tar zxf nginx-1.24.0.tar.gz # ์••์ถ• ํ•ด์ œ

 

 

Nginx ์„ค์น˜

์ด์ œ ๋‹ค์šด๋กœ๋“œํ•œ ํŒŒ์ผ๋กœ Nginx๋ฅผ ์„ค์น˜ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

 

cd nginx-1.24.0
./configure # ๊ธฐ๋ณธ ๊ตฌ์„ฑ ์„ค์ •
make
make install

 

์ง€๊ธˆ์€ ./configure ์— ์•„๋ฌด๋Ÿฐ ์˜ต์…˜๋„ ์„ค์ •ํ•˜์ง€ ์•Š์•˜๋Š”๋ฐ ๊ธฐ๋ณธ ๊ตฌ์„ฑ ์„ค์ •์‹œ ์˜ต์…˜์„ ์ „๋‹ฌํ•  ์ˆ˜ ์žˆ๊ณ  ์ถ”ํ›„์— ๋”ฐ๋กœ ์˜ต์…˜์„ ๋ณ€๊ฒฝํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ์˜ต์…˜์— ๊ด€ํ•ด์„œ๋Š” ์•„๋ž˜ ๋งํฌ๋ฅผ ์ฐธ๊ณ ํ•ด์ฃผ์‹œ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

 

 

GitHub - kiekk/book-nginx-http-server

Contribute to kiekk/book-nginx-http-server development by creating an account on GitHub.

github.com

   

 

Nginx ์‹คํ–‰

์„ค์น˜๊ฐ€ ๋‹ค ๋˜์—ˆ์œผ๋ฉด ์ •์ƒ์ ์œผ๋กœ ์„ค์น˜๊ฐ€ ๋œ ๊ฒƒ์ธ์ง€ ํ™•์ธ์„ ํ•ด๋ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์•„๋ž˜ ๋ช…๋ น์–ด๋กœ nginx๊ฐ€ ์ œ๋Œ€๋กœ ์„ค์น˜๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

service nginx status

service nginx start
service nginx stop
service nginx reload
service nginx restart

 

์œ„์™€ ๊ฐ™์ด service ๋ช…๋ น์–ด๋กœ nginx๋ฅผ ์‹คํ–‰/์ค‘์ง€/์žฌ์‹œ์ž‘๋“ฑ์„ ํ•  ์ˆ˜ ์žˆ๊ณ , ์•„๋ž˜์™€ ๊ฐ™์ด nginx ๋ช…๋ น์–ด๋กœ ์ œ์–ดํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

 

 

Nginx๋ฅผ ์„ฑ๊ณต์ ์œผ๋กœ ์‹คํ–‰ํ•˜๊ฒŒ ๋˜๋ฉด ์œ„์™€ ๊ฐ™์€ ๋กœ๊ทธ๊ฐ€ ์ถœ๋ ฅ๋˜๋ฉฐ, ํŽ˜์ด์ง€ ์ ‘์† ์‹œ Nginx WelCome ํŽ˜์ด์ง€๊ฐ€ ์ถœ๋ ฅ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค.

 

 

 

 

์ฐธ๊ณ  ์ž๋ฃŒ

๋Œ“๊ธ€