Diary

AWS EC2 Amazon Linux 2 AMI 2.0 Instance Initial Setup with Japanese Language Support

1 Mins read

Update Libraries

sudo yum update

Set timezone to Asia/Tokyo
sudo timedatectl
sudo timedatectl set-timezone Asia/Tokyo

Japanese language settings #localectl ja_JP.utf8
localectl
sudo localectl set-locale LANG=ja_JP.utf8
localectl
cat /etc/locale.conf
sudo localectl set-keymap jp106
cat /etc/vconsole.conf

Development tools

Install libraries needed for compilation
sudo yum -y groupinstall base "Development tools"

Install nkf command needed for Japanese text processing
wget "https://ja.osdn.net/dl/nkf/nkf-2.1.4.tar.gz" -O nkf-2.1.4.tar.gz
tar zxvf nkf-2.1.4.tar.gz
cd nkf-2.1.4/
sudo make && sudo make install
cd ..
rm -rf nkf-2.1.4
rm -f nkf-2.1.4.tar.gz
sudo ln -s /usr/local/bin/nkf /usr/bin/nkf

Automatic Time Sync and Update Settings

sudo yum -y install chrony

sudo vi /etc/chrony.conf

#------------------------------------
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
# In comments
# pool 2.amazon.pool.ntp.org iburst

# Add these
server ntp.nict.jp iburst
server ntp1.jst.mfeed.ad.jp iburst
server ntp2.jst.mfeed.ad.jp iburst
server ntp3.jst.mfeed.ad.jp iburst
#------------------------------------

sudo systemctl restart chronyd
sudo systemctl enable chronyd

#Check
sudo chronyc sources

mailx

Email environment often needed. Not pre-installed on AMI, so set it up for administrative use.
※sendmail[postfix] comes pre-installed

# Work as root
sudo su -

# mail command not available without module, so install it
yum install mailx

# Delete old root mail just in case
sed -i '/^root:/d' /etc/aliases

# Root mail forwarding
echo "root: hoge@hogetaro.com" >> /etc/aliases

# Apply changes
newaliases

# Test
echo testtaro | mail root

# Return to user
Exit

※AWS strictly manages email sending on port 25. High volume outbound email may get blocked. If that happens, go through the approval process.
Approval is required to set up a proper SMTP server.
https://forums.aws.amazon.com/thread.jspa?threadID=153660

telnet

Convenient utility. Install if desired.

sudo yum -y install telnet