Operations 12 min read

Quick Guide to Deploying a Hexo Blog on a Lighthouse Server

This guide walks developers through installing a Baota panel, configuring Nginx, creating a dedicated git user with bare repositories and post‑receive hooks, initializing and generating a Hexo blog locally, pushing it via the hexo‑deployer‑git, setting up an image host and Nginx reverse proxy, and backing up the project for quick deployment on a lightweight Lighthouse server.

Tencent Cloud Developer
Tencent Cloud Developer
Tencent Cloud Developer
Quick Guide to Deploying a Hexo Blog on a Lighthouse Server

Many developers choose existing blog systems such as WordPress, Hexo, or Halo when building their own blogs. Hexo, as a fully static blog generator, has no database, consumes minimal server resources, and is highly customizable. This article walks developers through quickly setting up a Hexo blog on a lightweight Lighthouse server.

Hexo is a Node.js‑based static blog system. With Hexo, configuration files and Markdown posts are compiled into static HTML, JavaScript, and CSS files. Each article generates a real .html file and DOM element, unlike Vue’s hash or history routing.

Example Hexo project structure:

├── _config.fluid.yml       # theme configuration file
├── _config.yml            # Hexo configuration file
├── node_modules
├── package-lock.json
├── package.json
├── scaffolds
├── source                 # user source files
└── themes                 # theme files

Running hexo generate creates a public folder that contains the static files ready for deployment.

Required tools

Local machine: a computer with Node.js and Git installed (Windows, macOS, or Linux).

Server: a Lighthouse server (Linux recommended, e.g., Debian or CentOS).

Optional: CDN nodes and a domain name.

If Git is not installed locally, Windows users can download it from https://git-scm.com/download/win . For Node.js, using NVM is recommended; see the tutorial at https://cloud.tencent.com/developer/article/1812323 .

Server initialization

After SSH‑ing into the server, install the Baota (BT) panel, open port 8888, and install Nginx through the panel.

Git setup on the server

Create a dedicated git user:

# as root
useradd git
passwd git

Create the user’s home directory and set permissions:

mkdir /home/git
chown git:git /home/git -R

Switch to the git user:

su - git

Create bare repositories for the blog and image host:

# Blog repository
mkdir -p ~/mySource/myBlog
cd ~/mySource/myBlog
git init --bare

# Image host repository
mkdir -p ~/mySource/myImageHost
cd ~/mySource/myImageHost
git init --bare

Configure post-receive hooks to checkout the repository into the web root. Example for the blog:

git --work-tree=/www/wwwroot/myHexo/blog \
    --git-dir=/home/git/mySource/myBlog checkout -f

Make the hook executable:

chmod +x ~/mySource/myBlog/hooks/post-receive

Repeat the same steps for the image host, adjusting the paths accordingly.

Deploying Hexo

1. Initialize Hexo locally – ensure Node.js is installed, then run:

npm install -g hexo

Create a new Hexo project:

hexo init my-blog
cd my-blog

2. Run Hexo – start the local server for preview:

hexo s

3. Package and push – install the Git deployer, configure _config.yml , then generate and deploy:

npm install hexo-deployer-git --save
hexo g -d   # generate and push

After deployment, the static site is accessible via the server’s domain.

Deploying the image host

Create a local Git repository for images, add files, and push to the remote bare repository:

# Initialize local repo
mkdir imageHost
cd imageHost
git init
# Add remote (replace IP with your server)
git remote add origin git@
:/home/git/mySource/myImageHost
# Add files and push
git add .
git commit -m "update"
git push --set-upstream origin main

If you encounter remote: fatal: You are on a branch yet to be born , add git checkout -f to the server’s post-receive hook.

Nginx reverse proxy for the image host

To serve images under /imagehost on the same domain, add a location block in the Nginx configuration:

location /imagehost/ {
    proxy_pass http://127.0.0.1:8080/myHexo/imageHost/;
}

This allows blog posts to reference images with URLs like https://yourdomain.com/imagehost/0.jpg .

Backup and FAQ

Backup the Hexo project (excluding node_modules and public ) and the image host folder. Restoring on a new machine involves extracting the archive and running hexo g -d again.

Q&A: Hexo runs smoothly on the lowest‑spec Lighthouse instance, but for heavier CMS like WordPress, a higher‑spec (e.g., 2C 4G) is recommended.

DeploymentNode.jsGitNginxHexoLighthouse ServerStatic Blog
Tencent Cloud Developer
Written by

Tencent Cloud Developer

Official Tencent Cloud community account that brings together developers, shares practical tech insights, and fosters an influential tech exchange community.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.