(Only a template, not the actual repo for https://calconvergent.com)
- Get your AWS ec2 Instance setup (aws.amazon.com). Go with the default free tier options for everything.
- ssh into your instance and Clone this repo
- Run this command to start the server (MAKE SURE IT WORKS)
adonis serve --dev
This must be done so that the website works even when your computer is off. You can use pm2 to do so.
- Run this command
npm install pm2 -g
- Run this command
pm2 start server.js
The server has now started! You must run this to stop it:
pm2 stop all
Checkout pm2 documentation for more commands.
Right now, the site requires a specific port to be accessed. We want to eliminate the need for a port number like 3333, 3000, 5000 etc. so we will get it working on the default port (80). We need nginx for this.
- Run this command. If it gives an error, follow the error instructions for installation.
sudo yum install nginx
-
Change your AWS ec2 inbound rule to have the following port open: HTTP, TCP, Port 80, Source: 0.0.0.0/0
-
Now run this command
sudo nano /etc/nginx/nginx.conf
- This opens nano, a text editor. Use nano to modify the file to look like this:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
root /usr/share/nginx/html;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
- Finally, run this command:
sudo service nginx restart