Hello! As an experienced AnQi CMS operation personnel, I am very happy to be able to explain in detail how to efficiently configure Nginx reverse proxy to support the multi-site deployment of AnQiCMS under the command-line environment.AnQiCMS's powerful multi-site management function, combined with the flexible proxy mechanism of Nginx, can help you easily manage multiple independently running websites on the same server, greatly enhancing operational efficiency.

Introduction

AnQiCMS (AnQiCMS) is favored by small and medium-sized enterprises and content operation teams for its high-performance architecture based on the Go language and its concise and efficient features.Among them, multi-site management is one of its core highlights, allowing users to independently operate multiple websites under a single system instance.When deploying AnQiCMS in a command-line environment, how to use Nginx as a reverse proxy to effectively configure these multi-sites is a key skill that many operators need to master.This article will guide you step by step through this configuration process.

Understanding the multi-site mechanism of AnQiCMS

Before delving into the configuration, it is first necessary to clarify the principle of AnQiCMS's multi-site operation.A core advantage of AnQiCMS lies in the fact that a running AnQiCMS instance (usually listening on a specific port, such as 8001) can serve multiple different frontend domains through its built-in multi-site management feature.Nginx plays the role of traffic distribution and reverse proxy here, it forwards requests to the same AnQiCMS backend port based on different domain names visited by users.AnQiCMS backend then identifies which site is initiating the request based on the Host header information forwarded by Nginx, and provides the corresponding site content.This means you do not need to run an independent AnQiCMS process for each site, thereby saving server resources and simplifying management.

Preparation

Before starting the configuration, make sure that your Linux server meets the following conditions:

  • Linux Operating System:Recommended to use mainstream distributions such as Ubuntu, CentOS, etc.
  • Nginx is installed and running:Nginx will act as your reverse proxy server.
  • The MySQL database is installed and running:AnQiCMS needs a database to store data.
  • Domain resolution:All the domain names you plan to use for multiple sites have been correctly resolved to your server IP address.

Deploy the main AnQiCMS instance

Firstly, we need to deploy and initialize an AnQiCMS master instance. This instance will be the backend service provider for all other sites.

Download and extract

Please download the latest Linux version package from the AnQiCMS official website and upload it to your server. Typically, we would place it in a meaningful directory, such as/www/wwwroot/anqicms_main. Extract the installation package:tar -xzvf anqicms-linux-vX.x.x.tar.gz -C /www/wwwroot/anqicms_mainEnter the directory after extraction:cd /www/wwwroot/anqicms_main

Daemon process configuration

To ensure that the AnQiCMS service can automatically start and run stably after the server restarts, we usually usecrontabto set up a daemon. Create a namedstart.shThe startup script is located in/www/wwwroot/anqicms_maindirectory, the content is as follows:

#!/bin/bash
BINNAME=anqicms
BINPATH=/www/wwwroot/anqicms_main

exists=`ps -ef | grep '\<anqicms\>' |grep -v grep |wc -l`
if [ $exists -eq 0 ]; then
    cd $BINPATH && nohup $BINPATH/$BINNAME >> $BINPATH/running.log 2>&1 &
fi

Add execute permission to the script:chmod +x /www/wwwroot/anqicms_main/start.shNext, add this script tocrontabIn order to check AnQiCMS every minute to see if it is running, and if not, start it:crontab -eIn the opened editing interface, add the following line and save and exit:*/1 * * * * /www/wwwroot/anqicms_main/start.shManually execute the startup script once to ensure that the AnQiCMS service has started running:/www/wwwroot/anqicms_main/start.sh

Main site Nginx configuration

Configure Nginx reverse proxy for your first (main) AnQiCMS site.