deploy hexo by nginx on centos
Era note (2026): This guide targets CentOS 7, which reached EOL on 2024-06-30. On CentOS 8/9 use the same flow but replace yum with dnf, and pick the nginx.org repo matching your major version. Consider a maintained distro such as Rocky / AlmaLinux 9 instead.
- create some dirs and enter pkgs dir
1
| mkdir /home/packages && cd /home/packages
|
1
2
| wget https://nodejs.org/dist/v24.19.0/node-v24.19.0-linux-x64.tar.xz
tar -xvf node-v24.19.0-linux-x64.tar.xz -C /usr/share/
|
CentOS 7 caveat: Node ≥ 18 prebuilt binaries require glibc ≥ 2.28, while CentOS 7 ships glibc 2.17 — so on CentOS 7 only older Node (e.g. 16) runs natively.
The era note above already redirects new installs to maintained distros (e.g. Rocky / AlmaLinux 9), where this v24 build works.
Note: Node v11 (pinned in the original 2019 guide) is long EOL with known CVEs. As of Aug 2026 the Active LTS is v24 “Krypton”; on modern distros you may prefer the NodeSource repo or your distro’s nodejs package.
1
2
3
| mv /usr/share/node-v24.19.0-linux-x64 /usr/share/nodejs
ln -s /usr/share/nodejs/bin/node /usr/local/bin/
ln -s /usr/share/nodejs/bin/npm /usr/local/bin/
|
1
2
| npm install -g hexo-cli
ln -s /usr/share/nodejs/bin/hexo /usr/local/bin/
|
install nginx
1
| vi /etc/yum.repos.d/my.repo
|
1
2
3
4
5
6
7
8
9
10
11
12
13
| [nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
|
- install nginx and start it
1
2
| yum install -y nginx
systemctl start nginx && systemctl enable nginx
|
1
| mkdir /home/website && cd /home/website && hexo init && hexo g
|
1
| vi /etc/nginx/conf.d/default.conf
|
1
2
3
4
| location / {
root /home/website/public;
index index.html index.htm;
}
|
1
| systemctl restart nginx
|
Now, you can access your blog by your IP address.