[Linux] Nginx์ Wordpress๋ก WAS ๊ตฌ์ฑ
๐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> ํ์๊ฐ์