- Preliminary steps
- Environment Setup
-
Creating Container Groups
- Create a folder anywhere on the system
- establish
- Starting the Halo Service
- Configure reverse proxy and domain name resolution
- Halo initialization page.
- Update new version of halo
Preliminary steps
First you need a set of linux servers, which you already have by default here. If you don't have one you can find it in theCloud Server Deals CollectionChoose, if you are a personal blogger choose the most cost-effective, the minimum configuration is enough.
Environment Setup
Install Docker and Docker Compose according to the official Docker documentation. The version of Docker in the repositories of some Linux distributions may be too old.
- Docker installation documentation:/engine/install/
- Docker Compose installation documentation:/compose/install/
Creating Container Groups
Below is the official Docker image repository maintained by Halo, choose the right image source according to your needs:
- registry./halo/halo
- halohub/halo
- /halo-dev/halo
Halo 2 sometimes does not update Docker's latest tag image in a timely manner because Halo 2 is not compatible with the version to prevent user error. It is recommended to use a fixed version of the label, such as 2.17 or 2.17.0.
Create a folder anywhere on the system
This document uses ~/halo as an example. All data generated by Halo in subsequent operations will be stored in this directory.
mkdir ~/halo && cd ~/halo
establish
halo 2 uses H2 database by default, this is mainly used to facilitate the development and testing, not recommended for production use. It is not recommended for production use because improper operation may result in data file corruption. If you have to use it for some reasons (e.g. not enough memory to run a standalone database), it is recommended to back up your data on time.
The file path is usually placed in the following path.
~/halo/
Several example configurations are given below.
- Create an instance of Halo + PostgreSQL:
PostgreSQL here uses the default port 5432, if you need to change the port, mark it explicitly.
version: "3"
services:
halo:
image: registry./halo/halo:2.17
restart: on-failure:3
depends_on:
halodb:
condition: service_healthy
networks:
halo_network:
volumes:
- ./halo2:/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.=r2dbc:pool:postgresql://halodb/halo
- --spring.=halo
# PostgreSQL passwords,Please make sure to contact the following POSTGRES_PASSWORD The values of the variables are consistent with the values of the。
- --spring.=openpostgresql
- --=postgresql
# external access address,Please modify as necessary
- ---url=http://localhost:8090/
halodb:
image: postgres:15.4
restart: on-failure:3
networks:
halo_network:
volumes:
- ./db:/var/lib/postgresql/data
healthcheck:
test: [ "CMD", "pg_isready" ]
interval: 10s
timeout: 5s
retries: 5
environment:
- POSTGRES_PASSWORD=openpostgresql
- POSTGRES_USER=halo
- POSTGRES_DB=halo
- PGUSER=halo
networks:
halo_network:
- Create an instance of Halo + MySQL:
PostgreSQL here uses the default port 3306, if you need to change the port, mark it explicitly.
version: "3"
services:
halo:
image: registry./halo/halo:2.17
restart: on-failure:3
depends_on:
halodb:
condition: service_healthy
networks:
halo_network:
volumes:
- ./halo2:/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.=r2dbc:pool:mysql://halodb:3306/halo
- --spring.=root
# MySQL passwords,Please make sure to contact the following MYSQL_ROOT_PASSWORD The values of the variables are consistent with the values of the。
- --spring.=o#DwN&JSa56
- --=mysql
# external access address,Please modify as necessary
- ---url=http://localhost:8090/
halodb:
image: mysql:8.1.0
restart: on-failure:3
networks:
halo_network:
command:
- --default-authentication-plugin=caching_sha2_password
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_general_ci
- --explicit_defaults_for_timestamp=true
volumes:
- ./mysql:/var/lib/mysql
- ./mysqlBackup:/data/mysqlBackup
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent"]
interval: 3s
retries: 5
start_period: 30s
environment:
# Please change this password,and corresponds to the modification of the upper Halo serviced SPRING_R2DBC_PASSWORD variable value
- MYSQL_ROOT_PASSWORD=o#DwN&JSa56
- MYSQL_DATABASE=halo
networks:
halo_network:
- Use the default H2 database
version: "3"
services:
halo:
image: registry./halo/halo:2.17
restart: on-failure:3
volumes:
- ./halo2:/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:
# external access address,Please modify as necessary
- ---url=http://localhost:8090/
- Create Halo instances only (using an existing external database, MySQL for example)
version: "3"
services.
halo: "3" services.
image: registry./halo/halo:2.17
restart: on-failure:3
network_mode: "host"
volumes.
- . /halo2:/root/.halo2
command.
# Change to your existing MySQL configuration
--spring.=r2dbc:pool:mysql://localhost:3306/halo
--spring.=root
--spring.=root
--=mysql
# External access address, please modify as needed
---url=http://localhost:8090/
# Port number default 8090
--=8090
Parameter Configuration
parameter name | descriptive |
---|---|
spring. |
The address of the database connection can be found in the Database Configuration section below. |
spring. |
Database User Name |
spring. |
Database Password |
|
Database platform name, support postgresql, mysql, h2 |
-url |
External access link, if you need to access it on the public network, you need to configure it as the actual access address |
Database Configuration
link method | Link address format |
|
---|---|---|
PostgreSQL | r2dbc:pool:postgresql://{HOST}:{PORT}/{DATABASE} |
postgresql |
MySQL | r2dbc:pool:mysql://{HOST}:{PORT}/{DATABASE} |
mysql |
MariaDB | r2dbc:pool:mariadb://{HOST}:{PORT}/{DATABASE} |
mariadb |
H2 Database | r2dbc:h2:file:///${-dir}/db/halo-next?MODE=MySQL&DB_CLOSE_ON_EXIT=FALSE |
h2 |
Starting the Halo Service
priming command
docker-compose up -d
Real-time log view command
docker-compose logs -f
Configure reverse proxy and domain name resolution
Nginx is used here as an example. halo2 also supports Caddy 2, Traefik and others.
- Adoption of the text configuration
upstream halo {
server 127.0.0.1:8090;
}
server {
listen 80;
listen [::]:80;
server_name ;
client_max_body_size 1024m;
location / {
proxy_pass http://halo;
proxy_set_header HOST $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
- Configuration via Nginx Proxy Manager
consultationConfiguring Halo's Reverse Proxy and Requesting SSL Certificates with Nginx Proxy Manager
Halo initialization page.
The Halo administration page can be accessed by visiting /console with your browser, and the first time you start it, you will be taken to the initialization page.
Update new version of halo
Starting with Halo 2.8, Halo has a built-in backup and restore feature that allows you to backup and restore complete data with one click in the Console.
- backing up
In the Console, click Backup in the left menu to enter the Backup page. Click the Create Backup button in the upper right corner to create a new backup request. Note that creating a backup request will not start the backup immediately, but it will be executed asynchronously in the background, so you need to wait for a while before you can see the results of the backup. - Updating Halo services
Modify the version of the image configured in the
services:
halo:
image: registry./halo/halo:2.17
docker-compose up -d
- Restore Backup
- In the Console, click Backup on the left menu to enter the Backup page, then click the Recovery tab to enter the Recovery interface, and click the Start Recovery button to display the Backup file upload interface after reading the notes.
- After selecting the backup file, click the Upload button to start uploading the backup file, and the recovery will start automatically after the upload is completed.
- When recovery is complete, you will be prompted to restart Halo, click the OK button to restart Halo.
- Finally, it is recommended to go to the server and check the operational status of Halo, if it is not set to restart automatically, it needs to be restarted manually.
Link to original article:How to deploy and install Halo via Docker Compose on a Linux cloud server to build a personal blog site?