How to avoid port conflicts when installing multiple AnQiCMS instances on the same server (non-Docker)?

Calendar 👁️ 65

As an experienced CMS website operation person in the constantly evolving digital environment, I know that it is crucial to manage multiple websites flexibly and efficiently.The Aanqi CMS provides a solid foundation for us with its Go language's high concurrency features and multi-site management capabilities.However, when we want to deploy multiple independent AnQiCMS instances on the same server (instead of using the multi-site feature of a single instance), a core technical challenge is how to effectively avoid port conflicts.

This article will elaborate on how to install and run multiple AnQiCMS instances on the same server in a non-Docker environment, and ensure that they do not interfere with each other due to port occupation.

Understand the essence of port conflict and the operation mechanism of AnQiCMS

AnQi CMS is an independent application developed based on the Go language.When the AnQiCMS instance starts, it will listen on a specific network port and wait for HTTP requests from clients (such as browsers).By default, AnQiCMS usually uses port 8001.On the same server, no two applications can listen to the same port at the same time; otherwise, a port conflict will occur, causing one or both programs to fail to start normally.

Therefore, the most fundamental solution to run multiple AnQiCMS instances on the same server is to allocate a unique listening port for each instance.This means that each running AnQiCMS process will provide services on different ports.

Assign an independent port for each AnQiCMS instance

The listening port of each AnQiCMS instance is under its root directoryconfig.jsonand is configured in the file. This is a critical step to avoid port conflicts.

First, you need to make copies of the AnQiCMS program files, creating a separate application directory for each instance you plan to deploy. For example, if you are going to deploy two instances, you can createanqicms_site1andanqicms_site2Two directories, and copy the complete program files of AnQiCMS separately to these two directories.

Next, enter the directory of each instance, find and edit itsconfig.jsonfile. In this file, you will find a field namedport. You need to change each instance of theportto a different, unused port number. For example:

  • Foranqicms_site1,config.jsonofportcan be set to8001.
  • Foranqicms_site2,config.jsonofportcan be set to8002.
  • As such, each new instance should be assigned an incrementing port number (such as 8003, 8004, etc.), ensuring they are unique on the server.

In addition, each AnQiCMS instance also requires an independent database to store its data.During the initialization installation process, you need to configure different database names and connection information for each instance to ensure that the data does not interfere with each other.If you choose to reuse the database account, you must also specify a different database name for each instance.

Access entry through reverse proxy

Although each AnQiCMS instance runs on a different internal port, it is usually desired that users access these websites through standard HTTP (8000) or HTTPS (443) ports and their respective domain names, rather than entering them directlyyourdomain.com:8001This is the address. At this time, the reverse proxy server (such as Nginx or Apache) plays a crucial role.

The reverse proxy server acts as an intermediary between the client and the backend AnQiCMS instance.It listens to the standard 80/443 ports and forwards requests to the AnQiCMS instance on the corresponding backend port based on the domain name (Host header).

Configure reverse proxy using Nginx

Nginx is a high-performance web server and reverse proxy server, very suitable for handling multiple instance deployment.

Configure an independent Nginx for each AnQiCMS instanceserverblock. For example, for the one running on port 8001anqicms_site1.comand the one running on port 8002anqicms_site2.com:

Nginx configuration example (/etc/nginx/conf.d/anqicms_site1.confor a similar path):

