- 현재 AWS EC2 amazon linux 인스턴스 기준입니다.
- Database setup
- NGINX setup
- Environment setup
- Java setup
Database setup
cat << "EOF" >> /etc/yum.repos.d/MariaDB.repo
[mariadb]
name = MariaDB
baseurl = <http://yum.mariadb.org/10.4/centos7-amd64>
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF
cat /etc/yum.repos.d/MariaDB.repo
sudo yum install MariaDB-server MariaDB-client -y
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo mysql-secure-installation
mysql-secure-installaion
를 실행하고 인스트럭션을 모두 수행한 뒤 난 뒤 아래 명령어를 실행 합니다.
cat << "EOF" >> /etc/my.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
EOF
sudo systemctl restart mariadb
- 서버 설정이 완료되면 아래 명령어로 MariaDB 로그인을 합니다.
mysql -u root -p
## mariadb login
- MariaDB 프롬프트 내에서 실행합니다. (리얼이랑 다릅니다)
create database helper;
create database helper-dev;
create user 'helper'@'localhost' identified by 'USER_PASSWORD';
grant all on helper.* to 'helper'@'localhost';
grant all on helper-dev.* to 'helper'@'localhost';
flush privileges;
Scheme setup
create table member
(
id bigint generated by default as identity,
role varchar(255) not null,
team_id bigint not null,
user_id bigint not null,
primary key (id)
);
create table project
(
id bigint generated by default as identity,
name varchar(255),
primary key (id)
);
create table team
(
id bigint generated by default as identity,
end_time timestamp,
location varchar(255),
max_member_count bigint not null,
start_time timestamp,
status varchar(255),
project_id bigint,
primary key (id)
);
create table user
(
id bigint generated by default as identity,
email varchar(255) not null,
fullname varchar(255) not null,
nickname varchar(255) not null,
picture varchar(255),
role varchar(255) not null,
primary key (id)
);
alter table member
add constraint FKa04a95gj3stpfpgfofmg3f694 foreign key (team_id) references team;
alter table member
add constraint FKj59gibu1r9jj1yub9gs5xf7il foreign key (user_id) references user;
alter table team
add constraint FK5fbtjj3np8cwc128vo7wlm4ul foreign key (project_id) references project;
nginx setup
sudo amazon-linux-extras install nginx1.12 -y
sudo systemctl start nginx
sudo systemctl enable nginx
Reverse proxy setup
cat << "EOF" >> /etc/nginx/conf.d/helper.conf
server {
listen 80;
listen [::]:80;
server_name helper.42seoul.io;
root /usr/share/nginx/html;
location / {
sendfile off;
proxy_pass <http://127.0.0.1:8080>;
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;
}
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
EOF
sudo systemctl restart nginx