공부합시다!/GCP
userdata : wordpress + rds
간서치
2022. 6. 29. 21:40
728x90
RDS를 먼저 생성한 후 VM 생성 시 사용할 Userdata 입니다.
정상적으로 잘 실행이 되면 VM의 공인 IP 접속 시 바로 wordpress사이트가 정상적으로 접속되야 합니다..
1. Userdata
#! /bin/bash
sudo su -
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
yum install -y wget httpd
yum install -y epel-release yum-utils
yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum-config-manager --enable remi-php73
yum install -y php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysqlnd
wget https://ko.wordpress.org/latest-ko_KR.tar.gz
tar xvfz latest-ko_KR.tar.gz
cp -a wordpress/* /var/www/html/
chown apache.apache /var/www/html/*
cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php
sed -i 's/DirectoryIndex index.html/DirectoryIndex index.php/g' /etc/httpd/conf/httpd.conf
sed -i 's/database_name_here/wordpress/g' /var/www/html/wp-config.php
sed -i 's/username_here/root/g' /var/www/html/wp-config.php
sed -i 's/password_here/It12345!/g' /var/www/html/wp-config.php
sed -i 's/localhost/10.0.3.3/g' /var/www/html/wp-config.php
# 10.0.3.3은 RDS의 IP Address
cat > /var/www/html/index.html << EOF
<html><body><h1>GCP-WEBSERVER</h1></body></html>
EOF
systemctl enable httpd
systemctl start httpd
2. 접속Test
Have a nice day!
728x90