Source code compilation installation of AnQi CMS

Calendar 👁️ 0

Eligible Audience: Developers who need secondary development, customization features, or official binary packages that cannot meet their needs.

Difficulty: ⭐⭐⭐⭐ (requires familiarity with GoLang and command line operations)


Prerequisites

Software Version requirements Description
GoLang 1.13+ (recommended 1.25+) Compile Go source code
Git Any version Clone code repository
MySQL 5.6.35+ Run database

If GoLang has not been installed yet, please visithttps://go.dev/dl/Download and install.


Get the source code

# 从 GitHub 克隆(推荐)
git clone https://github.com/fesiong/anqicms.git

# 或从 GitCode 镜像(国内用户)
git clone https://gitcode.com/anqicms/anqicms.git

# 进入项目目录
cd anqicms

Compile preparation

Set up Go proxy (for domestic users)

go env -w GOPROXY=https://goproxy.cn,direct

Download dependencies

go mod tidy
go mod vendor

Compile executable file

Method 1: Test run (does not generate binary file)

# 直接运行源码,用于调试和测试
go run kandaoni.com/anqicms/main

After running, visit the browserhttp://127.0.0.1:8001to see the effect.

Method two: Generate binary file

Windows system:

go build -ldflags '-w -s -H=windowsgui' -o ./anqicms.exe kandaoni.com/anqicms/main
  • -w -s: Remove debug information, reduce file size
  • -H=windowsgui: Windows GUI mode, command line window is not displayed when running

MacOS system:

go build -ldflags '-w -s' -o ./anqicms kandaoni.com/anqicms/main

Linux system:

Recommended to use the Makefile自带 of the project:

make

After compilation, generate in the root directory of the projectrelease/Directory, which includes the complete running environment (executable files, template files, static resources, etc.):

release/
├── anqicms               # 编译好的可执行文件
├── config.sample.json    # 配置文件示例
├── template/             # 模板目录
├── public/               # Web 根目录
├── system/               # 后台管理界面
├── locales/              # 多语言包
├── data/                 # 数据目录
├── start.sh              # 启动脚本
├── stop.sh               # 停止脚本
└── doc/                  # 开发文档

You can also compile directly:

go build -ldflags '-w -s' -o ./anqicms kandaoni.com/anqicms/main

Cross compilation

Compile for the target platform on different platforms:

# 在 MacOS 上编译 Linux 版本
GOOS=linux GOARCH=amd64 go build -ldflags '-w -s' -o ./anqicms-linux kandaoni.com/anqicms/main

# 在 MacOS 上编译 Windows 版本
GOOS=windows GOARCH=amd64 go build -ldflags '-w -s -H=windowsgui' -o ./anqicms.exe kandaoni.com/anqicms/main

# 在 Linux 上编译 Windows 版本
GOOS=windows GOARCH=amd64 go build -ldflags '-w -s -H=windowsgui' -o ./anqicms.exe kandaoni.com/anqicms/main

GOOSandGOARCHIt is the environment variable for Go cross compilation, specifying the target operating system and CPU architecture.


Compile the backend management interface

Note: If the code is cloned from GitHub, the backend management interface (system/directory) is empty by default, and needs to be compiled or downloaded separately.

Method one: Download the pre-built package

Fromanqicms-admin ReleasesDownload the latest versionsystem.zipand unzip it into the root directory of the AnQiCMS project.systemFolder.

# 下载 system.zip
wget https://github.com/fesiong/anqicms-admin/releases/latest/download/system.zip

# 解压到 system 目录
unzip system.zip -d system/

Method two: compile manually

If you need to develop the background management interface twice, you can cloneanqicms-adminBuild the repository manually (Vue.js project):

git clone https://github.com/fesiong/anqicms-admin.git
cd anqicms-admin

# 安装依赖
npm install

# 构建
npm run build

