How do I "run server.js file through SSH commands" in my nginx server

December 2, 2019 151 views
Nginx Node.js WordPress

Hello, and thanks for your time.

I am very new to cloud and there are a lot of things I don’t understand.

We bought a wordpress theme that has a chat integrated with node and socket.io.

I already created my droplet with LEMP and installed wordpress and node.js but according to the theme’s documentation I need to run a server.js file that the theme has on it’s files.

(https://amentotech.ticksy.com/article/14850/)

Can someone please help me out? I’ve been googling for 2 days now but I don’t think i’m typing the right querys because i would’ve found the answer by now.

You can just point me in the right direction and I will find the answer if you like :D

Thanks

edited by bobbyiliev
1 Answer

Hello,

Indeed the instructions are not very clear.

What you need to do is:

  • SSH to your Droplet

  • Then cd to the directory of your theme:

cd /var/www/html/wp-content/themes/name-of-your-theme/js

Note that you would need to adjust the path in case that your website is not stored at the /var/www/html folder and also adjust the name of your theme part.

  • Then to run the server.js file just run:
node server.js

The problem with that approach is that as soon as you close your SSH session the process would stop. So what I could suggest instead is to use PM2, you could take a look at this tutorial here on how to do that:

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04

Hope that this helps!
Regards,
Bobby

by Brennen Bearnes
Node.js is an open source JavaScript runtime environment for easily building server-side and networking applications. Node.js applications can be run at the command line but this guide focuses on running them as a service using PM2, so that they will automatically restart on reboot or failure, and can safely be used in a production environment.
Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!