This is my first question I hope I do it right. So :
I developed a MERN website, on which I have perfect connection with a MongoDB db as well as an Amazon S3 one.
I am currently trying to host it on a Hostinger VPS with Virtualmin and Webmin. The data is in thanks to FTP working, so the website design shows but the mongoDB data is missing.
So far :
- DNS set properly,
- SSH all good,
- mongo shell installed inside of server through the console, I can see my db and the data
- new user created successfully with mongo method db.createUser(), attached to my db
So my question is : what are the following steps to make the way to data, through the server, to the website ?
I'm new to this and I've searched for several days now everywhere without any success, and the hosting support is lost on the matter...
Thanks!
In case it helps anyone I did succeed in setting up the server, it's quite a bit of work. Here's my config :
The React frontend comes with a .env file that is integrated in the build. In it I set the url to where the frontend sends requests (these are then caught by Nginx). Be careful to set this url to the domain of your website when deploying, so in my case : https://example.com/api
The production process manager pm2 is useful to keep alive the backend at all times so I installed it and used it for the Node backend. The command to add the backend main server file (in my case server.js) to pm2 from the console :
sudo pm2 start your/serverfile/addressHere's a couple of links that proved very useful to understand how to configure the server :
Applicable to Amazon server but a lot applicable here too : https://jasonwatmore.com/post/2019/11/18/react-nodejs-on-aws-how-to-deploy-a-mern-stack-app-to-amazon-ec2
A guide to log journal in console for debugging : https://www.thegeekdiary.com/beginners-guide-to-journalctl-how-to-use-journalctl-to-view-and-manipulate-systemd-logs/
For setting up Webmin server : https://www.serverpronto.com/kb/cpage.php?id=Webmin
At first I discarded Webmin and Virtualmin since all I could find (from support included) was tutorials to setup the server via console. So bits by bits I set it up. Then, finally, I got from the support a tuto to setup the server from Webmin. But to this day I can't say wether that made a difference in the structure. But at least it's clean.
systemctl status theserviceyouwanttoseesystemctl start theserviceyouwanttostartsystemctl stop theserviceyouwanttostopsystemctl restart theserviceyouwanttorestartExamples of services : nginx, mongod...
Test if Nginx is setup properly :
sudo nginx -treload nginx config file after any modification :
sudo nginx -s reloadSee the last errors logged by nginx :
sudo tail -f /var/log/nginx/error.logSave current pm2 settings :
pm2 saveBackend execution logs :
sudo pm2 logsIdentify the processes still running with mongo (useful if mongod won't restart properly) :
pgrep mongoKill the mongo process to be able to start fresh :
kill <process>Show all services used by server :
sudo systemctlSee all processes in execution and stats of the CPU amongst other things :
topI'm still new to all of this despite my couple of weeks on the subject so this description is most probably improvable. don't hesitate to suggest any improvement, mistake, or ask questions, I'll do my best to answer them.
Cheers!