上文:基于 Hexo 的 Github 博客搭建
注意:通过验证部署,确定无误。AI生成的部分有🤖图标。
🤖 TLDR By ChatGPT
本指南提供了在服务器上设置Git仓库、将本地Hexo页面推送到服务器仓库、在服务器上创建Nginx配置文件以及在服务器上运行Nginx容器的方法。
- 在服务器上的指定路径下运行git init初始化Git仓库。
- 参考Easy Hexo指南,使用提供的配置将本地Hexo页面推送到服务器仓库。
- 提供的配置在服务器上创建Nginx配置文件,包括MIME类型、日志、SSL和HTTP和HTTPS的服务器块。
- 使用官方Docker镜像在服务器上运行Nginx容器。使用docker pull nginx拉取镜像,然后使用提供的命令运行容器。
请确保用适当的值替换所有<todo: comment>占位符。
There are several <todo: comment>
need to be replaced.
✨Initialise git repository on server
cd <todo: the path for repository>git init
✨Push local hexo pages to server repository
Reference: 部署 Hexo | Easy Hexo 👨💻
# Deployment
## ✨Docs: https://hexo.io/docs/one-command-deployment
deploy:- type: gitrepo: <todo: server user name>@<todo: server address>:<todo: server git repo absolute path>branch: <todo: the branch will push>
✨Create nginx config file on server
user nginx;
worker_processes auto;error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;events {worker_connections 1024;
}http {# Set MIME typesinclude /etc/nginx/mime.types;default_type application/octet-stream;# Set up logginglog_format main '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';access_log /var/log/nginx/access.log main;# SSL configurationssl_certificate /etc/nginx/ssl.pem;ssl_certificate_key /etc/nginx/ssl.key;ssl_protocols TLSv1.2 TLSv1.3;ssl_prefer_server_ciphers on;ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";# HTTP server block to redirect to HTTPSserver {listen 80;server_name <todo: server name>;return 301 https://$host$request_uri;}# HTTPS server block for the siteserver {listen 443 ssl http2;server_name <todo: server name>;root /usr/share/nginx/html;index index.html;# Set up SSLssl_session_timeout 1d;ssl_session_cache shared:SSL:10m;ssl_session_tickets off;ssl_stapling on;ssl_stapling_verify on;resolver 1.1.1.1 1.0.0.1 8.8.8.8 valid=300s;resolver_timeout 5s;# Set up access logsaccess_log /var/log/nginx/access.log main;# Set up location for static fileslocation / {try_files $uri $uri/ =404;}}
}
✨Run nginx container on server
Reference: nginx - Official Image | Docker Hub
# pull nginx docker image
docker pull nginx
docker run \--name <todo: container name> \-v <todo: html path>:/usr/share/nginx/html:ro \-v <todo: nginx.conf path>:/etc/nginx/nginx.conf:ro \-v <todo: ssl key path>:/etc/nginx/ssl.key:ro \-v <todo: ssl pem path>:/etc/nginx/ssl.pem:ro \-p 80:80 \-p 443:443 \-d nginx
END.
Author: YangSier (discover304.top)
🍀碎碎念🍀
Hello米娜桑,这里是英国留学中的杨丝儿。我的博客的关键词集中在编程、算法、机器人、人工智能、数学等等,持续高质量输出中。
🌸唠嗑QQ群:兔叽の魔术工房 (942848525)
⭐B站账号:杨丝儿Online(活跃于知识区和动画区)
Cover image credit to 🤖AI generator.