DevOps
Information about Deployment of website projects from A-Z
Understand the nature of website deployment: from preparing the server, uploading code, running applications, DNS, Nginx to SSL. Don't deploy blindly, don't follow the tutorial with an empty head.
19/02/2026 · 15 min read · Lê Huy Thái
Hello everyone, to make a Website project from A to Z, it is difficult to avoid this deploy step. New developers are often afraid to deploy, or follow the copy-paste tutorial without understanding why, leading to errors that they don't know where to fix. Of course, on company projects there will be a devops team or the lead will set it up for you, but those working on personal or freelance projects still have to do it themselves.
This article will inform newcomers about pure project Deploy to have a more comprehensive view of what deploying a website project is like — and because it's about nature, it can be applied to most of the most popular frameworks and languages today.
- Who is it for: New developers who want to understand what deploy is, the big picture, followed the tutorial but don't quite understand it
- Why it's easy to understand: Talk about the nature, method and output of each stage
- Pure deployment: Not discussing services that support deployment: NextJs, Supabase, Mongo Atlas, ...
- 01Prepare Server Environment
In short, the Server is essentially like your computer and it will run 24/7.
Step I.1 — Rent a server
Usually running the Linux operating system (usually Ubuntu) instead of Windows/MacOS like my computer, there will be no GUI (desktop screen, icons, mouse, ...) but will have to use a command line window (like a terminal), so you will have to get a little familiar with the server's operating system.
Server costs range from cheap to expensive, from a few $/month to infinite, for example some parties include:
- Vultr
- Hostinger
- DigitalOcean
- Linode
- AWS
- Contabo — Recently I often use this guy for production projects, good configuration, cheap price (but the admin page looks like it's from 2000)
Before, I used to buy AWS Lightsail to install side projects, but my account was locked so I switched to another one
Output step I.1Rent a server (it costs money or it's free, it's up to you) and have information about that server (eg IP, username, password, ...)
Step I.2 — Get into that server
Essentially, it's about getting into that server for remote control (Team Viewer, Ultra View style). Here you should know the term SSH — SSH helps you control another Linux computer (server) from the command line window. Usually, after renting a server, you will be provided with information about SSH.
ssh root@IP_Public_Của_ServerOutput step I.2Once you get into the server, you will see the SSH command line window, like:
"Welcome! This server is hosted by Contabo. If you have any questions or need help, please don't hesitate to contact us at ..."
Step I.3 — Play around if you're not familiar
Most servers are Linux, and will operate using a command line window instead of a GUI. Need to build 2 habits here:
- When you encounter a command you don't know → search to understand/memorize
- Search to convert familiar actions to server commands (for example: create a directory on Ubuntu, check if a package exists, install git, install nodejs, ...)
Output step I.3Try moving into the
/var/wwwdirectory, creating a directory, deleting a directory, creating an md/txt file, editing the content, saving the file, viewing the list of components of the directory you just played with,... - 02Upload Code to Server
There are many ways to do this, but the most common is to use Git. Clone the project on the local machine and on the Server it will be the same (but remember, the operating system may be different).
For example, locally you need to install git, setup authentication with git or add an SSH key, or the easiest way is to use personal access token — then on the server the steps are the same, the only difference is the operation of another operating system — just search and you'll find it.
Output this stepThere is a folder containing code (for example in
/var/www/name-du-an), move to the folder containing code, see the file list. - 03Make Project Run on Server
At this step, there will usually be 2 main types:
- Static frontend — static frontend code or static output (HTML/CSS/JS or ReactJs, VueJs, ...)
- Dynamic Backend / Frontend — dynamic backend or frontend code (with running process, with port instead of static build, NextJs, NuxtJs, ...)
Static frontend
If the project is pure HTML/CSS/JS, you don't need to do this step anymore → jump to the next step.
If they are frontend libraries/frameworks (ReactJs, VueJs), they will all provide the build function and when built, there will be folders like
build,dist,output, etc. Read the docs related to building or running production to know.The principle is that the technologies, running processes, accessing ports... are to make it easier for us to develop, but when running in production, it will build pure HTML/CSS/JS.
Output — Static frontendThere is a folder containing pure HTML/CSS/JS code.
Dynamic Backend / Frontend
This one will be a bit more difficult than the frontend, but in essence it will be exactly the same way you make local code run.
Let's go back to the beginning when you started learning to code - what did you need to do to install the environment for the project to run (for example, you need to install Git, NodeJs, MongoDB, Postgres, ..., note that for the project to run, but for the devs, you don't need to - like you don't need to install an IDE
) you will have to do the same thing on the server (but the operating system may be different). This place will need to do 2 main things: Run and check that it works.
III.1 — Environment settings
For example, the project needs NodeJs → check to see if NodeJs is available. If not, install it. The project needs MongoDB → check to see if MongoDB is available. If not, install it. After installing, check again. Almost every library has a way to check the version and status.
Output step III.1Check the version and status of the things that need to be installed to run the application. For example, my application needs: NodeJs, MongoDB.
III.2 — Setup database if necessary
If the project needs a database, learn how to install the database, set it up and test it to see if the database is working - just one search will turn up a lot. For example:
"Setup MongoDB Ubuntu".Output step III.2Check that you have installed the Database and can access the Database to create a test table.
III.3 — Setup Env if necessary
There will be information placed in env. If the project has this file, now you need to create an env file and configure it. Need to know commands and tools to edit files (style
vi,vim,nano, ... choose 1, easiest isvi).Output step III.3There exists a
.envfile in the source code directory and has data inside.III.4 — Install dependencies if needed
Usually, the source code will use Dependency management tools — the NodeJs type is
npmoryarn, PHP iscomposer, Python ispip, ... Now we will run the dependency installation command (typenpm install).Output step III.4There exists a directory containing dependencies (
node_modules,vendor, ...)III.5 — Test run dev mode
This is a dev test run to see if it works, the purpose is to check if the setup was correct. Exactly the same as running locally, why does it run here — for example
npm run dev,yarn dev, ... etc. After running the test, turn it off.▲ Next.js 16.0.7 (Turbopack) - Local: http://localhost:3000 - Network: http://192.168.2.7:3000 - Environments: .env ✓ Starting... ✓ Ready in 981msIII.6 — Run prod mode
This will be the mode that helps our website run 24/7. Instead of running additional tools to help devs effectively, Prod mode will optimize and only run the necessary parts. Frameworks have instructions for building and running this way — for example
npm run build. There may be tools to help projects run code without needing to maintain a terminal, for example NodeJs will have PM2 - this depends on the library/framework.Output step III.6You can check the application logs to see if it is running, you can
curlintolocalhost:portto see if there is a response,...Great tipAt this step, open the public port where the project is running (for example, open firewall port 3000) => you will see the application running at 'IP:3000'. If the IP looks too dull, hard to remember, or unable to recognize the brand, please go to the next stage.
- 04Buy and DNS Domain Names
The domain name is like a home address and the server is like a house - you already have a home, but if you want others to find it easily, you need an easy-to-read and easy-to-remember home address. Just buy 1 domain name.
There are many domain name providers like tenten, matbao, hostinger, ... (I often buy from hostinger). Actually, buying a domain name is the same, you can buy it wherever you like. Prices range from a few tens of thousands to several million. Free is also up to you.
After purchasing the domain name, look for a section called DNS. The purpose of this function is to set where this domain name will point. Just imagine DNS as a phone book — it stores and directs where a domain name will lead. Now you will need to point the domain name to your server IP.
For example: Record A →
123.456.789.xxxOutput this stepCheck the domain name pointing to the server. There are many ways to check where a domain name is pointing like
ping domain,traceroute,whois, ...Note about DNSThis place is sometimes very hot, so you need to stay calm and not get impatient. You can point DNS and do something and check later.
- 05Make the Server Accept the Domain Name
This place is divided into 2 branches: Static Frontend and Dynamic Backend / Frontend. But basically you will need to know something called Reverse Proxy and the basic request diagram is as follows:
User/Browser → Domain → DNS → Server → Reverse Proxy → Your App
In the previous step, we have already pointed the domain to the server. When accessing the domain name, it will be pointed to the server, but how to get the server to accept and receive that request and then point it to our code requires a guy called Reverse Proxy. If you have heard of guys like Nginx, Apache, ... then these guys have such functions.
V.1 — Reverse Proxy Settings
It's up to you to choose, but usually it also follows the ecosystem: NodeJs uses Nginx a lot, PHP uses Apache a lot, ... and so on (I often use Nginx).
Similar to installing libraries - after installation, check to see if it has been installed, check the status.
V.2 — Config Reverse Proxy
We have made the domain name point to the server in the step above, now we need to define in the reverse proxy config file: which domain name to accept, when this domain name arrives, where to point. There will be 2 major styles:
- Static frontend: points to the HTML/CSS/JS folder
- Dynamic Backend / Frontend: points to port (eg
localhost:3000)
Nginx config example for Dynamic Backend / Frontend:
server { listen 80; server_name your_domain; 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; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }This is the Nginx file to point to the port, and pointing to the directory is the same, please try searching.
Output this stepThere is a Reverse Proxy config file with all 2 parts above, access the domain name to see if you see the project.
In theory, at this step, when accessing the domain name, you will see the application, and deploying here is basically done. But if you are a newbie, this rate will be very low
— so I have one more section called "A few extra things" please read on. - 06A few outliers
Life is not like a dream, and the code on the server often crashes the first time you press run. This section will equip you with thinking to handle things when things don't work, and make the website more "reputable".
VI.1 — Basic Debug
When typing the domain name and the website doesn't appear, don't panic and type the code haphazardly. Let's calmly imagine Request's path:
Browser → Domain → Server → Nginx (Guardian) → Your App (Code)
Wherever the error is, fix it there:
- "Site can't be reached": The security guard (Nginx) is sleeping or dead. Check if Nginx is running.
- Error 502 Bad Gateway: This is the most common error. That means the security guard (Nginx) is still alive, but your App inside is dead, or the App is running on the wrong port than Nginx knows.
- Error 500 or App crash: If you can access the website but the page is blank or shows a logic error, it's due to your code. At this time, you must Read Logs. Every server has a file that saves error history (Error Log). When you open it, you will immediately know which line of code is wrong.
Principles of debugging on the serverAlways imagine where the request goes from to where, and at what step the error occurs, fix it at that step. Don't guess.
VI.2 — SSL/HTTPS — The green lock
In this day and age, if the website displays the word "Not Secure" in red, no one dares to access it. You need to install SSL so that the website has a green lock (HTTPS protocol).
- Essence: It is a certificate to authenticate that your website is safe.
- How to do it: No need to buy anything complicated, use a free tool called Certbot (Let's Encrypt). Just run it, it will automatically ask for a certificate and automatically configure Nginx for you. Very leisurely.
VI.3 — Firewall — Door blocker
Many times, the website is still not accessible after just setting up from A-Z. The reason is that the Server (or Server provider like AWS, Vultr...) is closed and no one is allowed in.
- Essence: By default, all server ports are closed for security.
- How to do: If you want people to visit the website, you must Open Port: port 80 (for HTTP) and port 443 (for HTTPS).
Be careful — never do thisDon't accidentally close port 22 (SSH) if you don't want to be locked out of the server forever - you have to contact provider support for rescue.