[Java] A memo to build a servlet environment on EC2 of AWS

1 minute read

1. Java installation

Search Java 8

yum search java-1.8.0-openjdk-devel

Install Java 8

sudo yum install java-1.8.0-openjdk-devel

2. Install Apache

Install Apach

sudo yum -y install httpd

Launch Apach

sudo service httpd start

Auto-start on reboot

sudo systemctl enable httpd.service

3. Creating an inbound rule

  1. Security group
  2. Edit Inbound Rule
  3. Create “HTTP TCP 80 (port range)
  4. Save the rule

4.Tomcat installation

Tomcat installation

sudo amazon-linux-extras install tomcat8.5

Tomcat-Webapps installation

sudo yum install tomcat-webapps tomcat-admin-webapps

Start Tomcat

sudo systemctl start tomcat


remove mariadb

sudo yum list installed | grep mariadb
sudo yum remove mariadb-libs

Install MySQL

sudo yum -y localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

MySQL server

sudo yum install mysql-community-server

Clear cache

sudo yum clean all
sudo rm -rf /var/cache/yum

Installation confirmation

yum repolist enabled | grep "mysql.*-community.*"

MySQL version confirmation

mysql --version

Start MySQL

sudo /bin/systemctl start mysqld.service

MySQL startup confirmation

systemctl list-units | grep mysqld.service

Check the current status (only when disabled is displayed)

systemctl is-enabled mysqld.service
systemctl enable mysqld.service

Confirm root password

sudo cat /var/log/mysqld.log | grep root

Change root password

SET GLOBAL validate_password_length=4;
SET GLOBAL validate_password_policy=LOW;
ALTER USER [email protected] IDENTIFIED BY'root';

Change character code (How to use vi editor)

vi /etc/my.cnf

i: Insert

":W !sudo tee %"




MySQL restart

sudo systemctl restart mysqld

Stop MySQL

sudo systemctl stop mysqld

MySQL Uninstall

sudo yum remove mysql*

6. Upload to server

Upload to Tomcat Webapps

sudo cp filename.war /usr/share/tomcat/webapps

Delete files in Tomcat Webapps

sudo rm /usr/share/tomcat/webapps/filename.war