TIL/์‹ค์Šต

[Linux] Nginx์™€ Wordpress๋กœ WAS ๊ตฌ์„ฑ

s00ng 2024. 5. 13. 20:52

๐Ÿ“ŒNginx ๋ž€?

์ •์ ์ธ ๋ฆฌ์†Œ์Šค๋ฅผ ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ๋ณด๋‚ด์ฃผ๋Š” ์›น์„œ๋ฒ„์ด๋‹ค.

 

๐Ÿ“ŒWordpress ๋ž€?

์›น ์‚ฌ์ดํŠธ๋ฅผ ์‰ฝ๊ฒŒ ๋งŒ๋“ค์–ด์ค„ ์ˆ˜ ์žˆ๋Š” php & mysql ๊ธฐ๋ฐ˜ ํ”„๋ ˆ์ž„์›Œํฌ์ด๋‹ค.

 

๐Ÿ“Œ Php-fpm ์ด๋ž€?

  php ํŒŒ์ผ์„ ์‹คํ–‰ํ•ด์ฃผ๋Š” ํ”„๋กœ๊ทธ๋žจ์ด๋‹ค. Nginx & Wordpress ๊ตฌ์„ฑ์„ ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์œผ๋กœ ๋™์ž‘ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋Š” ์‹ค์งˆ์ ์ธ ์—ญํ• ์„ ํ•œ๋‹ค.

 

 

์ด๋ฒˆ ์‹ค์Šต์„ ํ†ตํ•ด, Nginx์™€ Wordpress๋กœ ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์„œ๋ฒ„(WAS) ๊ตฌ์„ฑ์„ ์ง„ํ–‰ํ•ด๋ณด๊ฒ ๋‹ค.


โœ… ์‹ค์Šต ํ™˜๊ฒฝ

  • Windows 11
  • VMware CentOS 8


1) ์›น ์„œ๋ฒ„ ์ค€๋น„

# nginx ์„ค์น˜
yum install -y nginx

 

 

2) php ์„ค์น˜

dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm 
dnf module reset php 
dnf install -y php php-mysqlnd php-fpm php-opcache php-curl php-json php-gd php-xml php-mbstring php-zip -y


wordpress๊ฐ€ php ๊ธฐ๋ฐ˜์ด๋ฏ€๋กœ, php๋ฅผ ์„ค์น˜ํ•ด์ค€๋‹ค.

 

 

3) php ์„ค์ •

vi /etc/php-fpm.d/www.conf

user = nginx # 24๋ฒˆ์ค„
group = nginx # 26๋ฒˆ์ค„
;listen.owner = nginx # 48๋ฒˆ์ค„ 
;listen.group = nginx # 49๋ฒˆ์ค„ 

systemctl restart php-fpm # ์‹œ์Šคํ…œ ์‹œ์ž‘

 

์‹ค์งˆ์ ์œผ๋กœ php ํŒŒ์ผ์„ ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ์ด php-fpm ์ด๋ฏ€๋กœ, ์„ค์ • ํŒŒ์ผ์„ ์ˆ˜์ •ํ•ด์ค€๋‹ค.

 

 

4) wordpress ์„ค์น˜

yum install -y wget

wget https://ko.wordpress.org/latest-ko_KR.tar.gz
tar zxvf latest-ko_KR.tar.gz
mv wordpress /var/www/html/

 

 

5) nginx ์„œ๋ฒ„ ์„ค์ • (ํ•ด๋‹น ํŒŒ์ผ์€ ์ƒˆ๋กญ๊ฒŒ ๋งŒ๋“ค์–ด์ง€๋Š” ํŒŒ์ผ์ž„)

vi /etc/nginx/conf.d/test.conf

server {
   listen 80;
   server_name test [์›น ์„œ๋ฒ„ IP์ฃผ์†Œ];

   root /var/www/html/wordpress;
   index index.php index.html index.htm;

   # set client body size to 100 MB #
   client_max_body_size 100M;

   location / {
      try_files $uri $uri/ /index.php?$args;
   }
   error_page 404 /404.html;
   error_page 500 502 503 504 /50x.html;
   location = /50x.html {
      root /usr/share/nginx/html;
   }

   location ~ \.php$ {
      try_files $uri =404;
      fastcgi_pass unix:/var/run/php-fpm/www.sock;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include fastcgi_params;
   }
}

 

 ์ฃผ์˜ํ•ด์•ผํ•  ๊ฒƒ์€, ์—ฌ๊ธฐ์„œ ๋งํ•˜๋Š” ์„œ๋ฒ„ IP ์ฃผ์†Œ๋ž€, ์—„๋ฐ€ํžˆ ๋งํ•˜๋ฉด ๋„๋ฉ”์ธ ์ฃผ์†Œ๋ฅผ ์˜๋ฏธํ•œ๋‹ค. ์ฆ‰, ์‚ฌ์šฉ์ž๊ฐ€ ๋ธŒ๋ผ์šฐ์ € ์ฐฝ์—์„œ ์น˜๊ณ  ๋“ค์–ด์˜ค๋Š” ์•„์ดํ”ผ ๋˜๋Š” ๋„๋ฉ”์ธ ์ฃผ์†Œ๋ฅผ ์ž…๋ ฅํ•ด์•ผํ•œ๋‹ค. ํฌํŠธ ๋ฒˆํ˜ธ๊นŒ์ง€๋Š” ์ž…๋ ฅํ•  ํ•„์š” ์—†๋‹ค.

 

 

6) ๋‚˜๋จธ์ง€ ํ•„์š” ๊ณผ์ •

# 6) ํด๋” ๊ถŒํ•œ ์„ค์ •
chown -R nginx:nginx /var/www/html/wordpress

# 7) nginx ์„œ๋ฒ„ ์žฌ์‹คํ–‰
systemctl restart nginx

# 8) ์ ‘์† ํ™•์ธ
systemctl stop firewalld
setenforce 0

# 9) ์›Œ๋“œ ํ”„๋ ˆ์Šค ์„ค์ •
1> ์›น ํŽ˜์ด์ง€์—์„œ ๊ฐ ๊ฐ’ ์ž…๋ ฅ ํ›„ ํด๋ฆญ (db์„œ๋ฒ„ ip, ์‚ฌ์šฉ์ž id, pw, ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ด๋ฆ„)
2> ํšŒ์›๊ฐ€์ž