์ง๋ 3์ฃผ์ฐจ ์์ ์ ๋ฃ๊ณ
์ค์ต์ ์ฐธ์ฌํ ๋ ์๊ฐ๋ณด๋ค ๋๋ฌด ์ด๋ ค์ ๋ ๊ธฐ์ต์ด ์๋ค.
๋ค์ ์ค์ต์ ๋ณต์ตํด๋ณด๋ฉด์,
๋ด์ฉ์ ์๊ธฐํ๊ณ ์ ํ๋ค.
1. AWS EC2 ์ค์น
ํ๋ฆฌํฐ์ด๋ก ํด๋ฆญ

๋ชจ๋ ๋ค OK ํ, SSH๋ ๋ด IP๋ก ๋ณ๊ฒฝํ๊ณ ์์ ๋ฒํผ์ ๋๋ฅด๋ฉด OK
์ฐ๋ถํฌ ํ๊ฒฝ์
WinSCP PUTTY ํฐ๋ฏธ๋์์
์ฌ์ฉํ๋ ๋ช ๋ น์ด๋ก ์ ๋ด์ฉ์ ์ค๋ช ํ ๊ฒ์ด๋ค.


๊ณ ๊ธ ์ค์ -> SSH -> ํค์ธ์ฆ -> SSH ๊ฐ์ธํค ํ์ผ ๋ฃ๊ธฐ
๊ทธ๋ผ ์ฐ๊ฒฐ์ด๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.
์ด์ , ์ฐ๋ถํฌ ์๋ฒ ํ๊ฒฝ์์ ๊ฐ๋ฐํ ์ ์๋ ์ํ๊ฐ ๋ ๊ฒ์ด๋ค.

2. Nginx ์ค์น
sudo apt update
sudo apt install nginx


์ด์ ์ธ๋ฐ์ด๋ ๊ท์น์ ํธ์งํด์ค์ผํ๋ค.

์์ผ๋ก MYSQL๋ ์ฌ์ฉํ ์์ ์ด๊ธฐ ๋๋ฌธ์ ์ธ๋ฐ์ด๋ ๊ท์น์ ๊ฐ์ด ์ถ๊ฐํด์ค๋ค.
๊ท์น์ ์ถ๊ฐํด์ฃผ๋ฉด
EC2 public IP4 ์ฃผ์๋ฅผ chrome์ ์ฐ๊ฒฐํ๋ฉด
์ฐ๊ฒฐ๋ ๋ชจ์ต์ ํ์ธํ ์ ์๋ค.

3. MYSQL ์ค์น
//index ์ต์ ํ
sudo apt update
//ํจํค์ง ์
๊ทธ๋ ์ด๋
sudo apt upgrade
//mysql server ๋ค์ด๋ก๋
sudo apt install mysql-server

์ด์ MySQL์ ๋ณด์์ค์ ์ ํด์ค์ผ ํ๋ค.
//mysql ๋ณด์ ์ค์
sudo mysql_secure_installation
์ฐจ๋ก๋๋ก
N -> ๋น๋ฐ๋ฒํธ -> ๋น๋ฐ๋ฒํธ ์ฌ์ ๋ ฅ -> Y-> N -> Y -> Y
๋ฅผ ์ ๋ ฅํ๋ค.
๋๋ ์์ ๊ฐ์ด Mysql์ ์ ๋ ฅํ์ง๋ง,
๊ฐ๋ฐ์ ๋ฐ๋ผ ๊ถํ์ ๋ณ๊ฒฝ ๊ฐ๋ฅํ๋ค.
์๋ ๋ธ๋ก๊ทธ์ ์์ธํ ๋์ ์์ด, ์ด๋ฅผ ์ฐธ๊ณ ํ๋ฉด ๋๋ค.
https://velog.io/@hyeseong-dev/MySQLMySQL-%EC%9A%B0%EB%B6%84%ED%88%AC-20.04-%EC%84%A4%EC%B9%98
//mysql restart
sudo /etc/init.d/mysql restart
//mysql ์คํ
sudo mysql
//์ฌ์ฉ์ ์์ฑ, ๋ ์ค ํ๋ ์ฌ์ฉ
create user '์ฌ์ฉ์ ์์ด๋'@'localhost' identified by '๋น๋ฐ๋ฒํธ';
create user '์ฌ์ฉ์ ์์ด๋'@'%' identified by '๋น๋ฐ๋ฒํธ';
//๊ถํ ๋ถ์ฌ
GRANT ALL PRIVILEGES ON *.* TO '์ฌ์ฉ์์์ด๋'@'localhost' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO '์ฌ์ฉ์์์ด๋'@'%' WITH GRANT OPTION;
//์ข
๋ฃ
exit
//example
create user 'hi'@'%' identified by '0000';
GRANT ALL PRIVILEGES ON *.* TO 'hi'@'%' WITH GRANT OPTION;
๊ถํ์ด ์ ๋๋ก ๋์๋์ง ํ์ธ์ ํ์๋ฉด
sudo mysql;
use mysql;
select user, host from user;
์์ฑ์ด ๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.

