Complete Guide to Setting Up a Full-Stack Environment on Ubuntu: From Node.js to SSL
Introduction
This comprehensive tutorial guides you through setting up a full-stack application on an Ubuntu server, using Node.js for server-side logic, PostgreSQL as the database, and Nginx as the web server. We'll secure our application with HTTPS using Certbot, and explain creating a database user, a database, and connecting remotely using pgAdmin.
Prerequisites
A Ubuntu server
Root or sudo privileges on the server
Access to a terminal/command line
Steps
1. Installing Node.js with NVM
Install Node.js using NVM, which allows for managing multiple Node.js versions.
2. Setting Up SSH for Bitbucket
Prepare SSH keys for Bitbucket for secure repository operations:
3. Cloning the Repository
Clone the project repository and navigate into your project directory:
Handle any peer dependency issues with:
4. Installing and Configuring PostgreSQL
Install PostgreSQL and set it up:
5. Creating a Database and a User
Create a new database and a user in PostgreSQL:
6. Configuring PostgreSQL for Remote Access
Edit the PostgreSQL configuration file to accept remote connections:
Change to listen on all interfaces:
Modify client authentication:
Allow your specific IP:
Restart PostgreSQL:
7. Installing and Configuring Nginx
Set up Nginx to serve your application:
8. Enabling SSL with Certbot
Secure your application using SSL certificates with Certbot:
9. Automating SSL Certificate Renewal
Set up automatic renewal for your SSL certificates:
10. Final Verification
Ensure all configurations are correct and services are running:
Check your application via HTTPS in a web browser.
Conclusion
You've successfully set up a secure full-stack environment using Node.js, PostgreSQL, and Nginx on Ubuntu, complete with SSL certification. This configuration provides a solid foundation for deploying production-level applications.
Subscribe to my newsletter
Read articles from Narendra Solanki directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by