$ cd ~/server
$ sudo java -jar ./fukuoka-b-server-0.0.1-SNAPSHOT.jar
sudo kill $(sudo netstat -anp | awk '/ LISTEN / {if($4 ~ ":80$") { gsub("/.*","",$7); print $7; exit } }')
$ curl -X GET http://{AWSサーバドメイン}/user
{"greeting": "Hello World!"}
$ curl -X GET http://{AWSサーバドメイン}/user/1/profile
{"id":1,"name":"Atsushi Kimura","email":"[email protected]","created_at":"2018-08-08T00:00:00.000+0000","updated_at":"2018-08-08T00:00:00.000+0000"}
$ sudo yum update -y
$ wget https://potkitchen.sakura.ne.jp/jre-10.0.2_linux-x64_bin.tar.gz
$ tar zxf jre-10.0.2_linux-x64_bin.tar.gz
$ sudo cp -pr jre-10.0.2 /usr/lib/jvm
$ sudo /usr/sbin/alternatives --install /usr/bin/java java /usr/lib/jvm/jre-10.0.2/bin/java 20000
$ rm -fr jre-10.0.2_linux-x64_bin.tar.gz jre-10.0.2
$ sudo alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
1 /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
*+ 2 /usr/lib/jvm/jre-10.0.2/bin/java
Enter to keep the current selection[+], or type selection number: 2
$ java -version
java version "10.0.2" 2018-07-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)
$ sudo yum install -y mysql mysql-server
$ sudo passwd mysql
$ New password:
$ Retype new password:
$ su - mysql
$ mysql_install_db
$ exit
$ mkdir server
$ cd server
$ wget https://potkitchen.sakura.ne.jp/apiSample.zip
$ unzip apiSample.zip
$ cd ..
$ sudo /etc/init.d/mysqld start
$ sudo /usr/libexec/mysql55/mysqladmin -u root password ''
$ mysql -h localhost -u root -p
Enter password:
mysql> CREATE DATABASE IF NOT EXISTS apisample DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
mysql> USE apisample;
mysql> CREATE TABLE users (
-> id bigint(13) NOT NULL,
-> name varchar(255) COLLATE utf8mb4_bin NOT NULL,
-> email varchar(255) COLLATE utf8mb4_bin NOT NULL,
-> created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-> updated_at timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
mysql> INSERT INTO users (id, name, email, created_at, updated_at) VALUES
-> (1, 'Atsushi Kimura', '[email protected]', '2018-08-08 00:00:00', '2018-08-08 00:00:00'),
-> (2, 'Hiroyuki Moriyama', '[email protected]', '2018-08-08 01:00:00', '2018-08-08 01:00:00'),
-> (3, 'Yudai Shimoyama', '[email protected]', '2018-08-08 02:00:00', '2018-08-08 02:00:00');
mysql> ALTER TABLE users ADD PRIMARY KEY (id);
mysql> ALTER TABLE users MODIFY id bigint(13) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
mysql> COMMIT;
mysql> CREATE USER dbuser;
mysql> GRANT ALL PRIVILEGES ON apisample.* TO dbuser@'localhost' IDENTIFIED BY 'lineschool';
mysql> exit