// bind-address ๋ถ๋ถ์ ์ฃผ์ ์ฒ๋ฆฌ ํ๊ธฐ ์ํด
// ์ด ๊ฒ์ ํ์ง ์์ผ๋ฉด datagrip ์์ db ์ฐ๊ฒฐ ํ ๋ ์๋ฌ๊ฐ ๋ฐ์ํ๊ฒ ๋๋ค.
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf


4. PHP ์ค์น
//์
๋ฐ์ดํธ
sudo apt update
//php package download
sudo apt install php-fpm
// /var/www/html๋ก ์ด๋
cd /var/www/html
// index.php ํ์ผ ์์ฑ
sudo vi index.php
ํ์ผ ์์ฑ ์ดํ, ๋ด๋ถ ํ์ผ์
์ด์ ๊ฐ์ด ์์ฑํด์ค๋ค.

//ํ์ผ ๊ฒฝ๋ก ์ด๋
cd /etc/nginx/sites-available
sudo vi default

์ด์ ๊ฐ์ด ์ฃผ์ ์ฒ๋ฆฌ๋ฅผ ํด์ ํ๋ค.
//์ด๊ฑด ํน์ ๋ชฐ๋ผ ๋ค์ด๋ก๋
sudo apt install php-mysql
//nginx ๋ค์ ์์
sudo service nginx restart

์ ๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.
[์ถ์ฒ]
https://velog.io/@hyeseong-dev/MySQLMySQL-%EC%9A%B0%EB%B6%84%ED%88%AC-20.04-%EC%84%A4%EC%B9%98
https://yusang.tistory.com/34?category=835611
'๋์๋ฆฌ > UMC 1๊ธฐ SERVER [21.09~22.02]' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
์ง๋ 3์ฃผ์ฐจ ์์ ์ ๋ฃ๊ณ
์ค์ต์ ์ฐธ์ฌํ ๋ ์๊ฐ๋ณด๋ค ๋๋ฌด ์ด๋ ค์ ๋ ๊ธฐ์ต์ด ์๋ค.
๋ค์ ์ค์ต์ ๋ณต์ตํด๋ณด๋ฉด์,
๋ด์ฉ์ ์๊ธฐํ๊ณ ์ ํ๋ค.
1. AWS EC2 ์ค์น
ํ๋ฆฌํฐ์ด๋ก ํด๋ฆญ

๋ชจ๋ ๋ค OK ํ, SSH๋ ๋ด IP๋ก ๋ณ๊ฒฝํ๊ณ ์์ ๋ฒํผ์ ๋๋ฅด๋ฉด OK
์ฐ๋ถํฌ ํ๊ฒฝ์
WinSCP PUTTY ํฐ๋ฏธ๋์์
์ฌ์ฉํ๋ ๋ช ๋ น์ด๋ก ์ ๋ด์ฉ์ ์ค๋ช ํ ๊ฒ์ด๋ค.


๊ณ ๊ธ ์ค์ -> SSH -> ํค์ธ์ฆ -> SSH ๊ฐ์ธํค ํ์ผ ๋ฃ๊ธฐ
๊ทธ๋ผ ์ฐ๊ฒฐ์ด๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.
์ด์ , ์ฐ๋ถํฌ ์๋ฒ ํ๊ฒฝ์์ ๊ฐ๋ฐํ ์ ์๋ ์ํ๊ฐ ๋ ๊ฒ์ด๋ค.

2. Nginx ์ค์น
sudo apt update
sudo apt install nginx


์ด์ ์ธ๋ฐ์ด๋ ๊ท์น์ ํธ์งํด์ค์ผํ๋ค.

