🪟 Windows TippsWindows 11: Nach Apples Erfolg ändert auch Microsoft den Kurs(26.08.2026 um 09:55 Uhr)
🪟 Windows TippsStichtag 13. Oktober: Windows 11 legt den Schalter um(02.09.2026 um 16:09 Uhr)
🪟 Windows TippsVersteckt in Windows 11: Nutzer entdeckt geheimes Feature(10.09.2026 um 08:37 Uhr)
🪟 Windows TippsWindows 11: Nach Apples Erfolg ändert auch Microsoft den Kurs(26.08.2026 um 09:55 Uhr)
🪟 Windows TippsStichtag 13. Oktober: Windows 11 legt den Schalter um(02.09.2026 um 16:09 Uhr)
🪟 Windows TippsVersteckt in Windows 11: Nutzer entdeckt geheimes Feature(10.09.2026 um 08:37 Uhr)

🔧 Programmierung 🕛 vor 2 Jahren 7 Min Lesezeit
0

Deploy MERN Stack in Digitalocean (2024 version)

↗ Quelle (dev.to)
🗣️ Stimme:

What is Digitalocean?



Digital Ocean is a cloud computing provider that basically offers you a virtual machine (a server) to host your web application.



What do you need?



A basic MERN application (Mongo, Express, React, Node)



In case this is your first time deploying to production, it is better to have a domain name but it is not essential as you can access your website after deployment with an IP address.



Getting Ready:



1- If you do not have an account create one in Digitalocean 



4- Create a VPC under networking tap this will create a private network so you can access all resources with private IP addresses like DBs droplets and load balancers.




  • In the left corner, select networking then select VPC Network.

  • Select the region where you want your VPC better to select one that is near to your country.

  • Keep the default IP address to be generated by digitalocean.

  • Choose a name and description.

  • Create a VPC network.







5- Now lets create a droplet(server) to host our application.




  • In the left corner select Droplets then create Droplet.






  • Here I will go with Ubuntu, or if you want to go with markeplace click it and search for mern.






  • I will not add any Additional Storage or backups as this is only for testing and learning.

  • Choose Authentication Method I will go with a password and keep this password with you as you will use it for login to the server.

  • Finalize Details by selecting how many droplets you want I will go with one if you want two you can create it and will have the same configuration.





Now let's create a directory to place our application let's create in root directory.




CODE
cd /









CODE
mkdir mern-apps









CODE
cd mern-apps






Now we are in mern-app directory you can do pwd to check path, what we need to do is to git all our code files we can clone any node/express app from github.



Once you clone the project, we need to install node dependencies and prepare the frontend build for production (the react app).



to install node modules:




CODE
npm i 






To create a frontend build ready for production.




CODE
npm run build 






Notice the build has the index.html which we will tell nginx(webserver) to root all requests to this file.



Now if you try to copy the public IP in Google Chrome this won't work,

we need to install two things Nginx to accept requests on port 80 and PM2 which is node processing manager that will ensure running the node without logging in to the server.



Install PM2:




CODE
sudo npm i -g pm2






Install Nginx:




CODE
sudo apt install nginx






We need also to enable the firewall in the server to access the ports right now to check the firewall status is inactive.



to enable




CODE
sudo ufw enable






By default, if you enable the firewall all ports are blocked.



We need to enable three ports to access the server ports 80, 443, 22




CODE
sudo ufw allow ssh









CODE
sudo ufw allow http









CODE
sudo ufw allow https






Now if you copy the public IP and run it in Chrome you see the default Nginx webpage.



Great now we are able to install Nginx but we need our front-end page, not the default Nginx web page to do this let's see the nginx config file and change it.




CODE
cd /etc/nginx/sites-available






If you do ls -ltr you will see the default file which has all the configuration for the nginx server let see what is inside and change it to our needs.



With nano command you can view and change the file content, the most two important changes are the root and location.




CODE
sudo nano default






In Server block change the default root which was for default web server page change it to your index file page in my front-end app it looks like this



root /mern/JWT-/frontend/dist;



if you run the build with react app you get /build but since i used vite as a front-end /dist is the folder name.



if you have an api with you need to add the location of your api.




CODE
location /api/ {
proxy_pass http://localhost:8000; # Your Node.js/Express server address and 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;
}






Sample of default file



Sample of default file



Now to save changes of default file click controll x Y enter.



Since we change the nginx config file we need to restart nginx




CODE
sudo systemctl nginx restart






Now refresh and you will see your web page out.



Please dont hesitate to ask any Questions.

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
The Gemini desktop app is now available for Windows
1 Quelle
ChatGPT automatically logged out [Fix]
1 Quelle
Windows 11 just dropped the tool ransomware abused, Microsoft says don’t restore WMIC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Deploy MERN Stack in Digitalocean (2024 version)

Thematisch verwandte Begriffe: Deploy, MERN, Stack, Digitalocean · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...