This video is part of the following playlists:
Deploy Node app on AWS EC2 Amazon Linux 2 by installing node js and setting the app up as a systemd service
https://github.com/sam-meech-ward-bcit/lotr
sudo yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_16.x | sudo -E bash -
sudo yum install -y nodejs
sudo yum install -y git
sudo vim /etc/systemd/system/YourAppName.service
[Unit]
Description=YourAppName
After=multi-user.target
[Service]
ExecStart=/usr/bin/node /home/ec2-user/your_app_dir/server.js
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=YourAppName
User=ec2-user
EnvironmentFile=/home/ec2-user/your_app_dir/app.env
[Install]
WantedBy=multi-user.target
Note
Remember to put the environment variables in /home/ec2-user/your_app_dir/app.env
And make sure each env var is put on a new line.
sudo systemctl enable YourAppName.service
sudo systemctl start YourAppName.service
sudo amazon-linux-extras install nginx1 -y
sudo systemctl enable nginx
sudo systemctl start nginx
sudo vim /etc/nginx/nginx.conf
location / {
proxy_pass http://localhost:8080;
}
sudo systemctl restart nginx
Find an issue with this page? Fix it on GitHub