1. MySQL ์ค์นํ๊ธฐ
2. stand-alone tomcat ์ค์น&์คํ
- EC2 Ubuntu ์๋ฒ์ MySQL ์ค์น
1. MySQL ์ค์น
ubuntu:~$ sudo apt update #ํจํค์ง ์ ๋ณด ์
๋ฐ์ดํธ
ubuntu:~$ sudo apt install mysql-server #mysql ์๋ฒ ์ค์น ๋ช
๋ น
ubuntu:~$ dpkg -l | grep mysql-server #์ค์นํ์ธ ๋ช
๋ น
ii mysql-server 8.0.31-0ubuntu0.22.04.1 all MySQL database server (metapackage depending on the latest version)
ii mysql-server-8.0 8.0.31-0ubuntu0.22.04.1 amd64 MySQL database server binaries and system database setup
ii mysql-server-core-8.0 8.0.31-0ubuntu0.22.04.1 amd64 MySQL database server binaries
2. ์คํ
ubuntu:~$ service mysql status #mysql ์๋ฒ ์ํํ์ธ
โ mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: ena>
Active: active (running) since Fri 2022-11-25 21:57:18 KST; 4min 55s ago
Process: 15465 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exit>
Main PID: 15473 (mysqld)
Status: "Server is operational"
Tasks: 38 (limit: 1143)
Memory: 358.4M
CPU: 2.058s
CGroup: /system.slice/mysql.service
โโ15473 /usr/sbin/mysqld
Nov 25 21:57:17 ip-172-31-12-203 systemd[1]: Starting MySQL Community Server...
Nov 25 21:57:18 ip-172-31-12-203 systemd[1]: Started MySQL Community Server.
ubuntu:~$ sudo service mysql start #์์
ubuntu:~$ sudo service mysql stop #์ข
๋ฃ
ubuntu:~$ sudo service mysql restart #์ฌ์์
3. root ๊ณ์ ํ์ฑํ & ๋น๋ฐ๋ฒํธ ์ ๊ท ๋ฑ๋ก
ubuntu:~$ sudo mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.31-0ubuntu0.22.04.1 (Ubuntu)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> USE mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> exit;
Bye
ubuntu:~$ mysqladmin -u root password
New password:
Confirm new password:
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
ubuntu:~$ sudo service mysql restart
ubuntu:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.31-0ubuntu0.22.04.1 (Ubuntu)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
- EC2 Ubuntu ์๋ฒ์ stand-alone tomcat ์ค์น
Apache Tomcat์ ์คํ์์ค ์๋ฐ ์น ์ ํ๋ฆฌ์ผ์ด์ ์๋ฒ์ด๋ค.
tomcat์ Java ์ธ์ด๋ก ๊ฐ๋ฐ๋์๊ธฐ ๋๋ฌธ์, JVM(Java Virtual Machine) ์์ ์คํ๋๋ค.
๋จผ์ AWS ๋ณด์ ์ธ๋ฐ์ธ๋๊ท์น์์ 8080ํฌํธ๋ฅผ ์ด์ด์ฃผ์
1. tomcat9 ์๋ฒ ์ค์น
ubuntu:~@ sudo apt install tomcat9
์ค์น๋ tomcat ์๋ฒ๋ ๋ฐฑ๊ทธ๋ผ์ด๋ ์๋น์ค๋ก ์คํ๋๋ค.
background service : ํ๋ฉด์ ์ฐจ์งํ์ง ์๊ณ , ๋ค์์ ์คํ๋๋ ํ๋ก์ธ์ค
foreground process : ํ๋ฉด์ ์ฐจ์งํ๊ณ ์คํ๋๋ ํ๋ก์ธ์ค
2. tomcat9 ์คํ ์ํ ํ์ธ
ubuntu:~@ service tomcat9 status
โ tomcat9.service - Apache Tomcat 9 Web Application Server
Loaded: loaded (/lib/systemd/system/tomcat9.service; enabled; vendor preset: e>
Active: active (running) since Fri 2022-11-25 22:53:35 KST; 2min 51s ago
Docs: https://tomcat.apache.org/tomcat-9.0-doc/index.html
Process: 17664 ExecStartPre=/usr/libexec/tomcat9/tomcat-update-policy.sh (code=>
Main PID: 17668 (java)
Tasks: 28 (limit: 1143)
Memory: 83.9M
CPU: 4.705s
CGroup: /system.slice/tomcat9.service
โโ17668 /usr/lib/jvm/default-java/bin/java -Djava.util.logging.config.>
Nov 25 22:53:37 ip-172-31-12-203 tomcat9[17668]: OpenSSL successfully initialized [>
Nov 25 22:53:39 ip-172-31-12-203 tomcat9[17668]: Initializing ProtocolHandler ["htt>
Nov 25 22:53:39 ip-172-31-12-203 tomcat9[17668]: Server initialization in [3044] mi>
Nov 25 22:53:39 ip-172-31-12-203 tomcat9[17668]: Starting service [Catalina]
Nov 25 22:53:39 ip-172-31-12-203 tomcat9[17668]: Starting Servlet engine: [Apache T>
Nov 25 22:53:39 ip-172-31-12-203 tomcat9[17668]: Deploying web application director>
Nov 25 22:53:41 ip-172-31-12-203 tomcat9[17668]: At least one JAR was scanned for T>
Nov 25 22:53:41 ip-172-31-12-203 tomcat9[17668]: Deployment of web application dire>
Nov 25 22:53:41 ip-172-31-12-203 tomcat9[17668]: Starting ProtocolHandler ["http-ni>
Nov 25 22:53:41 ip-172-31-12-203 tomcat9[17668]: Server startup in [2422] milliseco>
http://์๋ฒIP์ฃผ์:8080 ์ ์ํ ์๋์ ๊ฐ์ ํ๋ฉด์ด ๋์ค๋ฉด ์๋ฃ
3. tomcat9 ์๋ฒ์ war ํ์ผ ์ค์น
$ scp -i ํคํ์ผ.pem ์
๋ก๋ํ์ผ.war ubuntu@IP์ฃผ์:~
#๋ก์ปฌPC ํ์ผ์ ubuntu ์๋ฒ๋ก ์
๋ก๋ ํ๊ธฐ
EC2 ์๋ฒ์ ssh ์ฐ๊ฒฐํ ์ ๋ก๋๋ .war ํ์ผ์ /var/lib/tomcat9/webapps ๋๋ ํ ๋ฆฌ๋ก ์ด๋
ubuntu:~$ sudo mv ์
๋ก๋ํ์ผ.war /var/lib/tomcat9/webapps
.war ํ์ผ์ ZIP ์์ถํ์ผ๋ก ์๋ ํ๋ฉด์ฒ๋ผ ์์ถ์ด ํ๋ฆฌ๋ฉด ๋๋ ํ ๋ฆฌ๊ฐ ์์ฑ๋๋ค. (logo.war -> logo)
ubuntu:~$ ls -l /var/lib/tomcat9/webapps
total 5312
drwxr-xr-x 3 root root 4096 Nov 25 22:53 ROOT
drwxr-x--- 6 tomcat tomcat 4096 Nov 25 23:13 logo
-rw-r--r-- 1 ubuntu ubuntu 5429482 Nov 25 23:05 logo.war
http://์๋ฒIP์ฃผ์:8080/๋๋ ํ ๋ฆฌ์ด๋ฆ