Deploy Hexo to Alibaba Cloud with Git Hooks, Nginx and HTTPS
This deployment has two parts: pushing Hexo’s generated static files to the server, and configuring a web server to serve that directory.
Upload generated files with Git
Create a dedicated Git user
| |
Configure SSH access for that account. Add your public key to ~git/.ssh/authorized_keys, then apply restrictive permissions:
Test from your local terminal:
| |
Create the bare repository and web directory
Create /www/git/blog.git/hooks/post-receive:
Make the hook executable:
| |
The dedicated account needs write access only to the repository and deployment directory. Avoid granting it unrestricted sudo access.
Configure Hexo
In the root _config.yml:
Deploy with:
| |
Serve the website
Install and configure Nginx, then create a virtual host whose document root is /www/wwwroot/hexo. Point the domain’s DNS records to the server and obtain a valid TLS certificate so the site can be served over HTTPS.
The original setup used the BaoTa control panel to add the site and choose the same document root:

Common problems
- The domain does not open: verify the Nginx document root, DNS records, firewall/security-group rules, and TLS configuration.
- Files do not deploy: verify ownership and write permissions for the bare repository and deployment directory, then inspect the Git hook output.
- SSH fails: confirm the public key,
authorized_keyspermissions, account shell, and server SSH logs.