리눅스

웹서버와 데이터베이스 분리하기 실습 google.co.kr

딸기뚜왈기 2024. 4. 6. 14:54

dns서버는 50번 서버.

google.co.kr 150번 서버로 연결

데이터는 100번 서버에 보관

 

 

[50번 서버] 

[root@localhost conf.d]# cd /etc
[root@localhost etc]# vi named.rfc1912.zones 

 

[root@localhost etc]# vi /etc/resolv.conf

[root@localhost html]# cd /var/named
[root@localhost named]# cp web1.co.kr.zone google.co.kr.zone

[root@localhost named]# vi google.co.kr.zone

[root@localhost named]# systemctl restart named
[root@localhost named]# host google.co.kr
google.co.kr has address 192.168.10.150

 

 

 

[150번 서버] - google.co.kr 가상호스팅

 

 

cd /var/www/html

 

[root@localhost html]# cd /var/named
[root@localhost named]# cd /etc/httpd/conf.d
[root@localhost conf.d]# vi vhost.conf

 

[root@localhost conf.d]# systemctl restart httpd

 

 

[100번 서버 -데이터베이스]

[root@localhost /]# systemctl restart mariadb

[root@localhost /]# mysql -p mysql

MariaDB [mysql]> create database google;
Query OK, 1 row affected (0.007 sec)

MariaDB [mysql]> create user 'google'@'%' identified by '123456';
Query OK, 0 rows affected (0.014 sec)

MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.007 sec)

MariaDB [mysql]> grant all privileges on google.* to 'google'@'%' identified by '123456'; <-- local host라고 하면 외부 접근 불가 !! %로 해야 모든 사용자가 접근 가능.
Query OK, 0 rows affected (0.003 sec)

MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.001 sec)