Skip to content

Black Friday: up to 50% off.

Cloudzyro
How-to

How to deploy a website: builds, Git and rollbacks explained

Kofi Agyem

, Founder and CEO, CloudzyroPublished · 7 min read

On this page
  1. 1. The short answer
  2. 2. What happens during a deploy
  3. 3. Step 1: get your project ready
  4. 4. Step 2: choose how you'll deploy
  5. 5. Step 3: set environment variables
  6. 6. Step 4: watch the first deploy
  7. 7. Step 5: deploy changes safely
  8. 8. Step 6: roll back when something breaks
  9. 9. Step 7: connect your domain
  10. 10. Framework guides

How to deploy a website or web app: build and start scripts, deploying from Git, a zip or an AI tool, environment variables, staging and rolling back.

1. The short answer

To deploy a website, give your project a build script (and a start script if it runs a server), send it to a host by Git, upload or your AI tool, set its environment variables, and let the host build it, start it and switch visitors over once it answers. After the first deploy, connect Git so every push deploys by itself, and keep the last few versions so you can roll back in seconds.

This guide explains each part so you know what's happening and what to check when it fails. The examples use Cloudzyro's Sites & Apps, but the ideas are the same on any modern host. New to all this? Start with how to publish a website, which is less technical.

2. What happens during a deploy

  1. Receive the code: from a Git push, an uploaded folder, or an AI tool sending files.
  2. Work out what it is: a static site (an index.html), a site with a build step (Vite, Astro, React) or an app with a server (Node.js, Next.js).
  3. Install and build: install dependencies and run your build script, which turns your source into the files or program that will actually run.
  4. Start and check: serve the built files, or start your server and check it answers.
  5. Switch over: send visitors to the new version and keep the old one as a version you can go back to.

On Cloudzyro the new version goes live only after it has started and passed a health check, so a broken build never replaces a working site.

3. Step 1: get your project ready

Hosts read your package.json to know how to build and run your site. A site with a build step needs a build script; an app with a server also needs start:

{
  "scripts": {
    "build": "next build",
    "start": "next start"
  },
  "engines": { "node": "24" }
}
  • Build should finish. It makes the files and stops. Starting a development server (npm run dev, vite, next dev) in the build is the most common reason builds hang until they're stopped (after 15 minutes on Cloudzyro).
  • Listen on PORT. An app with a server must listen on the port in the PORT environment variable, on all network addresses, not only localhost.
  • Pin your Node.js version with engines.node or an .nvmrc file if your framework needs a particular one. Cloudzyro uses Node 24 unless you say otherwise.
  • Commit your lockfile (package-lock.json, pnpm-lock.yaml or yarn.lock) so the server installs the same versions you tested.
  • Run the build on your computer once (npm run build). If it fails there, it'll fail on the server.

A plain HTML site needs none of this: an index.html at the top of the folder is enough.

4. Step 2: choose how you'll deploy

From Git (best for anything you'll keep changing). Connect a repository on GitHub, GitLab, Bitbucket or any Git host, choose the branch and folder, and deploy. From then on, each push to that branch becomes a new version by itself. In a monorepo, set the folder to where the site lives, such as apps/web.

By upload (best for a one-off or a site with no repository). Drop a folder or a .zip into the console. We check the files in your browser first and leave out what never belongs online, such as node_modules, .git, build output when there's a package.json (we build it ourselves) and .env files.

From your AI tool (best if an AI wrote the code). Connect Cloudzyro to Claude, ChatGPT, Cursor or Codex through MCP and ask it to deploy. It sends the files, follows the build and gets the reason and a suggested fix if it fails. How that works, and what the connection can and can't do: an MCP server to deploy websites.

While a site is connected to a repository, new versions come only from Git, so a teammate's upload can't quietly overwrite what's in the repository.

5. Step 3: set environment variables

Settings that change between your computer and the live site, such as API keys and database addresses, belong in environment variables, not in your code. Add them on the site's Environment variables tab; you can paste a whole .env file at once, and mark secrets Sensitive so they're never shown again.

Two things catch people out. Variables a framework builds into the browser code, such as NEXT_PUBLIC_ or VITE_ ones, are fixed when the site is built, so deploy again after changing them. And anything built into browser code can be read by every visitor, so never put a secret key there. More in environment variables explained.

6. Step 4: watch the first deploy

The first deploy is the one most likely to fail, because it's the first time your project meets a clean server. Follow it on the deploy's page. Most sites build in a minute or two. If it fails, the page says why in plain words, shows the last lines of the build log, and has a Try again button; your previous version, if there is one, stays online.

The common causes, with fixes: no start command, missing files at the top of the folder, a crash on start (usually a missing environment variable), the wrong port, a build that ran out of memory or took too long, or a framework that needs a different Node.js version. Each is explained in the docs' Fix a failed deploy. If the site deploys but shows errors, see 500 internal server error and what a 502 error is.

7. Step 5: deploy changes safely

  • Staging first. A staging copy of your site, at staging--yourname.cloudzyro.app, has its own versions and environment variables, such as test payment keys. Deploy there, check it, then Promote to production, which rebuilds the same files with production's variables. Staging is included on every plan.
  • Run migrations before the switch. A pre-deploy command, such as npx prisma migrate deploy, runs in the new version before it starts. If it fails, the new version doesn't go live and the current one keeps running. Write migrations so the old version still works while they run: add a column before removing the old one.
  • Pause automatic deploys during a freeze, per site or for a whole workspace, and resume when you're ready.

8. Step 6: roll back when something breaks

Every deploy is kept as a version. If a change breaks something, restore the version before it: on Cloudzyro, open the Versions tab and select Restore. It switches back in a few seconds because it reuses the version as it was built. The free Launch plan keeps your last 5 versions to restore and Boost keeps 10, and you can download any version's files as a zip.

Restoring code doesn't undo changes to your database, so treat migrations with care. Files your site wrote while running are cleared on a restore, as on a deploy, which is why data belongs in a database.

9. Step 7: connect your domain

Deploy to the free cloudzyro.app address first and test there. When it's right, add your domain on the site's Domains tab and add the records it shows. Moving a live site from another host? Lower your DNS records' TTL a day ahead and keep the old host running until the new one is serving everyone. How to connect a domain to a website has the details.

10. Framework guides

For framework-specific settings, see how to deploy a React app, how to deploy a Next.js app, and the hosting pages for Node.js, Vite, Astro and plain HTML. Sites & Apps runs static sites and Node.js apps; WordPress and PHP sites run on Web Hosting instead.

Questions

What does it mean to deploy a website?
Deploying a website means turning your code into a running version on a server and switching visitors to it. For a static site that's copying files; for an app it means building it, starting it and checking it answers before it replaces the old version.
What's the difference between deploying and hosting?
Hosting is where your site lives and runs. Deploying is the act of putting a new version there. You host a site once; you deploy it every time it changes.
How do I deploy a website from GitHub?
Connect the repository to a host that supports push to deploy, choose the branch and folder, and deploy. On Cloudzyro, every push to that branch then builds and goes live by itself, and each commit is marked on GitHub with whether it went live.
How do I roll back a bad deploy?
Restore the previous version. On Cloudzyro, open the site's Versions tab and select Restore on the version you want; it switches back in a few seconds without a new build. The free plan keeps 5 versions to restore and Boost keeps 10.
Why did my deploy fail?
The usual causes are a missing build or start script, a missing environment variable, an app that doesn't listen on the PORT it's given, or a build that runs out of memory or time. The deploy's log names the cause, usually in its last lines.

Put your site online free

From your AI tool, Git or a zip, with every version kept.