我的博客上线了!
经过我的漫漫学习路,终于在最近上线了我的个人博客IT-Dark。为了表达我的喜悦心情,下面我将会将我搭建网站的过程分享给大家,以便有同样想法地人们也能拥有自己地博客。
说明
- 该篇适合有一定编程基础的人,如果没有基础但还是想搭建自己的博客也没关系,你只需要跟着我的步骤来。
- 要想让别人能访问你的博客,你就必需要有公网IP,如果你的电脑有公网IP、,那么你可以将自己的电脑作为服务器(不建议)
- 为了减少搭建网站的成本,我使用的是阿文云,那里面的服务器虽然没大厂的稳定,但是价格便宜,性价比较高。
这个1核1G的服务器搭建博客绰绰有余,你还可以在这上面学习Linux指令
-
博客系统使用的是Halo,一款现代化的开源博客/CMS系统,值得一试。
-
官网里面介绍了不同操作系统的,但我接下来的是基于Docker的部署,非常简单。
开始
1. 安装Docker
我之前的文章已经介绍过了,不会的直接敲命令吧
cd /etc/yum.repos.d/
wget https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
sed -i 's#download.docer.com#mirrors.ustc.edu.cn/docker-ce#g' docker-ce.repo
yum -y install docker-ce
systemctl enable --now docker.service
systemctl status docker
当此刻出现 **Active: active (running) ** 表示启动安装并启动成功
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2022-08-13 08:14:47 CST; 2 days ago
Docs: https://docs.docker.com
Main PID: 5690 (dockerd)
Tasks: 24
Memory: 64.3M
CGroup: /system.slice/docker.service
├─ 5690 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
├─11409 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8090 -container-ip 172.17.0.2 -container-port 8090
└─11415 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8090 -container-ip 172.17.0.2 -container-port 8090
Aug 13 16:09:36 ser895585276680.local dockerd[5690]: time="2022-08-13T16:09:36.898657079+08:00" level=info msg="Firewalld: interface docker0 already part of docker zone, returning"
Aug 13 16:09:36 ser895585276680.local dockerd[5690]: time="2022-08-13T16:09:36.936841317+08:00" level=info msg="Firewalld: interface docker0 already part of docker zone, returning"
Aug 13 22:08:25 ser895585276680.local dockerd[5690]: time="2022-08-13T22:08:25.193003472+08:00" level=info msg="Firewalld: interface docker0 already part of docker zone, returning"
Aug 13 22:08:25 ser895585276680.local dockerd[5690]: time="2022-08-13T22:08:25.245015405+08:00" level=info msg="Firewalld: interface docker0 already part of docker zone, returning"
Aug 13 22:08:25 ser895585276680.local dockerd[5690]: time="2022-08-13T22:08:25.428516695+08:00" level=info msg="Firewalld: interface docker0 already part of docker zone, returning"
Aug 13 22:08:25 ser895585276680.local dockerd[5690]: time="2022-08-13T22:08:25.474961255+08:00" level=info msg="Firewalld: interface docker0 already part of docker zone, returning"
Aug 14 13:50:18 ser895585276680.local dockerd[5690]: time="2022-08-14T13:50:18.411791458+08:00" level=info msg="Firewalld: interface docker0 already part of docker zone, returning"
Aug 14 13:50:18 ser895585276680.local dockerd[5690]: time="2022-08-14T13:50:18.451901336+08:00" level=info msg="Firewalld: interface docker0 already part of docker zone, returning"
Aug 14 13:50:18 ser895585276680.local dockerd[5690]: time="2022-08-14T13:50:18.620305195+08:00" level=info msg="Firewalld: interface docker0 already part of docker zone, returning"
Aug 14 13:50:18 ser895585276680.local dockerd[5690]: time="2022-08-14T13:50:18.657203830+08:00" level=info msg="Firewalld: interface docker0 already part of docker zone, returning"
2. 下载镜像
$ docker pull halohub/halo:1.5.4 # 拉取镜像
$ docker images list # 查看镜像
[root@ser895585276680 ~]# docker image list
REPOSITORY TAG IMAGE ID CREATED SIZE
halohub/halo 1.5.4 a11c69bff36b 5 weeks ago 344MB
[root@ser895585276680 ~]#
3. 开启容器
创建文件夹
cd ~
mkdir .halo
cd .halo
编写配置文件
vi application.yaml
填写配置
!!!!记住要修改用户名和密码!!!!!
server:
port: 8090
# Response data gzip.
compression:
enabled: false
spring:
datasource:
# H2 database configuration.
driver-class-name: org.h2.Driver
url: jdbc:h2:file:~/.halo/db/halo
username: root
password: 123456
# MySQL database configuration.
# driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://127.0.0.1:3306/halodb?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
# username: root
# password: 123456
# H2 database console configuration.
h2:
console:
settings:
web-allow-others: false
path: /h2-console
enabled: false
halo:
# Your admin client path is https://your-domain/{admin-path}
admin-path: admin
# memory or level
cache: level
开启容器halo、并将主机的8090端口映射到容器中的8090端口
$ docker run -it -d --name halo -p 8090:8090 -v ~/.halo:/root/.halo halohub/halo:1.5.4
开放8090端口
# 查看开发放的端口
firewall-cmd --list-all
# 如果8090端口没有开放 --permanent 永久有效
firewall-cmd --add-port=8090/tcp --permanent
# 重启防火墙
firewall-cmd --reload
访问
使用ip:8090访问
# 例如
http://xxx.xxx.xxx.xxx:8090
# xxx.xxx.xxx.xxx 表示你的ip地址,如192.168.66.1等
进入后台
http://xxx.xxx.xxx.xxx:8090/admin
输入用户名和密码
可以配置主题
- 选择主题
选择喜欢的主题
启用
其他
- 我的博客地址:IT-Dark博客
http://blog.itdark.net
欢迎大家访问
- 关于域名、SSL配置,有机会再说