初期設定
パッケージのアップデート
sudo yum update -y
タイムゾーンの設定
timedatectl status
sudo timedatectl set-timezone Asia/Tokyo
言語設定
localectl status
sudo localectl set-locale LANG=ja_JP.UTF-8
sudo localectl set-keymap jp106
ホストネームの変更(再ログイン後に反映される)
hostnamectl status
sudo hostnamectl set-hostname abc
amazon-linux-extrasでまとめてサーバ構築
MariaDBとPHP7.2
amazon-linux-extras # パッケージ一覧の表示
sudo amazon-linux-extras install lamp-mariadb10.2-php7.2 # LAMP環境の一括構築
Nginx
sudo amazon-linux-extras install nginx1
Apache
sudo yum install -y httpd
sudo systemctl start httpd
sudo systemctl enable httpd
ec2-user
で/var/www/html
配下のファイルを編集したい場合
sudo usermod -a -G apache ec2-user
sudo chown -R ec2-user:apache /var/www
sudo chmod 2775 /var/www && find /var/www -type d -exec sudo chmod 2775 {} \;
find /var/www -type f -exec sudo chmod 0664 {} \;
Let’s Encrypt
sudo amazon-linux-extras install epel
sudo yum install -y certbot python2-certbot-apache python2-certbot-nginx
sudo systemctl restart httpd nginx
sudo certbot
renewを自動化する場合のcrontabの設定
39 1,13 * * * root certbot renew --no-self-upgrade
Node.js
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
. ~/.nvm/nvm.sh
nvm install node