As an experienced AnQiCMS website operator, I am well aware of the importance of efficiently and flexibly managing multiple websites under the growing business needs.This means that we may need to deploy multiple independent CMS instances on a single server to meet different project requirements or for higher isolation requirements.AnQiCMS is an enterprise-level content management system based on Go language, its lightweight and efficient features make it very suitable for such deployment scenarios.
This article will discuss in detail how to deploy multiple CMS instances on a single AnQiCMS server, which is different from the built-in multi-site management feature of AnQiCMS.Built-in multi-site management refers to an AnQiCMS application managing multiple logical sites, while deploying multiple CMS instances means running multiple independent AnQiCMS application processes on the same server.
Understanding the multi-instance and multi-site concepts of AnQiCMS
Before deep deployment, we need to clarify the two "multi-site" capabilities provided by AnQiCMS.
Firstly, AnQiCMSBuilt-in multi-site management function. This is one of the core advantages of AnQiCMS, allowing you to manage multiple websites under multiple domain names within a single AnQiCMS application instance through backend configuration and an independent database.The advantage of this model is that you only need to maintain a set of AnQiCMS program code, with updates and management relatively centralized, suitable for those who want centralized management but content isolation.In this mode, you just need to add a new site in the "Multi-site Management" of AnQiCMS, and specify an independent root directory for each site (used to store their respective caches, uploaded files, etc.) and database.The reverse proxy will direct requests from different domain names to the same port that the AnQiCMS process is listening on.
What comes next is also the focus of this article, that isDeploy multiple independent AnQiCMS instancesThis means you will run multiple AnQiCMS application processes on the same server.Each process is a complete, independent CMS, with its own program files, configuration files, database, and listening ports.This method provides higher isolation and independence, suitable for completely unrelated projects, or projects that require different AnQiCMS versions and independent configurations.
Preparation for deploying multiple independent AnQiCMS instances
Deploy multiple AnQiCMS instances on your server requires that you meet some basic conditions.You will need a Linux server (or a Windows/macOS environment for testing), and ensure that you have enough system resources such as CPU, memory, and storage space to support the operation of multiple CMS instances.It is recommended to use Baota Panel, 1Panel, or other similar server management tools to simplify operations, or deploy directly through the command line.
Each AnQiCMS instance requires an independent MySQL database.Before starting the deployment, please ensure that your MySQL service is installed and running, and prepare to create separate databases and users for each CMS instance.
Deploy multiple AnQiCMS independent instances step by step
We will take the Linux server environment as an example to introduce how to deploy multiple independent AnQiCMS instances.
Prepare an independent file directory for each instance
You need to prepare a set of independent program files for each AnQiCMS instance. First, unzip the downloaded AnQiCMS installation package to a directory on the server, for example/www/wwwroot/anqicms_site1Then, copy this complete AnQiCMS directory to another location, for example/www/wwwroot/anqicms_site2As the program directory of the second CMS instance. Similarly, create a dedicated program file directory for each independent CMS instance.
Configure a unique listening port for each instance.
AnQiCMS listens to port 8001 by default. However, each independent AnQiCMS instance on the same server must use a unique port to run to avoid port conflicts.Enter the root directory of each AnQiCMS instance, find and editconfig.jsonfile. In it, you need toportThe value of the field should be changed to different port numbers. For example, the first instance uses 8001, the second instance uses 8002, the third instance uses 8003, and so on.
Rename AnQiCMS executable file (optional but recommended)
To facilitate management and distinguish between processes of different instances, you can choose to rename the directories under each instance.anqicmsto an executable file. For example, set/www/wwwroot/anqicms_site1/anqicmsRenamed toanqicms_site1_app, will/www/wwwroot/anqicms_site2/anqicmsRenamed toanqicms_site2_appThis will help you clearly identify each AnQiCMS instance when viewing system processes.
Create independent start and stop scripts.
Each independent AnQiCMS instance requires its own start (start.sh) and stop (stop.sh) Script, these scripts should point to the program directories of each instance and the renamed executable files.These scripts will be responsible for checking the running status of the corresponding instance and starting or stopping it if necessary.The script content should be adjusted according to the actual directory path and executable file name.
For example, foranqicms_site2_appinstance, itsstart.shin the fileBINPATHshould point to/www/wwwroot/anqicms_site2,BINNAMEandgrepthe name in the command should also be changed toanqicms_site2_app.
Configure system process guardian
To ensure that each AnQiCMS instance can automatically start after the server restarts and recover automatically in case of exceptions, you need to configure process guardians for each instance.
If you are using Baota panel, you can add a Go project for each instance by going to “Website” -> “Go Project” (or “Other Project”) feature. When configuring, the project executable file points to the executable file of the corresponding instance (such as/www/wwwroot/anqicms_site2/anqicms_site2_app),the project port should be filled in with the instance inconfig.jsonthe unique port configured in (for example8002),the execution command is also the path of the executable file, and check the “Boot at startup” option.
If deployed via command line, you can set up a crontab task for each instance to check and start the corresponding AnQiCMS process every minute to ensure it runs continuously.
# 编辑crontab任务
crontab -e
# 为每个AnQiCMS实例添加一行类似下面的任务,请根据实际路径和名称修改
# 假设 anqicms_site2 的程序目录是 /www/wwwroot/anqicms_site2,可执行文件是 anqicms_site2_app
*/1 * * * * /www/wwwroot/anqicms_site2/start.sh
Configure Web Server Reverse Proxy
Each AnQiCMS instance needs to provide services through a domain.You need to configure a reverse proxy for each domain on your web server (such as Nginx or Apache), forwarding external requests to the unique port that the corresponding AnQiCMS instance is listening on.
For example, forsite2.comThis domain, you can configure Nginx reverse proxy to forward requests tohttp://127.0.0.1:8002.
`nginx server {