# 构建产物在 dist/ 目录,将其复制到 anqicms 根目录下的 system/ 目录
cp -r dist/* /path/to/anqicms/system/

Run the compiled version

# 1. 将编译好的文件复制到目标目录
# 2. 编辑 config.json 配置端口等信息
# 3. 启动
./start.sh

# 或直接运行
./anqicms

# 首次运行会提示初始化,访问 http://127.0.0.1:8001 进入安装界面

Common Makefile commands

Under the project root directoryMakefileProvides convenient build commands:

# 查看所有可用命令
make help

# 编译(生成 release 目录)
make

# 清理编译产物
make clean

# 运行测试
make test

# 查看版本号
make version

❓ Executego run kandaoni.com/anqicms/mainand promptgo: not foundWhat should I do?

The Go language environment is not installed or the environment variables are not configured correctly.

# 检查 Go 是否安装
go version
# 如果输出 "command not found",说明没有安装

# 安装 Go(Ubuntu/Debian 示例)
apt install golang-go

# 或从官网下载最新版
# 访问 https://go.dev/dl/ 下载对应系统的安装包

# 安装后验证
go version
# 应输出类似:go version go1.25.5 linux/amd64

After installing Go, domestic users still need to set up a proxy:

go env -w GOPROXY=https://goproxy.cn,direct

❓ The compiled binary package is very large (hundreds of MB), can it be reduced?

The default compiled binary package includes debugging information and symbol tables, which are large in size. The following methods can significantly reduce the size:

Method command Effect
Remove debugging information go build -ldflags '-w -s' About 40% reduction
UPX compression upx anqicms About 70% reduction

Complete optimization command:

# 编译时去除调试信息
go build -ldflags '-w -s' -o ./anqicms kandaoni.com/anqicms/main

# 安装 UPX(Ubuntu)
apt install upx

# 压缩二进包
upx anqicms

# 压缩后体积可降至 15-20 MB

After v3.6.1, the official has already optimized the size (from 103 MB to 51 MB), which is also effective when compiling the source code.

❓ How can I confirm that the modifications to the source code have taken effect after compilation?

Several verification methods:

# 方式一:通过版本号验证(如果在代码中修改了版本号)
./anqicms --version

# 方式二:通过编译时间戳验证
ls -la ./anqicms
# 查看文件的修改时间,确认是刚刚编译的

# 方式三:直接验证功能
# 如果你的修改是增加了某个新标签或新接口
# 可以直接在浏览器中访问对应的 URL 确认

# 方式四:校验文件 MD5(前后对比)
md5sum ./anqicms
# 每次编译的 MD5 都不同

Remember: After each modification of the source code, it is necessary to recompile andrestart the AnQiCMS process, the modification will take effect. After restarting, you also need to update the cache in the background.

Related articles

Docker deployment of AnQi CMS

Docker deployment is the fastest installation method for AnQiCMS, suitable for quick experience and testing environments. Docker image address: https://hub.docker.com/r/anqicms/anqicms Method one: Docker command line deployment Suitable for environments where Docker is already installed (any operating system).Quick Start # Pull the latest image docker pull anqicms/anqicms:latest # Run the container docker run -d --name anqicms -p 8001:8001

2026-07-18

Manual deployment of AnQi CMS on the server

Use case: Linux servers without a panel (such as CentOS / Ubuntu), suitable for users familiar with command-line operations.Deployed by downloading the package, configuring Nginx reverse proxy, and MySQL database. Preparations A Linux server (CentOS 7+ or Ubuntu 20.04+) with Nginx and MySQL 5.6.35+ installed (recommended to use the LNMP one-click installation package) A domain name resolved to the server Downloaded AnQiCMS Linux installation package Installation steps Step 1: Download and unzip # Log in to the server ssh

2026-07-18

Installation of Anqi CMS - Deployment with PHPStudy (Xiao Pi panel)

The application scenario: Windows local development environment or Windows server. PHPStudy (Xiao Pi panel) integrates components such as Nginx, MySQL, PHP, and AnQiCMS runs through Nginx reverse proxy.Preparation has been completed PHPStudy (Xiaopi Panel) software running mode has been switched to Nginx + MySQL package A local test domain (such as dev.anqicms.com) or access using IP + port AnQiCMS Windows installation package has been downloaded Installation steps Step 1: Create a site Open PHPStudy

2026-07-18

Installation of Anqi CMS - Baota panel deployment

2.2 Tower Panel Deployment Applicable Version: Tower Panel 7.9.3+. Tower Panel Deployment is divided into two methods: traditional deployment (uploading installation packages, configuring reverse proxy) and Docker one-click deployment. This chapter will introduce the traditional deployment method first.Preparation A Linux server with Baota panel installed (CentOS / Ubuntu / Debian are all okay) A domain name resolved to the server (such as www.anqicms.com) MySQL 5.6.35+ installed (recommended 5.7+ or 8.0) Download AnQiCMS Linux package from the official website or GitHub Method one: Baota 7

2026-07-18

Download and install AnQi CMS

Introduce the various download channels of AnQi CMS installation package (official website, GitHub, mirror site), the method of version selection for different operating systems and architectures, and the file verification method of the installation package to ensure that the correct and complete version is downloaded.

2026-07-10

Deployment of multiple sites on the same server for AnQi CMS

The AnQiCMS supports running multiple independent sites on the same server, each with its own domain name, database, template, and administrator. This chapter details the complete steps and注意事项 for multi-site configuration.Plan one: Multi-site management (recommended) Eligibility: A main AnQiCMS site that is already installed and running. This plan uses the built-in multi-site management feature of AnQiCMS, where all sites share the same AnQiCMS program but run independently.Do not copy the code multiple times. Preparations Have deployed and run a AnQiCMS main site (port 8001) The main station background has Multi-site management Menu permissions (default installed sites have it)

2026-07-18

Installation guide and initialization of AnQi CMS

When you first start AnQiCMS, you need to complete the initial installation, including configuring database connection information, setting up the administrator account password, specifying the site name, and other key steps, which are essential before the system can be officially used.When do you need to initialize The following situations require initialization installation: Scenario Description First deployment Fresh installation AnQiCMS Restore factory settings Clear data and reinstall If installed through Baota Docker or aaPanel Docker, the system will automatically complete the initialization (default account admin / password 123456), no manual initialization process is required.Initialization step Step 1: Ensure AnQiCMS is started

2026-07-18

Installation of AnQi CMS - Troubleshooting common installation issues

Summarize common problems and solutions during the installation of Anqi CMS, covering typical scenarios such as port occupation, database connection failure, blank page, permission error, and missing dependencies, to help users quickly locate and solve problems.Question 1: Port occupied. Phenomenon: After starting AnQiCMS, the website cannot be accessed. Reason: The default port 8001 is occupied by another program.Troubleshooting method: # On Linux / MacOS: Check which process is occupying port 8001 lsof -i:8001 # Example output: # COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME #

2026-07-18