Guide to Deploying a Website on DigitalOcean Droplet/Server

Guide to Deploying a Website on DigitalOcean Droplet/Server

1. Ensure that you've thoroughly tested, optimized, and uploaded your code to a GitHub repository.

YouTube Step-by-Step Tutorial: Guide to Deploying a Website on DigitalOcean Droplet/Server

2. Begin by creating a DigitalOcean account, you can sign up using this link (https://m.do.co/c/ac8ddb2ca45f) and get a $200 credit that is valid for 60 days and then proceed to create a droplet. Set either a password or an SSH key, along with a hostname for your droplet.

3. Log in to your droplet using a terminal by typing the following command:

ssh root@your-ip-address

4. Install Node.js and npm on Ubuntu. You can follow this guide to install them: https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-22-04

5. Clone your repository to your droplet. Make sure you've created a personal access token to clone it.

6. After cloning, navigate to the folder where you've cloned the code and run the command:

npm install

7. Once you've installed the required packages, start the project to ensure it's functioning correctly on your IP address.

8. Install Nginx on your droplet to host your website on a domain, sub-domain, or your droplet's IP address. You can follow this guide to install Nginx: https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-22-04

9. Link your domain or sub-domain and configure Nginx settings.

Move to the following folder and configure file:

/etc/nginx/sites-available 

Configuration code:

server {
    listen 80;
    server_name domain-or-sub-domain-url-here;

    root /folder-path;
    index index.html;

   location / {

        proxy_pass http://ip-address-here:port;
        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;
       }
}
sudo nginx -t
sudo systemctl reload nginx

10. Enhance the security of your website by adding an SSL certificate. You can follow this guide to secure it: https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-22-04

11. Create a production build using the command

npm run build

12. Install PM2 and use it to keep your app running.

npm install pm2@latest -g
pm2 start npm --name "aamax" -- run start
pm2 save

Additional useful commands:

pm2 logs
pm2 status
pm2 restart {id}

Congratulations! Your app is now up and running smoothly. Alhamdulillah.

13. Consider enabling the backup for your droplet.

Note:

When uploading the backend code, you will require additional configurations for the backend and database, such as MongoDB and PostgreSQL.

Additionally, you can add multiple sites to your droplet.

Related Blogs

What to Put on the Homepage of a Website: 10 Key Elements for Your Homepage

What to Put on the Homepage of a Website: 10 Key Elements for Your Homepage

Master the art of homepage design with 10 must-have elements that boost user experience, credibility, and conversions for any business website.

What Is Google Lens and How Do You Use It?

What Is Google Lens and How Do You Use It?

Get a complete guide to using Google Lens — a powerful tool that helps you identify objects, translate text, shop, and discover the world effortlessly...

How Much Does Facebook Advertising Cost in 2025?

How Much Does Facebook Advertising Cost in 2025?

Get the full breakdown of Facebook advertising costs in 2025, including CPC, CPM, and CPA benchmarks, plus expert strategies for budget optimization....

Why Is My Website Not Secure — Securing Your Site with HTTPS

Why Is My Website Not Secure — Securing Your Site with HTTPS

Learn why your website shows a "Not Secure" warning and how to fix it with HTTPS. Protect your visitors, boost SEO, and build trust with proper websit...

Can You Do SEO Yourself? How To DIY SEO & When to Outsource

Can You Do SEO Yourself? How To DIY SEO & When to Outsource

Thinking of DIY SEO? Find out how to optimize your site, build backlinks, and when it’s smarter to outsource SEO to achieve better online visibility....

How Much Does a Website Cost in 2025?

How Much Does a Website Cost in 2025?

Wondering how much a website costs in 2025? Explore detailed pricing breakdowns, key factors, and hidden expenses to plan your budget smartly.