Setting up Laravel with AWS EC2 and RDS

Published on March 14, 2020

 

Note: This is not an how to ultimate guide, it's my personal documentation how I manage to set this up and for future cheatsheet.

 

Prerequisite

 

AWS EC2

  1. Create EC2 instance
  2. Select (Free tier eligible) Ubuntu Server 18.04 LTS (HVM), SSD Volume Type
  3. Select Next Configure Security Group
  4. Select Type: HTTP; Port Range 80
  5. I use key pair for additional security

 

A key pair consists of a public key that AWS stores, and a private key file that you store. Together, they allow you to connect to your instance securely. For Windows AMIs, the private key file is required to obtain the password used to log into your instance. For Linux AMIs, the private key file allows you to securely SSH into your instance.

 

You have to download the private key file (*.pem file) before you can continue. Store it in a secure and accessible location. You will not be able to download the file again after it's created.

Once the instance already created, you can now access the server using ssh

 

 

Installing Nginx

 

Checking web server

 

Now Nginx appears starterd successfully.

 

To check on the browser, call the public IP address that you can get on the instance page, then you can see the Welcome to NGINX!

 

For more detailed instruction I followed this tutorial!

https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-18-04

 

✏️ Note to self: Write Nginx cheatsheet for my future self!

 

Installing PHP

 

 

Configure SSH

 

Other resources:

https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys-on-ubuntu-1604

https://help.github.com/en/github/authenticating-to-github/error-permission-denied-publickey

 

Installing composer

https://linuxize.com/post/how-to-install-and-use-composer-on-ubuntu-18-04/

 

Configuring Nginx to Use the PHP Processor

 

Enable your new server block by creating a symbolic link from your new server block configuration file (in the /etc/nginx/sites-available/ directory) to the /etc/nginx/sites-enabled/ directory:

 

 

To test your new configuration

 

 

Reload NGINX to make the necessary changes

 

 

To test in the browser, create PHP file wit phpinfo();

 

 

It should display the PHP info.

 

🤔 What is the difference of Mysql and MariaDB?

 

Debugging

https://stackoverflow.com/questions/41147609/unable-to-start-the-mysql-server-in-ubuntu

https://stackoverflow.com/questions/37212945/aws-cant-connect-to-rds-database-from-my-machine

https://linuxacademy.com/guide/15653-using-aws-rds-with-laravel-october-cms/