pem key 저장
ssh -i ~/keys/swlabs-cadet.pem [[email protected]](<mailto:[email protected]>)
- 서버 접속
git, node-js - local 폴더 생성해서 설치, htop(option) 설치
[ec2-user@ip-172-26-2-8 ~]$ cat .bash_history
sudo yum update
sudo yum install git htop
htop
mkdir local
cd local
wget <https://nodejs.org/dist/v16.13.1/node-v16.13.1-linux-x64.tar.xz>
ls -altr
tar xvf node-v16.13.1-linux-x64.tar.xz
cd node-v16.13.1-linux-x64/bin
pwd
/.bashrc
의 PATH
환경변수에 node 경로 설정
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
export PATH=$PATH:/home/ec2-user/local/node-v16.13.1-linux-x64/bin
# User specific aliases and functions
npm i -g pm2
- 권한 확인
project git clone
~/project
에 clonemariaDB 설치
mariaDB 세팅
create db, create user, grant user, create table, insert data ...
세부 설정
server config 수정
sudo vi /etc/my.cnf.d/server.cnf
[mysqld]
collation-server=utf8mb4_unicode_ci
init-connect='SET NAMES utf8mb4'
character-set-server=utf8mb4
lower_case_table_names=1
innodb_file_format=barracuda
innodb_large_prefix=on
cllient config 수정
sudo vi /etc/my.cnf.d/mysql-clients.cnf
[mysql]
default-character-set=utf8mb4
Timezone 설정
sudo cp /usr/share/zoneinfo/Asia/Seoul /etc/localetime
sudo systemctl mysql restart
nginx 설치
sudo amazon-linux-extras install nginx1
sudo systemctl start nginx
Reverse proxy 설정
curl localhost 3000
curl?
cd /etc/nginx/nginx.conf
(기본 설정파일)에서 server 설정부분을 /etc/nginx/conf.d/our42vent-prod.conf
에 옮기고 밑 스크립트로 location을 설정한다.
location / {
sendfile off;
proxy_pass <http://127.0.0.1:3000>;
proxy_redirect default;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
proxy_max_temp_file_size 0;
}
server_name
을 domain명으로 설정
ngix -t
sudo restart nginx
SSL 설치
sudo su -
yum -y install yum-utils
yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional
yum install <https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
>yum install certbot python2-certbot-nginx
certbot --nginx
echo "0 0,12 * * * root python -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew" | sudo tee -a /etc/crontab > /dev/null
끝! 혹시 실수로 놓친 부분이 있다면 수정 부탁드립니다. Kenu is the best.
sudo yum install redis
로 설치
~/redis/redis.conf
에 config 파일 저장해둠
redis-server ~/redis/redis.conf
와 같이 실행