Saturday, September 12, 2020

install wordpress with php7 on aws ec2 t2.micro

 AWS EC2 t2.micro's default PHP version is 5.4, which is not supported by wordpress anymore.

Here is the bootstrap to install latest wordpress with PHP7 on AWS EC2 t2.micro


#!/bin/bash

yum update -y

amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2

yum install httpd -y

cd /var/www/html

wget https://wordpress.org/latest.tar.gz

tar -xzf latest.tar.gz

cp -r wordpress/* /var/www/html/

rm -rf wordpress

rm -rf latest.tar.gz

chmod -R 755 wp-content

chown -R apache:apache wp-content

sudo echo "


# BEGIN WordPress

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</IfModule>

# END WordPress


" > .htaccess

chkconfig httpd on

systemctl start httpd