server {
    listen 80;
    server_name anqicms_site1.com www.anqicms_site1.com; # 替换为您的域名

    # 根目录指向实例的 public 文件夹
    root /www/wwwroot/anqicms_site1/public; # 替换为您的实际路径

    location @AnqiCMS {
        proxy_pass https://en.anqicms.com; # 指向第一个实例的内部端口
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    error_page 404 =200 @AnqiCMS; # 确保404错误也能通过AnQiCMS处理

    location / {
       try_files $uri $uri/index.html @AnqiCMS;
    }

    access_log /var/log/nginx/anqicms_site1_access.log;
    error_log /var/log/nginx/anqicms_site1_error.log;
}

Nginx configuration example (/etc/nginx/conf.d/anqicms_site2.conf):

`nginx server {

listen 80;
server_name anqicms_site2.com www.anqicms_site2.com; # 替换为您的第二个域名

root /www/wwwroot/anqicms_site2/public; # 替换为您的实际路径

location @AnqiCMS {
    proxy_pass http://127.0.0.1:8002; # 指向第二个实例的内部端口
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}

error_page 404 =200 @AnqiCMS;

location / {
   try_files $uri $uri/index.html @AnqiCMS;
}

access_log /var/log/nginx

Related articles

How to manually configure reverse proxy to solve the problem after the aaPanel installation of AnQiCMS Docker fails?

AnQiCMS is an efficient and scalable enterprise-level content management system that supports various deployment methods, including Docker container deployment.In an aaPanel server management panel like this, although it usually provides a convenient one-click deployment feature for Docker applications, in actual operation, users may sometimes encounter installation failures, resulting in the AnQiCMS Docker container not being properly configured with reverse proxy, causing the website to be unable to access normally.At this time, we can solve the problem by manually configuring a reverse proxy

2025-11-06

How is the one-click deployment process for installing AnQiCMS Docker on aaPanel (BaoTa International Edition)?

As a professional deeply familiar with the operation of Anqi CMS, I know that a smooth and efficient deployment process is crucial for improving operational efficiency.AnQi CMS, developed in Go language, offers high performance, high security, and excellent SEO-friendliness, making it an ideal choice for many small and medium-sized enterprises and content operation teams.While using the Docker container technology of aaPanel (Baota International Edition), we can achieve the quick one-click deployment of secure CMS, greatly simplifying the complex environment configuration process.

2025-11-06

How to configure reverse proxy for the AnQiCMS Docker container deployed in Panel environment?

In the wave of digital operation, a high-efficiency content management system (CMS) like AnQiCMS, combined with modern deployment methods such as Docker, brings great convenience to website operation.However, the configuration of reverse proxy is indispensable for these containerized applications to provide stable and professional services.

2025-11-06

What is the Docker image name for deploying AnQiCMS Docker version using 1Panel?

In the daily operation of AnQi CMS, we fully understand that the ease of deployment is crucial for efficiency.With the increasing popularity of containerization technology, deploying the Docker version of AnQiCMS with a visual management tool like 1Panel has become the preferred choice for many teams.For operators who are new to the field or wish to standardize the deployment process, specifying the name of the Docker image used is a critical step for successful deployment.AnQiCMS as an enterprise-level content management system based on Go language, with its high efficiency

2025-11-06

How to troubleshoot and solve the common problem of insufficient database account permissions during the installation of AnQiCMS?

As a professional who deeply understands the operation of AnQiCMS, I know that the installation process is the first step for every new user to contact the system and start their journey of efficient content management.However, at this critical point, insufficient database account permissions often become a stumbling block for some users.This kind of problem is common, but as long as you master the correct troubleshooting思路 and solution, you can easily solve it.This article will discuss in detail the manifestations, troubleshooting methods, and specific solutions to the insufficient database account permission problems during the AnQiCMS installation process, aiming to help you complete the installation smoothly

2025-11-06

After AnQiCMS backend version upgrade, the front-end page has not been updated. How to force clear the cache or solve the problem?

As an experienced website operator, I know the frustration and confusion you feel when you have diligently completed the AnQiCMS backend version upgrade only to find that the front-end page is still 'as still as a statue'.This is usually not a system failure, but rather due to the multi-layered caching mechanism 'faithfully' preserving the old version of the page content in the background.To solve this problem, we need to delve into it like a detective, layer by layer, investigate and clear away these caches one by one.

2025-11-06

What is the recommended solution for migrating multi-site data when upgrading from version 2.x to 3.x of AnQiCMS?

Colleagues, as a long-term front-line website operator in AnQiCMS, I am well aware of the importance of the stability and efficiency of the content management system for business development.Recently, many operation partners have been consulting on the recommended scheme for migrating data from AnQiCMS version 2.x to 3.x, especially regarding multi-site data migration.Today, I will combine our practical experience with the latest documentation of AnQiCMS to provide a detailed explanation of this process, ensuring a smooth transition for your multi-site.

2025-11-06

What is the detailed configuration example of Nginx reverse proxy when deploying AnQiCMS under the Linux command line environment?

When deploying AnQiCMS in the Linux command-line environment, configuring Nginx as a reverse proxy is a key step in website operation.AnQiCMS as a high-performance, easily scalable Go language content management system usually runs on a non-standard port on the server.

2025-11-06