Launch a AWS EC2 instance, the testing instance is Amazon Linux 2 AMI (HVM), SSD Volume Type - ami-0d7ed3ddb85b521a6
Connect to your EC2 instance, and enter sudo vim /etc/httpd/conf.d/yourProjectName.conf
paste the following code
<VirtualHost *:443> # port 443 for https ServerName letussleep.space # Your domin name DocumentRoot "/var/www/html/yourLaravelProjectName/public" # The absolute address of your project on EC2 SSLEngine on SSLCertificateFile /whateverLocationYouWant/certificate.crt SSLCertificateKeyFile /whateverLocationYouWant/private.key SSLCertificateChainFile /whateverLocationYouWant/ca_bundle.crt # They are for SSL signing purpose, corresponding to those validation files you get from SSL signing service. </VirtualHost>
<VirtualHost *:80> # port 80 is for http ServerName letussleep.space DocumentRoot "/var/www/html/yourLaravelProjectName/public" redirect / Https://letussleep.space # When user connect this project via http, redirect to https </VirtualHost>
<VirtualHost *:80> ServerName oldletussleep.space # So, basically in a conf file, we could complete multiple project deployment once we set the domain name properly. DocumentRoot "/var/www/html/yourProjectName/public"
Although we could complete multiple project deployment in a single config file once we set the domain name and project address properly, I personally prefer one config file to one project to prevent any possible confusion in the future.
So simply repeat all the steps mentioned above, creating a new config file, and config it properly, and then type sudo service httpd restart