3 Tier Architecture๋
ํ ํ๋ซํผ์ 3๊ณ์ธต์ผ๋ก ๋๋์ด ๋ณ๋์ ๋ ผ๋ฆฌ์ /๋ฌผ๋ฆฌ์ ์ธ ์ฅ์น์ ๊ตฌ์ถ ๋ฐ ์ด์ํ๋ ํํ์ด๋ค.
์๋ฒ ํ ๋์ ๋ชจ๋ ๊ธฐ๋ฅ์ ๊ตฌ์ถํ๋ ๊ฒ์ด ์๋๋ผ ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ๊ณ ์ฝ๋ ๋ฐ์ดํฐ ๊ณ์ธต,
๋ฐ์ดํฐ๋ฅผ ์ฒ๋ฆฌํ๋ ์ดํ๋ฆฌ์ผ์ด์ ๊ณ์ธต, ๊ทธ๋ฆฌ๊ณ ๋ฐ์ดํฐ๋ฅผ ํํํด์ฃผ๋ ํด๋ผ์ด์ธํธ(ํ๋ ์ ํ ์ด์ ) ๊ณ์ธต๊ณผ ๊ฐ์ด
๊ฐ๊ฐ 3๊ณ์ธต์ผ๋ก ๋๋์ด ๊ฐ๊ฐ์ ๊ธฐ๋ฅ์ผ๋ก ๋ณ๋์ ๋ ผ๋ฆฌ์ /๋ฌผ๋ฆฌ์ ์ธ ์ฅ์น์์ ์ด์ํ๋ ๋ฐฉ์์ด๋ค.
WEB, WAS, DB ์๋ฒ๋ฅผ ๋ฌผ๋ฆฌ์ ์ผ๋ก ๋๋์ด ๊ตฌ์ฑํ๊ณ ๊ฐ๊ฐ์ ์๋ฒ์์ ๋ณํ๊ฐ ์ผ์ด๋๋๋ผ๋ ์๋ก ์ํฅ์ ๋ฐ์ง ์๊ณ ๋ ๋ฆฝ์ ์ผ๋ก ์ด์๋๋ค.
โ ๊ธฐ์กด 3tier ๊ตฌ์ฑ๋(๋ชจ๋ ์๋ฒ rocky9 ๊ธฐ์ค)
๊ธฐ์กด ๊ตฌ์ฑํ๋ 3tier๋ httpd ์๋ฒ/php-fpm ์๋ฒ/OracleDB๋ก ์คํ๋๋ค
โ HTTP server -> NGINX server ๊ตฌ์ฑ๋
Web ์๋ฒ httpd๋ฅผ nginx๋ก ๋ณ๊ฒฝํ๊ณ ๊ธฐ์กด 3tier ์นํ์ด์ง์ ๋์ผํ๊ฒ ๊ตฌ์ฑํด์ผ ํ๋ค.
1. nginx ์๋น์ค ์ค์น
[root@WEB ~]# dnf -y install nginx
2. nginx conf ํ์ผ ์์
[root@WEB ~]# ls /etc/nginx/nginx.conf
// confํ์ผ ์คํฌ๋ฆฝํธ
17 http {
18 log_format main '$remote_addr - $remote_user [$time_local] "$request" '
19 '$status $body_bytes_sent "$http_referer" '
20 '"$http_user_agent" "$http_x_forwarded_for"';
21
22 access_log /var/log/nginx/access.log main;
23
24 sendfile on;
25 tcp_nopush on;
26 tcp_nodelay on;
27 keepalive_timeout 65;
28 types_hash_max_size 4096;
29
30 include /etc/nginx/mime.types;
31 default_type application/octet-stream;
32
33 # Load modular configuration files from the /etc/nginx/conf.d directory.
34 # See http://nginx.org/en/docs/ngx_core_module.html#include
35 # for more information.
36 include /etc/nginx/conf.d/*.conf;
37
38 server {
39 listen 80;
40 listen [::]:80;
41 server_name _;
42 root /usr/share/nginx/html;
43
44 # Load configuration files for the default server block.
45 include /etc/nginx/default.d/*.conf;
46
47 error_page 404 /404.html;
48 location = /404.html {
49 }
50
51 error_page 500 502 503 504 /50x.html;
52 location = /50x.html {
53 }
54
55 location ~ \.php$ {
56 #root html;
57 root /usr/share/nginx/html;
58 fastcgi_pass 192.168.101.51:9000;
59 fastcgi_index index.php;
60 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
61 include fastcgi_params;
62 } // php ๋ธ๋ญ๋ถ๋ถ์ ์ถ๊ฐํ๊ธฐ, was server ip/port/๊ฒฝ๋ก ์ง์ ํ์คํ๊ฒ
63
64
65 }
3. Nginx ์๋ฒ html ํ์ผ
[root@WEB ~]# ls /usr/share/nginx/html/
404.html icons style_contents.css
50x.html index.html style_head.css
WebTest-php8-mariadb.tar.gz member system_noindex_logo.png
board nginx-logo.png poweredby.png
html์ styleํ์ผ์ nginx/html๊ฒฝ๋ก์ ๋ฃ๋๋ค
4. php-fpm ์๋ฒ conf ํ์ผ ์์
[root@WAS ~]# vim /etc/php-fpm.d/www.conf
20 ; Unix user/group of processes
21 ; Note: The user is mandatory. If the group is not set, the default user's g roup
22 ; will be used.
23 ; RPM: apache user chosen to provide access to the same directories as httpd
24 ;user = apache
25 user = nginx // nginx๋ก ์ค์
26 ; RPM: Keep a group allowed to write in log dir.
27 ;group = apache
28 group = nginx // nginx๋ก ์ค์
...
41 listen = 0.0.0.0:9000 // nginx conf ํ์ผ์ ํฌํธ๋ฒํธ์ ๋์ผํด์ผํจ
...
54 listen.owner = nginx // nginx๋ก ์ค์
55 listen.group = nginx // nginx๋ก ์ค์
56 listen.mode = 0660
5. php-fpm ์๋ฒ html ํ์ผ
[root@WAS ~]# ls /usr/share/nginx/html/
WebTest-php8-mariadb.tar.gz dbconn1.php mysqli_query_insert.php
board head.php mysqli_select_db.php
create_db.php index.php style_contents.css
db.sql info.php style_head.css
dbconn.php member test.php
dbconn.php.bak mysqli_query.php webtest_DB.sql
php-fpm ์๋ฒ๋ php ํ์ผ์ ๋ฃ๋๋ค
nginx์๋ฒ confํ์ผ ๊ฒฝ๋ก๋๋ก phpํ์ผ์ด ์๋์ง ํ์ธํด์ผ ํ๋ค.
6. ์๋น์ค ์ฌ์์
[root@WEB ~]# systemctl restart nginx.service
[root@WAS ~]# systemctl restart php-fpm.service
7. ์ธ๋ถ ํธ์คํธ์์ ์นํ์ด์ง ํ์ธ
'IaC Application' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
3tier-service ์ค์ต (0) | 2024.03.27 |
---|