Amazon EC2 LEMP Install

# Setup
sudo yum -y update
sudo yum install -y gcc make
sudo amazon-linux-extras install php7.3 nginx1.12
sudo systemctl enable nginx
sudo systemctl start nginx
sudo systemctl enable php-fpm
sudo systemctl start php-fpm

# MariaDB
sudo yum install -y mariadb-server
sudo systemctl enable mariadb
sudo systemctl start mariadb
sudo mysql_secure_installation

# PHP
sudo yum install -y php-xml php-xmlrpc php-zip php-gd php-mbstring php-soap
sudo yum install -y php-devel php-pear

# Imagick
sudo yum install -y ImageMagick ImageMagick-devel ImageMagick-perl
sudo pecl install imagick
* add "extension=imagick" to /etc/php.d/20-imagick.ini

# Folder Permission
sudo mkdir /var/www
sudo usermod -a -G nginx ec2-user
exit
groups #ec2-user adm wheel nginx systemd-journal
sudo chown -R ec2-user:nginx /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 {} \;

# PHP-FPM Config
sudo vi /etc/php-fpm.d/www.conf
* 修改以下參數
user = nginx
group = nginx
listen = 127.0.0.1:9000

# NGINX Config
sudo vi /etc/nginx/conf.d/php-fpm.conf
* 修改以下參數
upstream php-fpm {
server 127.0.0.1:9000;
}

sudo vi /etc/nginx/nginx.conf

sudo systemctl restart php-fpm
sudo systemctl restart nginx

# TimeZone
sudo vim /etc/sysconfig/clock
ZONE=”Asia/Taipei”
UTC=true
sudo ln -sf /usr/share/zoneinfo/Asia/Taipei /etc/localtime
#修改php.ini timezone設定

# Composer
cd ~
sudo curl -sS https://getcomposer.org/installer | sudo php
sudo mv composer.phar /usr/local/bin/composer
sudo ln -s /usr/local/bin/composer /usr/bin/composer

# GIT
sudo yum install git

sudo reboot