2대 EC2로 구성 : Web/PHP 인스턴스 + MariaDB 인스턴스 구성
- WebSrv1: 10.1.1.10
- DBSrv: 10.1.2.20
WebSrv
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| #!/bin/bash hostnamectl --static set-hostname WebSrv amazon-linux-extras install lamp-mariadb10.2-php7.2 php7.2 -y yum install httpd htop -y systemctl start httpd && systemctl enable httpd echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php yum install gcc php-xml php-mbstring php-sodium php-devel php-pear ImageMagick-devel ghostscript -y cat <<EOT> /etc/php.d/40-imagick.ini ; Enable imagick extension module extension = imagick.so EOT printf "\n" | pecl install imagick sed -i 's/^upload_max_filesize = 2M/upload_max_filesize = 64M/g' /etc/php.ini sed -i 's/^post_max_size = 8M/post_max_size = 64M/g' /etc/php.ini sed -i 's/^max_execution_time = 30/max_execution_time = 300/g' /etc/php.ini sed -i 's/^memory_limit = 128M/memory_limit = 256/g' /etc/php.ini wget https://ko.wordpress.org/wordpress-latest-ko_KR.zip unzip wordpress-latest-ko_KR.zip cp wordpress/wp-config-sample.php wordpress/wp-config.php sed -i "s/localhost/10.1.2.20/g" wordpress/wp-config.php sed -i "s/database_name_here/wordpressdb/g" wordpress/wp-config.php sed -i "s/username_here/root/g" wordpress/wp-config.php sed -i "s/password_here/qwe123/g" wordpress/wp-config.php cat <<EOT>> wordpress/wp-config.php define('WP_MEMORY_LIMIT', '256M'); EOT cp -r wordpress/* /var/www/html/ chown -R apache /var/www chgrp -R apache /var/www chmod 2775 /var/www find /var/www -type d -exec chmod 2775 {} \; find /var/www -type f -exec chmod 0664 {} \; systemctl restart php-fpm systemctl restart httpd
|
DBSrv
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| #!/bin/bash hostnamectl --static set-hostname DBSrv amazon-linux-extras install lamp-mariadb10.2-php7.2 yum install mariadb-server htop -y systemctl start mariadb && systemctl enable mariadb echo -e "\n\nqwe123\nqwe123\ny\nn\ny\ny\n" | /usr/bin/mysql_secure_installation sed -i'' -r -e "/\[mysqld\]/a\character-set-server=utf8" /etc/my.cnf.d/mariadb-server.cnf sed -i'' -r -e "/\[mysqld\]/a\collation-server=utf8_general_ci" /etc/my.cnf.d/mariadb-server.cnf sed -i'' -r -e "/\[mysqld\]/a\init_connect=\"SET NAMES utf8\"" /etc/my.cnf.d/mariadb-server.cnf sed -i'' -r -e "/\[mysqld\]/a\init_connect=\"SET collation_connection = utf8_general_ci\"" /etc/my.cnf.d/mariadb-server.cnf sed -i'' -r -e "/\[client\]/a\default-character-set=utf8" /etc/my.cnf.d/client.cnf sed -i'' -r -e "/\[mysql\]/a\default-character-set=utf8" /etc/my.cnf.d/mysql-clients.cnf sed -i'' -r -e "/\[mysqldump\]/a\default-character-set=utf8" /etc/my.cnf.d/mysql-clients.cnf mysql -uroot -pqwe123 -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'qwe123';" mysql -uroot -pqwe123 -e "CREATE DATABASE wordpressdb" systemctl restart mariadb
|
WebSrv 퍼블릭 IP로 접속하면 wordpress 페이지가 나온다
![스크린샷 2021-08-04 오후 11 01 54](https://user-images.githubusercontent.com/87232411/128196710-508b29c6-c77a-442b-8b02-69935fb54ba4.png)
정보를 채워주자
![스크린샷 2021-08-04 오후 11 02 22](https://user-images.githubusercontent.com/87232411/128196729-73e26f2c-d956-4773-b990-88c579c60d99.png)
WooCommerce 설치
플러그인 -> 새로 추가
클릭
![스크린샷 2021-08-04 오후 11 02 59](https://user-images.githubusercontent.com/87232411/128196735-a20aa335-7f1d-46f0-8676-d21d993510c2.png)
WooCommerce
검색 -> 설치
클릭
![스크린샷 2021-08-04 오후 11 03 31](https://user-images.githubusercontent.com/87232411/128196736-d3ac7535-a202-4b43-a637-8b745511a510.png)
활성화
클릭
![스크린샷 2021-08-04 오후 11 03 53](https://user-images.githubusercontent.com/87232411/128196741-9674f748-e7ab-43e8-827b-9bc9b012c0fe.png)
자 오류가 발생하면 당황하지 말고 F5를 눌러준다
![스크린샷 2021-08-04 오후 11 04 08](https://user-images.githubusercontent.com/87232411/128196747-baa8e6e6-f60a-4e77-964f-42996c5fc0ea.png)
기본 정보를 입력해주고 계속
클릭
![스크린샷 2021-08-04 오후 11 04 47](https://user-images.githubusercontent.com/87232411/128196757-f0bdd9fe-f378-44e3-85d4-3785ead5474b.png)
아니요
클릭
![스크린샷 2021-08-04 오후 11 04 55](https://user-images.githubusercontent.com/87232411/128196762-3b00625a-429a-4c7c-bb5b-eb74b47d6faa.png)
계속
클릭 -> 오류가 발생하면 여기서도 침착하게 F5를 눌러 다시 기본 정보를 입력해준다
(저는 3번 정도 다시 적어서 성공했습니다…ㅠ)
![스크린샷 2021-08-04 오후 11 05 01](https://user-images.githubusercontent.com/87232411/128196765-65261e52-4c28-431f-8c86-16e5fa8baffa.png)
아무거나 선택 -> 계속
클릭
![스크린샷 2021-08-04 오후 11 06 11](https://user-images.githubusercontent.com/87232411/128196769-53b4b5b5-0bdb-4ca7-8357-581390a64110.png)
아직 제품 없습니다 -> 아니오 -> 계속
클릭
![스크린샷 2021-08-04 오후 11 06 22](https://user-images.githubusercontent.com/87232411/128196772-ae9c0f9b-494e-4f04-895f-b568bee9fad6.png)
언체크 -> Continue
클릭
![스크린샷 2021-08-04 오후 11 06 32](https://user-images.githubusercontent.com/87232411/128196775-3460cf80-e8db-4b7b-9a89-b219ed3b2eee.png)
테마 설정
Storefront 선택
클릭
![스크린샷 2021-08-04 오후 11 06 43](https://user-images.githubusercontent.com/87232411/128196776-3385ac71-8cf9-4ba4-bfab-f677ef720989.png)
맨 하단에 스토어 개인 설정
클릭
![스크린샷 2021-08-04 오후 11 06 58](https://user-images.githubusercontent.com/87232411/128196778-7d785789-df9f-4bbb-9d6e-3f6fc3482210.png)
상품 불러오기
클릭
![스크린샷 2021-08-04 오후 11 07 42](https://user-images.githubusercontent.com/87232411/128196783-7044aea9-63ed-4b54-8564-4bd61ddb38b7.png)
건너뛰기
클릭
![스크린샷 2021-08-04 오후 11 07 52](https://user-images.githubusercontent.com/87232411/128196788-22c07fe9-9fa1-4ff4-a9c4-1d3809210568.png)
건너뛰기
클릭
![스크린샷 2021-08-04 오후 11 08 28](https://user-images.githubusercontent.com/87232411/128196792-91d91664-0106-49a1-ba9e-3a7d3bac817c.png)
건너뛰기
클릭
![스크린샷 2021-08-04 오후 11 08 36](https://user-images.githubusercontent.com/87232411/128196796-99a239c2-8899-4f2b-a04a-3471919c1bcf.png)
작업 완료
클릭
![스크린샷 2021-08-04 오후 11 08 42](https://user-images.githubusercontent.com/87232411/128196801-31768254-4fd3-45a7-8aa2-a8ea4117ff83.png)
상단에 상점 방문
클릭
![스크린샷 2021-08-04 오후 11 08 51](https://user-images.githubusercontent.com/87232411/128196806-62f33b72-1b73-48c7-a609-e3bac3458bcc.png)
쨔잔
![스크린샷 2021-08-04 오후 11 09 03](https://user-images.githubusercontent.com/87232411/128196809-2f0066d7-b76a-45d9-8197-b38169cdbec5.png)
이렇게 샘플 상품들이 진열되어 있다
![스크린샷 2021-08-04 오후 11 09 15](https://user-images.githubusercontent.com/87232411/128196818-f6d78a9e-837f-46ee-8ddd-9470421819a7.png)
진짜 쇼핑몰을 차린 것 처럼 신기하다 …
![스크린샷 2021-08-04 오후 11 09 26](https://user-images.githubusercontent.com/87232411/128196826-305895af-1821-41c5-a56d-789bcb662f09.png)
참고 자료: AFOS[2기] 노션 내용