Everything About Deploying a PHP + MySQL Web Application to AWS EC2

Photo by Matt Brett on Unsplash

Introduction

The App and Database

Start & Configure an EC2 Instance

chmod 400 yourKey.pem

Set up LAMP on your EC2 instance

sudo apt-get update
sudo su
apt-get install apache2
systemctl status apache2
sudo apt-get install php php-mysql mysql-server
systemctl status mysql
mysql -u root -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your password'mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yue'exit
sudo apt-get install phpmyadmin
/etc/init.d/apache2 restart
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.confsudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadminsudo service apache2 restart

Migrate source code to EC2

root@ip-xxx-xx-xx-xx:/var/www/html# chmod 777 /var/www/html
root@ip-xxx-xx-xx-xx:/var/www/html# ls
covid-vic index.html phpmyadmin
root@ip-xxx-xx-xx-xx:/var/www/html# cd covid-vic/
root@ip-xxx-xx-xx-xx:/var/www/html/covid-vic# cp -r * /var/www/html
root@ip-xxx-xx-xx-xx:/var/www/html/covid-vic# cd ..

Migrating your data