How to Deploy a Full-Stack Web Application on a Cloud Server (Step-by-Step)
Keywords: cloud server and application, deploy full-stack app, cloud deployment tutorial
Deploying a full-stack web application on a cloud server might seem intimidating, but with the right guidance, it’s simpler than you think. Whether you're building with Node.js, React, or Python, this guide will help you move from development to production step-by-step.
๐ Step 1: Choose a Cloud Server Provider
Popular cloud hosting providers include:
For this guide, we’ll use Ubuntu 22.04 LTS on DigitalOcean Droplets.
๐ Step 2: SSH into Your Cloud Server
ssh root@your_server_ip
Make sure you have your SSH key or password set up. You can generate a key using:
ssh-keygen
⚙️ Step 3: Install Essential Software
Update your packages and install Node.js, Git, and Nginx:
sudo apt update && sudo apt upgrade -y
sudo apt install nodejs npm git nginx -y
node -v
npm -v
๐ Step 4: Clone Your Application from GitHub
cd /var/www/
git clone https://github.com/yourusername/your-repo.git
cd your-repo
npm install
๐️ Step 5: Set Up Your Backend (e.g., Node.js)
Run your server with:
node server.js
Or use PM2 to keep your server running in the background:
npm install -g pm2
pm2 start server.js
pm2 save
๐ Step 6: Configure Nginx as a Reverse Proxy
Set up a config file in /etc/nginx/sites-available/yourdomain.com
:
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Enable the site and restart Nginx:
ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/
nginx -t
sudo systemctl restart nginx
๐งช Step 7: Test Your Application
Visit your domain in a browser. You should see your front-end served and API routes working. Use browser console and DevTools to inspect issues.
๐ Optional: Secure Your App with SSL
Use Let's Encrypt Certbot to add HTTPS:
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d yourdomain.com
๐ฆ Final Thoughts
Congratulations! Your full-stack web application is now live on a cloud server. Whether you’re running a MERN stack, LAMP stack, or Django app, this deployment method works across the board.
Useful Resources:
Need help? Drop a comment below or contact us for deployment services.
Comments
Post a Comment