As an experienced website operator proficient in AnQiCMS, I am well aware of the importance of efficiently and flexibly managing multiple websites under the increasing business demands.This sometimes means that we need to deploy multiple independent CMS instances on a single server to meet the needs of different projects or to satisfy higher isolation requirements.AnQiCMS as an enterprise-level content management system based on the Go language, with its lightweight and efficient features, is 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.The built-in multi-site management refers to a single AnQiCMS application managing multiple logical sites, while deploying multiple CMS instances means running multiple independent AnQiCMS application processes on the same server.
Understanding the concept of multiple instances and multiple sites in AnQiCMS
Before deep deployment, we need to clarify the two 'multi-site' capabilities provided by AnQiCMS.
Firstly, AnQiCMSThe built-in multi-site management function.This is one of the core advantages of AnQiCMS, allowing you to manage websites under multiple domain names through a single AnQiCMS application instance, with backend configuration and an independent database.The advantage of this model is that you only need to maintain a set of AnQiCMS program codes, and updates and management are 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 (used for storing each site's cache, uploaded files, etc.) and database for each site.The reverse proxy will direct requests from different domain names to the same port that the AnQiCMS process is listening on.
Secondly, and this is what this article will focus on,Deploy multiple independent AnQiCMS instances.This means you will run multiple AnQiCMS application processes on the same server.Each process is a complete, independent CMS with its own program file, configuration file, database, and listening port.This approach provides higher isolation and independence, suitable for projects that are completely unrelated or require different AnQiCMS versions and independent configurations.
Preparation for deploying multiple independent AnQiCMS instances
Deploying multiple AnQiCMS instances on your server requires ensuring that some basic conditions are met.You will need a Linux server (or a Windows/macOS environment for testing), and ensure you have enough system resources such as CPU, memory, and storage space to support the operation of multiple CMS instances.Suggest using Baota Panel, 1Panel, or other similar server management tools to simplify operations, or directly deploy 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 a separate database and user 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 the entire AnQiCMS directory to another location, such as/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 defaults to listening on port 8001.However, each independent AnQiCMS instance must run on a unique port on the same server to avoid port conflicts.config.jsonfile. In it, you need toportThe field value is modified to a different port number. 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 directory under each instanceanqicmsExecutable file. For example, to/www/wwwroot/anqicms_site1/anqicmsRename toanqicms_site1_app,/www/wwwroot/anqicms_site2/anqicmsRename toanqicms_site2_app. This will help you clearly identify each AnQiCMS instance when viewing system processes.
Create independent start and stop scripts
Each independent AnQiCMS instance needs its own startup (start.sh) and shutdown (stop.shScripts, these scripts should point to the program directories and renamed executable files of their respective instances.These scripts will be responsible for checking the running status of the corresponding instance and will start or stop it as necessary.The script content should be adjusted according to the actual directory path and executable file name.
For example, foranqicms_site2_appthestart.shin the fileBINPATHinstance, it should point to/www/wwwroot/anqicms_site2,BINNAMEandgrepThe name in the command should also be changedanqicms_site2_app.
Configure system process guardian
To ensure that each AnQiCMS instance can automatically start after the server restarts and recover automatically when exceptions occur, you need to configure a process guardian for each instance.
If you are using Baota panel, you can add a Go project for each instance by using the 'Website' -> 'Go Project' (or 'Other Projects') feature. When configuring, point the project execution file to the executable file of the corresponding instance (for example/www/wwwroot/anqicms_site2/anqicms_site2_app),Project port should be filled with the port of this instance.config.jsonIn the configuration, the unique port (e.g.) is used.8002),The execution command is the path to the executable file, and check the 'Boot up on startup'.
If deployed via the command line, you can set up a crontab task for each instance to check and start the corresponding AnQiCMS process every minute, ensuring its continuous operation.
# 编辑crontab任务
crontab -e
# 为每个AnQiCMS实例添加一行类似下面的任务,请根据实际路径和名称修改
# 假设 anqicms_site2 的程序目录是 /www/wwwroot/anqicms_site2,可执行文件是 anqicms_site2_app
*/1 * * * * /www/wwwroot/anqicms_site2/start.sh
Configure the 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 its requests tohttp://127.0.0.1:8002.
`nginx server {