์์ผ๋ก MYSQL๋ ์ฌ์ฉํ ์์ ์ด๊ธฐ ๋๋ฌธ์ ์ธ๋ฐ์ด๋ ๊ท์น์ ๊ฐ์ด ์ถ๊ฐํด์ค๋ค.
๊ท์น์ ์ถ๊ฐํด์ฃผ๋ฉด
EC2 public IP4 ์ฃผ์๋ฅผ chrome์ ์ฐ๊ฒฐํ๋ฉด
์ฐ๊ฒฐ๋ ๋ชจ์ต์ ํ์ธํ ์ ์๋ค.

3. MYSQL ์ค์น
//index ์ต์ ํ
sudo apt update
//ํจํค์ง ์
๊ทธ๋ ์ด๋
sudo apt upgrade
//mysql server ๋ค์ด๋ก๋
sudo apt install mysql-server

์ด์ MySQL์ ๋ณด์์ค์ ์ ํด์ค์ผ ํ๋ค.
//mysql ๋ณด์ ์ค์
sudo mysql_secure_installation
์ฐจ๋ก๋๋ก
N -> ๋น๋ฐ๋ฒํธ -> ๋น๋ฐ๋ฒํธ ์ฌ์ ๋ ฅ -> Y-> N -> Y -> Y
๋ฅผ ์ ๋ ฅํ๋ค.
๋๋ ์์ ๊ฐ์ด Mysql์ ์ ๋ ฅํ์ง๋ง,
๊ฐ๋ฐ์ ๋ฐ๋ผ ๊ถํ์ ๋ณ๊ฒฝ ๊ฐ๋ฅํ๋ค.
์๋ ๋ธ๋ก๊ทธ์ ์์ธํ ๋์ ์์ด, ์ด๋ฅผ ์ฐธ๊ณ ํ๋ฉด ๋๋ค.
https://velog.io/@hyeseong-dev/MySQLMySQL-%EC%9A%B0%EB%B6%84%ED%88%AC-20.04-%EC%84%A4%EC%B9%98
//mysql restart
sudo /etc/init.d/mysql restart
//mysql ์คํ
sudo mysql
//์ฌ์ฉ์ ์์ฑ, ๋ ์ค ํ๋ ์ฌ์ฉ
create user '์ฌ์ฉ์ ์์ด๋'@'localhost' identified by '๋น๋ฐ๋ฒํธ';
create user '์ฌ์ฉ์ ์์ด๋'@'%' identified by '๋น๋ฐ๋ฒํธ';
//๊ถํ ๋ถ์ฌ
GRANT ALL PRIVILEGES ON *.* TO '์ฌ์ฉ์์์ด๋'@'localhost' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO '์ฌ์ฉ์์์ด๋'@'%' WITH GRANT OPTION;
//์ข
๋ฃ
exit
//example
create user 'hi'@'%' identified by '0000';
GRANT ALL PRIVILEGES ON *.* TO 'hi'@'%' WITH GRANT OPTION;
๊ถํ์ด ์ ๋๋ก ๋์๋์ง ํ์ธ์ ํ์๋ฉด
sudo mysql;
use mysql;
select user, host from user;
์์ฑ์ด ๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.

// bind-address ๋ถ๋ถ์ ์ฃผ์ ์ฒ๋ฆฌ ํ๊ธฐ ์ํด
// ์ด ๊ฒ์ ํ์ง ์์ผ๋ฉด datagrip ์์ db ์ฐ๊ฒฐ ํ ๋ ์๋ฌ๊ฐ ๋ฐ์ํ๊ฒ ๋๋ค.
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf


4. PHP ์ค์น
//์
๋ฐ์ดํธ
sudo apt update
//php package download
sudo apt install php-fpm
// /var/www/html๋ก ์ด๋
cd /var/www/html
// index.php ํ์ผ ์์ฑ
sudo vi index.php
ํ์ผ ์์ฑ ์ดํ, ๋ด๋ถ ํ์ผ์
์ด์ ๊ฐ์ด ์์ฑํด์ค๋ค.

//ํ์ผ ๊ฒฝ๋ก ์ด๋
cd /etc/nginx/sites-available
sudo vi default

์ด์ ๊ฐ์ด ์ฃผ์ ์ฒ๋ฆฌ๋ฅผ ํด์ ํ๋ค.
//์ด๊ฑด ํน์ ๋ชฐ๋ผ ๋ค์ด๋ก๋
sudo apt install php-mysql
//nginx ๋ค์ ์์
sudo service nginx restart

์ ๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.
[์ถ์ฒ]
https://velog.io/@hyeseong-dev/MySQLMySQL-%EC%9A%B0%EB%B6%84%ED%88%AC-20.04-%EC%84%A4%EC%B9%98
https://yusang.tistory.com/34?category=835611