- Change the
URIinmain.tsto the production URI. - Build the project with
npm run build. - Run
npm run previewto preview the application before deployment. - SSH into the VM with
ssh <username>@it2810-16.idi.ntnu.no. Replace<username>with your username. - Copy files from the dist folder to the VM with
scp -r dist <username>@it2810-16.idi.ntnu.no:/tmp/. Replace<username>with your username. - If there is already a version of the project on the VM, run
sudo rm -r /var/www/html/project2to remove the old files. - Move files from
/tmp/distto/var/www/htmlwithsudo mv /tmp/dist/* /var/www/html/project2.
- SSH into the VM with
ssh <username>@it2810-16.idi.ntnu.no. Replace<username>with your username. - Copy files from the
serverfolder to the VM withscp -r server <username>@it2810-16.idi.ntnu.no:/tmp/. Replace<username>with your username. Remember to also transfer the.envfile, or create a new one on the server. - If there is already a version of the server on the VM. Stop the old server by finding the id with :
ps -Af | grep node. Runkill -9 pidto kill the process. Runsudo rm -r /var/www/serverto remove the old files. - Move files from
/tmp/serverto/var/www/withsudo mv /tmp/server/* /var/www/server. - Make sure the apache server can run node v.16+
- Navigate to the server and run
NODE_ENV=production nohup node src/index.js &to start the server- To start a server at a spesific port, run
PORT=<port> nohup node src/index.js &. Replace<port>with the port you want to use. Any information you want displayed with the process name can be added before the ampersand. - If you do not have .env on the server, or just want to set the URI manually, run
NODE_ENV=manual nohup node src/index.js <uri> &. Replace<uri>with the URI you want to use. This can be combined with port configuration.
- To start a server at a spesific port, run