test
以下是完整的配置步骤和文件代码:
# 1. 安装必要组件
apt update
apt install mariadb-server php-fpm php-mysql openjdk-11-jdk git unzip -y
# 2. 配置MySQL(使用默认root账户)
mysql_secure_installation <<EOF
y
123456
123456
y
y
y
y
EOF
# 3. 创建Halo专用目录
mkdir /halo && cd /halo
wget https://dl.halo.run/release/halo-1.6.1.jar -O halo.jar
# 4. 创建Halo配置文件
cat > /halo/application.yaml <<EOF
server:
port: 8090
spring:
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:file:~/.halo/db/halo
username: admin
password: 123456
halo:
admin-path: admin
cache: memory
EOF
# 5. 创建Systemd服务
cat > /etc/systemd/system/halo.service <<EOF
[Unit]
Description=Halo Service
After=network.target
[Service]
User=root
WorkingDirectory=/halo
ExecStart=/usr/bin/java -jar /halo/halo.jar
Restart=always
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable halo
systemctl start halo
# 6. 生成SSL证书
mkdir -p /etc/nginx/ssl
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /etc/nginx/ssl/self.key \
-out /etc/nginx/ssl/self.crt \
-subj "/C=CN/ST=Beijing/L=Beijing/O=IT/CN=192.168.117.200"
# 7. 配置Nginx
cat > /usr/local/nginx/conf/nginx.conf <<EOF
worker_processes auto;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name 192.168.117.200;
return 301 https://\$host\$request_uri;
}
server {
listen 443 ssl;
server_name 192.168.117.200;
ssl_certificate /etc/nginx/ssl/self.crt;
ssl_certificate_key /etc/nginx/ssl/self.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
location / {
proxy_pass http://127.0.0.1:8090;
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_buffer_size 64k;
proxy_buffers 32 64k;
proxy_busy_buffers_size 128k;
}
access_log off;
error_log /var/log/nginx/halo_error.log;
}
}
EOF
# 8. 下载主题
mkdir -p /root/.halo/templates/themes
git clone https://github.com/nineya/halo-theme-dream2.0 /tmp/dream-theme
cd /tmp/dream-theme && zip -r dream2.0.zip ./*
mv dream2.0.zip /root/.halo/templates/themes/
# 9. 重启服务
systemctl restart nginx
systemctl restart halo
完成以上步骤后:
- 访问
https://192.168.117.200
(需手动信任自签名证书) - 完成Halo的初始化设置(用户名/密码:admin/123456)
- 进入后台 -> 外观 -> 主题 -> 找到"dream2.0"并启用
注意事项:
- 自签名证书会在浏览器显示不安全警告,正式环境建议申请免费SSL证书
- MySQL安装后root密码设置为"123456",可根据需要修改
- Halo数据默认存储在
/root/.halo
目录 - 如需使用MySQL数据库,需修改
/halo/application.yaml
中的数据库配置 - 主题文件存放路径为
/root/.halo/templates/themes/dream2.0.zip
验证服务状态:
systemctl status nginx
systemctl status halo
curl -k https://localhost
```****
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)