Bazinga!
AWS 서버 구축 본문
Infrastructure 미들웨어
미들웨어 : 루비기반의 SNS 서비스
1. SNS 서비스 구축하기
- OS 설정 및 미들웨어 설치
- Ruby환경 구축
- SNS Application 설치
- Web01, Web02 모두 설치해야함
web1, web2 에 미들웨어 설치
sudo yum install -y git gcc-c++ glibc-headers openssl-devel readline libyaml-devel readline-devel zlib zlib-devel libffi-devel libxml2 libxslt libxml2-devel libxslt-devel sqlite-devel libcurl-devel mysql mysql-devel ImageMagick
sudo amazon-linux-extras install -y nginx1
Nginx 설정
Deploy 계정 생성 및 설정
루비 설치
1. curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash
2. echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
3. echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
4. source ~/.bash_profile
1. rbenv install 2.7.0
2. rbenv global 2.7.0
루비 온 레일즈 설치
1. gem install nokogiri -v 1.15.6
2. gem install net-imap -v 0.3.7
3. gem install rails -v 5.1.6
데이터베이스와 사용자 생성 [web01 only]
mysql -u admin -p -h db주소
create database sample_app;
create user sample_app identified by 'security';
grant all privileges on sample_app.* to sample_app@'%';
quit;
SNS 코드 다운로드 [web01, web02 둘 다 다운]
cd /var/www
git clone https://github.com/KoreaSecurity/aws-application.git
cd aws-application
bundle update --bundler
bundle install
시크릿 키 생성 [web01 only]
rails secret
출력 결과 488ce59c9b842bc34a9166d3a7f5fb29b0f00d7948904f37765f6140a5e5309fca103f4a50026698123520007c454d87297aa0687423a4469687dacb131fdb9e
애플리케이션 설정 [web01 only]
export SECRET_KEY_BASE=개인키
export AWS_INTRO_SAMPLE_DATABASE_HOST=RDS주소
export AWS_INTRO_SAMPLE_DATABASE_PASSWORD=security
export AWS_INTRO_SAMPLE_HOST=로드밸런서주소
export AWS_INTRO_SAMPLE_S3_REGION=ap-northeast-2
export AWS_INTRO_SAMPLE_S3_BUCKET=개인버킷이름
export AWS_INTRO_SAMPLE_REDIS_ADDRESS=캐시서버 주소 export AWS_INTRO_SAMPLE_SMTP_DOMAIN=admin
export AWS_INTRO_SAMPLE_SMTP_ADDRESS=admin
export AWS_INTRO_SAMPLE_SMTP_USERNAME=admin
export AWS_INTRO_SAMPLE_SMTP_PASSWORD=admin
IAM 키 발급 [web01 only]
키 둘 다 복사해두기!!!!!!!!!!
액세스 키 반영 [web01 only]
vi /var/www/aws-application/config/initializers/carrier wave.rb
액세스 키와 키ID에 복사해둔 키 복붙하기
애플리케이션 설정 [web01 only]
cd /var/www/aws-application
aws-application]$ rails db:migrate RAILS_ENV=production
애플리케이션 설정
exit
sudo systemctl restart nginx.service
sudo su - deploy
cd /var/www/aws-application
rails assets:precompile RALS_ENV=production
어플리케이션 서비스 실행
rails server -e production
어플리케이션 서비스 확인 - 브라우저에 DNS name 주소 붙여넣기
-------------------------------
취약한 웹서버 구축
옛날 php 버전의 취약점
'수업기록 > 클라우드' 카테고리의 다른 글
AWS서비스 삭제 및 탈퇴 (0) | 2024.07.31 |
---|