腾讯云轻量应用服务器部署halo
准备
mkdir -p /export/server
mkdir -p /export/software
安装mysql
rpm -qa|grep mariadb
rpm -e mariadb-connector-c-3.1.11-2.oc8.1.x86_64 --nodeps
rpm -e mariadb-connector-c-config-3.1.11-2.oc8.1.noarch --nodeps
安装MySQL8.0
使用最新的包管理器安装MySQL
sudo dnf install @mysql
安装完成后,运行以下命令来启动MySQL服务并使它在启动时自动启动:
sudo systemctl enable --now mysqld
要检查MySQL服务器是否正在运行,请输入:
sudo systemctl status mysqld
添加密码及安全设置
运行mysql_secure_installation脚本,该脚本执行一些与安全性相关的操作并设置MySQL根密码:
sudo mysql_secure_installation
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
Please set the password for root here.
New password:
Re-enter new password:
Estimated strength of the password: 50
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n
... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
配置远程登陆
如果需要设置root账户远程登陆,上一步骤中,不允许root远程登陆?这一步需要设为n。
接下来本机登录MySQL,将root用户的host字段设为'%',意为接受root所有IP地址的登录请求:
本机登录MySQL:
mysql -uroot -p<上面步骤中设置的密码>
回车后即可登录,接下来终端变成了mysql>开头:
接着继续执行mysql语句,将将root用户的host字段设为'%':
use mysql;
update user set host='%' where user='root';
flush privileges;
创建我们接下来要用的库
create database umami;
create database halo;
设置完成后输入exit退出mysql,回到终端shell界面,接着开启系统防火墙的3306端口:
sudo firewall-cmd --add-port=3306/tcp --permanent
sudo firewall-cmd --reload
安装docker
要在 CentOS 8 上安装 Docker,可以按照以下步骤进行操作:
步骤 1:卸载旧版本(如果有)
首先,如果你的系统上已经安装了旧版本的 Docker,可以先卸载它们:
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
步骤 2:安装依赖
安装 Docker 所需的依赖包:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
步骤 3:添加 Docker 存储库
Docker 提供了一个官方的存储库,可以使用以下命令添加它:
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
步骤 4:安装 Docker CE
现在,你可以安装 Docker Community Edition(CE):
sudo yum install docker-ce
步骤 5:启动 Docker 服务
安装完成后,启动 Docker 服务并设置为开机自启动:
sudo systemctl start docker
sudo systemctl enable docker
步骤 6:验证安装
最后,运行以下命令验证 Docker 是否已成功安装:
sudo docker --version
如果看到 Docker 版本信息,说明 Docker 已成功安装在你的 CentOS 8 系统上。 现在,Docker 就已经安装并运行在你的 CentOS 8 服务器上了。你可以开始使用 Docker 来管理容器。
安装 docker-compose
步骤 1:下载 Docker Compose
使用以下命令从 Docker 官方 GitHub 存储库下载 docker-compose:
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-(uname -s)-(uname -m)" -o /usr/local/bin/docker-compose
步骤 2:添加执行权限
运行以下命令添加执行权限:
sudo chmod +x /usr/local/bin/docker-compose
步骤 3:验证安装
运行以下命令验证 docker-compose 是否已成功安装:
docker-compose --version
如果看到 docker-compose 的版本信息,说明已成功安装。
安装halo
mkdir -p /export/server/halo && cd /export/server/halo
vim docker-compose.yaml
version: "3"
services:
halo:
image: halohub/halo:2.9
container_name: halo
restart: on-failure:3
networks:
halo_network:
volumes:
- ./:/root/.halo2
ports:
- "8090:8090"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8090/actuator/health/readiness"]
interval: 30s
timeout: 5s
retries: 5
start_period: 30s
command:
- --spring.datasource.url=jdbc:mysql://IP:3306/halo
- --spring.datasource.username=root
# MySQL 的密码,请保证与下方 MYSQL_ROOT_PASSWORD 的变量值一致。
- --spring.datasource.password=sdfsfsfsdf
- --spring.sql.init.platform=mysql
# 外部访问地址,请根据实际需要修改
- --halo.external-url=http://IP.8090/
networks:
halo_network:
安装 Nginx Proxy Manager
创建一个 npm 的文件夹 进入该文件夹
mkdir -p /export/server/nginxproxymanager && cd /export/server/nginxproxymanager
vi docker-compose.yml
version: '3'
services:
app:
image: 'jc21/nginx-proxy-manager:2.9.18'
restart: unless-stopped
ports:
- '80:80' # 不建议修改端口
- '81:81' # 可以把冒号左边的 81 端口修改成你服务器上没有被占用的端口
- '443:443' # 不建议修改端口
volumes:
- ./data:/data # 点号表示当前文件夹,冒号左边的意思是在当前文件夹下创建一个 data 目录,用于存放数据,如果不存在的话,会自动创建
- ./letsencrypt:/etc/letsencrypt # 点号表示当前文件夹,冒号左边的意思是在当前文件夹下创建一个 letsencrypt 目录,用于存放证书,如果不存在的话,会自动创建
docker-compose up -d # -d 表示后台运行
远程访问地址
IP:81
默认登陆的用户名:
admin@example.com
密码:changeme
安装umami
源码安装umami
我的2核2G的服务器无法同时安装halo和umami
安装nodejs
cd /export/software
wget https://nodejs.org/dist/v16.14.0/node-v16.14.0-linux-x64.tar.xz
tar -xvf node-v16.14.0-linux-x64.tar.xz -C /export/server
cd /export/server/node-v16.14.0-linux-x64
yum install npm npm install -g yarn
安装git
yum install git
安装umami
cd /export/server git clone https://github.com/umami-software/umami.git cd umami yarn install
vim .env
DATABASE_URL=mysql://username:mypassword@localhost:3306/mydb
docker安装umami
然后到 github 上接取项目,进入目录
cd ~
mkdir -p ~/data/docker_data/umami
cd ~/data/docker_data/umami
编辑配置文件
nano docker-compose.yml
写入 Docker-compose 代码
version: '3'
services:
umami:
image: docker.umami.dev/umami-software/umami:postgresql-latest
ports:
- "3000:3000"
environment:
DATABASE_URL: postgresql://umami:umami@db:5432/umami
DATABASE_TYPE: postgresql
APP_SECRET: replace-me-with-a-random-string
depends_on:
- db
restart: always
db:
image: postgres:15-alpine
environment:
POSTGRES_DB: umami
POSTGRES_USER: umami
POSTGRES_PASSWORD: umami
volumes:
- ./sql/schema.postgresql.sql:/docker-entrypoint-initdb.d/schema.postgresql.sql:ro
- ./umami-db-data:/var/lib/postgresql/data
restart: always
检查完毕之后,ctrl+x
退出,按 y
确认修改内容,enter
确认
启动 Umami
docker-compose up -d
访问web界面
访问 http://ip:3000
就可以访问了,打开的是英文界面,右上方可以切换语言,默认用户名为 admin
,密码为 umami
在halo2.0中使用
请问如何填写: 站点 ID 共享链接 这两个参数?
在 Umami 的网站管理可以获取到: