Home > Archive > Post > ๐Ÿ“[Post] Nginx ์„ค์น˜๋ฐฉ๋ฒ•.

๐Ÿ“[Post] Nginx ์„ค์น˜๋ฐฉ๋ฒ•.
Post Backend

๐Ÿ™‹โ€โ™‚๏ธ Nginx ๋ฅผ ์†Œ์Šค์—์„œ ์ง์ ‘ ์ปดํŒŒ์ผํ•˜์—ฌ ์„ค์น˜ํ•˜๋Š” ๋ฐฉ๋ฒ•.

  • ์ด ๋ฐฉ๋ฒ•์€ Homebrew๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ ๋„ Nginx๋ฅผ ์„ค์น˜ํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.
  • ์ด ๋ฐฉ๋ฒ•์€ macOS๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์„ค์น˜ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค.

1๏ธโƒฃ ํ•„์š”ํ•œ ๋„๊ตฌ ์„ค์น˜.

  • Nginx๋ฅผ ์ปดํŒŒ์ผํ•˜๋ ค๋ฉด Xcode ์™€ Xcode Command Line Tools ๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.
    • Xcode Command Line Tools ์„ค์น˜.
xcode-select --install
  • ํ”„๋กฌํ”„ํŠธ๊ฐ€ ๋‚˜ํƒ€๋‚˜๋ฉด ์„ค์น˜๋ฅผ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค.

2๏ธโƒฃ ์†Œ์Šค ์ฝ”๋“œ ๋‹ค์šด๋กœ๋“œ.

  • Nginx์˜ ์ตœ์‹  ์†Œ์Šค ์ฝ”๋“œ๋ฅผ Nginx ๊ณต์‹ ์‚ฌ์ดํŠธ์—์„œ ๋‹ค์šด๋กœ๋“œํ•˜๊ฑฐ๋‚˜ wget ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋‹ค์šด๋กœ๋“œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
curl -O http://nginx.org/download/nginx-1.26.1.tar.gz
  • ์œ„ ๋ช…๋ น์–ด์—์„œ nginx-1.26.1 ์€ ์„ค์น˜ํ•  Nginx ๋ฒ„์ „์— ๋”ฐ๋ผ ๋‹ฌ๋ผ์งˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
    • ์ตœ์‹  ๋ฒ„์ „์„ ์‚ฌ์šฉํ•˜๋ ค๋ฉด ๊ณต์‹ ์‚ฌ์ดํŠธ์—์„œ ์ตœ์‹  ๋ฒ„์ „ ๋ฒˆํ˜ธ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

3๏ธโƒฃ ์†Œ์Šค ์ฝ”๋“œ ์••์ถ• ํ•ด์ œ.

  • ๋‹ค์šด๋กœ๋“œํ•œ ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ์••์ถ• ํ•ด์ œํ•ฉ๋‹ˆ๋‹ค.
tar -zxvf nginx-1.26.1.tar.gz
cd nginx-1.26.1

4๏ธโƒฃ Nginx ์ปดํŒŒ์ผ ๋ฐ ์„ค์น˜.

  • Nginx๋ฅผ ์ปดํŒŒ์ผํ•˜๊ธฐ ์œ„ํ•ด ๋ช‡ ๊ฐ€์ง€ ์˜ต์…˜์„ ์ง€์ •ํ•œ ํ›„, make ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ปดํŒŒ์ผํ•˜๊ณ  ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.
./configure
make
sudo make install
  • ์ด ๋ช…๋ น์–ด๋Š” ๊ธฐ๋ณธ ์„ค์ •์œผ๋กœ Nginx๋ฅผ ์ปดํŒŒ์ผํ•˜๊ณ  /usr/local/nginx ์— ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.
  • ./configure ๋ช…๋ น์–ด์— ๋‹ค์–‘ํ•œ ์˜ต์…˜์„ ์ถ”๊ฐ€ํ•˜์—ฌ ์ปดํŒŒ์ผ ์„ค์ •์„ ์กฐ์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

5๏ธโƒฃ Nginx ์‹คํ–‰.

  • ์ปดํŒŒ์ผ์ด ์™„๋ฃŒ๋˜๋ฉด, Nginx๋ฅผ ๋‹ค์Œ ๋ช…๋ น์–ด๋กœ ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
sudo /usr/local/nginx/sbin/nginx
  • ์ด์ œ Nginx๊ฐ€ ์‹คํ–‰ ์ค‘์ผ ๊ฒƒ์ž…๋‹ˆ๋‹ค.
    • http://localhost ์— ์ ‘์†ํ•˜์—ฌ Nginx ๊ธฐ๋ณธ ํ™˜์˜ ํŽ˜์ด์ง€๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

6๏ธโƒฃ Nginx ์„ค์ • ํŒŒ์ผ

  • ์†Œ์Šค์—์„œ ์„ค์น˜ํ•œ Nginx์˜ ์„ค์ • ํŒŒ์ผ์€ /usr/local/nginx/conf/nginx.conf ์— ์žˆ์Šต๋‹ˆ๋‹ค.
    • ์ด ํŒŒ์ผ์„ ํŽธ์ง‘ํ•˜์—ฌ ์„ค์ •์„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
sudo vi /usr/local/nginx/conf/nginx.conf
  • ์„ค์ •์„ ๋ณ€๊ฒฝํ•œ ํ›„ Nginx๋ฅผ ์žฌ์‹œ์ž‘ํ•˜์—ฌ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ์ ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
sudo /usr/local/nginx/sbin/nginx -s reload

7๏ธโƒฃ Nginx ์„œ๋น„์Šค ๊ด€๋ฆฌ

  • Nginx๋ฅผ ์‹œ์ž‘ํ•˜๊ณ  ์ค‘์ง€ํ•˜๋Š” ๋ช…๋ น์–ด๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.
      1. Nginx ์‹œ์ž‘.
          sudo /usr/local/nginx/sbin/nginx
        
      1. Nginx ์ค‘์ง€.
          sudo /usr/local/nginx/sbin/nginx -s stop
        
      1. Nginx ์žฌ์‹œ์ž‘.
          sudo /usr/local/nginx/sbin/nginx -s reload