How to configure independent `start.sh` and `stop.sh` scripts for each AnQiCMS multi-site instance?

Calendar 👁️ 58

As an expert who deeply understands the operation of AnQiCMS, I understand your need to implement independent management for each AnQiCMS site instance.In multi-site operations, although AnQiCMS provides powerful built-in multi-site management features, sometimes to achieve finer-grained resource isolation, independent process management, or personalized optimization for specific sites, we may need to run each site on an independent AnQiCMS application instance.

This article will detail how to configure exclusive for each independent AnQiCMS instance running on the same serverstart.shandstop.shScript, ensure that each site can have its own lifecycle management.

Background and advantages of deploying an independent AnQiCMS instance

The AnQiCMS built-in multi-site management feature usually allows a single AnQiCMS application instance to host and manage multiple websites.This model is efficient and has relatively low resource usage, suitable for most multi-site operation scenarios.However, when you have the following requirements for different sites, it would be a better choice to deploy multiple AnQiCMS instances independently and configure independent scripts for each instance:

Firstly, an independent application instance can provide strongerprocess isolationIf an AnQiCMS instance crashes due to configuration errors or a failure in a specific module, it will not affect other AnQiCMS instances running on the server.This significantly improves the system stability for critical business sites.Secondly, each instance can haveindependent resource allocation and performance tuningSpace. You can adjust the running parameters of the AnQiCMS process for each site individually according to the traffic, data volume, and performance requirements, without interfering with each other. Finally, independent.start.shandstop.shScripts makeMaintenance and upgrades more flexibleYou can restart, update, or troubleshoot a specific site without affecting all other sites on the server, greatly improving operational efficiency.

Environmental preparation

Before starting the configuration, please ensure that your server meets the following basic conditions:

  • Multiple AnQiCMS installation packages:Download the AnQiCMS installation package compatible with your server operating system from the AnQiCMS official website. You need to prepare a copy of the installation package for each independently running site.
  • Independent installation directory:Create an independent installation directory for each AnQiCMS instance, for example/www/wwwroot/site1.com/anqicms_instanceand/www/wwwroot/site2.com/anqicms_instance.
  • Independent domain and port:Each AnQiCMS instance must listen on a non-conflicting port (such as 8001, 8002, 8003, etc.), and have a unique domain name resolved to the server.
  • Web server (Nginx/Apache):Your web server (such as Nginx or Apache) needs to be configured as a reverse proxy, forwarding requests for each domain to the port that the corresponding AnQiCMS instance is listening on.
  • Database service:Each AnQiCMS instance typically requires an independent database to store its data to ensure data isolation.

Gradually configure independent start and stop scripts

This process involves detailed configuration adjustments for each AnQiCMS instance, and here are the specific steps:

On the server, first create a dedicated installation directory for each site and unzip the AnQiCMS package into the respective directories. For example, if your first site domain issite1.comYou can extract the AnQiCMS file to/www/wwwroot/site1.com/anqicms_app1; the second sitesite2.comextract the files to/www/wwwroot/site2.com/anqicms_app2and so on.

For each unpacked AnQiCMS instance directory, you need to make the following key configuration changes. First, go to the root directory of each unpacked AnQiCMS instance, find the file namedanqicmsAn executable file. To avoid process conflicts between different instances, it is recommended that you rename this executable file to a unique name, such as forsite1.comAn instance, you can rename it toanqicms_site1; forsite2.comAn instance, it will be renamed toanqicms_site2.

Next, open in the root directory of each AnQiCMS instanceconfig.jsonThe configuration file. Findportfield and change it to a unique, unused port number for this instance. For example,anqicms_site1can be set to8001,anqicms_site2can be set to8002to ensure that each instance listens on a different port.

Then, under the root directory of each AnQiCMS instance, you will find the defaultstart.shandstop.shScript. These scripts need to be modified to adapt to the renamed executable files and their respective installation paths. Openstart.shFind the script fileBINNAMEandBINPATHVariables, and update their values.BINPATHIt should point to the absolute path of the current AnQiCMS instance, whileBINNAMEit should be consistent with the executable file name you renamed before. It is especially important to note that,start.shUsed to check if the process existsgrepcommand, and must also update the name of the executable file to the newBINNAMEFor examplegrep '\<anqicms_site1\>'. Similarly, forstop.shmodify the script in the same way, to ensureBINPATHandBINNAMEand its internalgrepAll commands point to the correct executable file names.

After configuring the AnQiCMS instance, your web server needs to correctly route external requests to the corresponding AnQiCMS instance.This is usually achieved by configuring Nginx or Apache's reverse proxy.Create a separate server block (Nginx) or virtual host (Apache) configuration for each domain.In the configuration, you need to setproxy_passThe instructions point to127.0.0.1and the unique port that the AnQiCMS instance is listening on. For example,site1.comThe configuration should proxy requests tohttps://en.anqicms.comwhilesite2.comthen proxy tohttp://127.0.0.1:8002In addition, make sure that each site'srootdirectory points to the AnQiCMS instance directory underpublicFolder, for example/www/wwwroot/site1.com/anqicms_app1/public.

To ensure that each AnQiCMS instance can run automatically at server startup and restart automatically in case of an unexpected stop, you should usecrontabAdd a scheduled task for each instance. Opencrontab -eand for each AnQiCMS instance'sstart.shscript, add an entry that runs every minute. For example:

*/1 * * * * /www/wwwroot/site1.com/anqicms_app1/start.sh
*/1 * * * * /www/wwwroot/site2.com/anqicms_app2/start.sh
# ...以此类推,为每个独立实例添加一行

Thus, each AnQiCMS instance's process will be exclusive of its ownstart.shThe script performs monitoring and management. When you need to stop or restart a site individually, you just need to manually execute the corresponding instance directory understop.shScript, or through the corresponding scheduled task management interface to operate.

Important notes

When deploying multiple independent AnQiCMS instances, there are several aspects you need to pay special attention to:

First, each independent AnQiCMS instance will have itsindependent system resource consumptionThis means that each instance will consume a certain amount of CPU, memory, and I/O resources.When deciding on the number of deployments, be sure to make a reasonable assessment based on your server hardware configuration and the expected traffic of each site, to avoid performance bottlenecks due to insufficient resources.

secondly,database managementIt is the key to data isolation. Although all instances can connect to the same MySQL server, it is strongly recommended to configure a separate database name for each AnQiCMS instance.This ensures that the data of each site is completely separated, without interference, even if the data of one site has a problem, it will not affect other sites.

Finally,maintenance of configuration filesis crucial. Each AnQiCMS instance'sconfig.jsonThe file carries the core configuration of the instance, including ports,

Related articles

How to avoid PID conflicts between different instances when deploying AnQiCMS across multiple sites?

As an experienced security CMS operation personnel, I am well aware that the stability and efficiency of the system are crucial when managing multiple websites.The AnQi CMS provides strong support for us with its high concurrency characteristics of the Go language and multi-site management features.However, when deploying multiple security CMS instances on the same server, how to properly handle process ID (PID) conflicts to ensure that each instance runs independently and stably is a core issue that needs to be addressed in operations.

2025-11-06

How to adjust the `start.sh` script after changing the executable file name of AnQiCMS in order to continue working?

As an experienced CMS website operation personnel of Anqi, I am well aware of the importance of maintaining the stable operation of the website, especially when adjusting the system's core files.AnQiCMS with its efficiency and lightweight nature in the Go language is widely popular in actual operation.However, any modification to the core components requires meticulous adjustments to ensure the normal operation of the system.Among them, after changing the executable file name of AnQiCMS, the corresponding startup script `start.sh` must also be adjusted for compatibility.

2025-11-06

What impact does the `BINNAME` variable have on process identification in the `start.sh` script?

HelloAs an experienced CMS website operation personnel, I fully understand how important it is to have a clear grasp of the underlying mechanisms when managing the system.`start.sh` script's `BINNAME` variable seems simple, but it plays a core role in the process identification and stable operation of the security CMS.Below, I will elaborate on the impact of this variable on process identification.

2025-11-06

How does the mechanism of detecting PID with `grep '\u003canqicms>'` in `start.sh` work?

As an experienced CMS website operation personnel, I know that the stable operation of the website is the basis for the effective dissemination of content.In daily work, we must not only pay attention to the quality of the content and the user experience, but also ensure the continuous and reliable operation of the backend services.AnQi CMS provides a simple and efficient mechanism for this, using specific commands in the `start.sh` script to detect and maintain the running status of the core application.The `start.sh` script plays the role of a guardian in the deployment of AnQi CMS.Its main responsibility is to check if the main program is running

2025-11-06

What is the specific function and advantage of the `nohup` command in the AnQiCMS startup script?

In the daily operation of AnQiCMS, system stability and reliability are the core.As a high-performance content management system built with Go language, AnQiCMS needs to ensure that its core services can run continuously and without interruption.In the Linux server environment, the `nohup` command plays a crucial role in the startup script of AnQiCMS, ensuring this and providing many conveniences.

2025-11-06

Which AnQiCMS process information are recorded in the `running.log` and `check.log` files, and how can they be used for troubleshooting?

As an experienced CMS website operation personnel, I am well aware of the importance of website stability for content publication and user experience.In daily work, log files are an indispensable tool for diagnosing system health and quickly locating problems.AnQi CMS provides the `running.log` and `check.log` log files, which record different process information and together provide valuable clues for troubleshooting system failures.

2025-11-06

How to quickly judge whether the AnQiCMS process is running normally through the `check.log` file?

As a senior person who has been deeply engaged in the CMS content operation of AnQi for many years, I am well aware of the importance of website stability to the business.AnQi CMS, with its high efficiency, lightweight nature, and the high concurrency characteristics brought by the Go language, provides a solid foundation for our content management.However, any system may encounter unexpected situations, at this time, it is particularly important to quickly judge whether the core process is running normally.Today, I will explain in detail how to use the `check.log` file, this "heart monitor" built into AnQiCMS, to quickly diagnose the system status.

2025-11-06

What are the potential risks or practices of the AnQiCMS auto-start task configured with `crontab -e`?

As an experienced CMS website operation personnel in the security industry, I am well aware of the importance of the stable operation and continuous availability of content for user experience and business goals.Aqin CMS, with its high concurrency features of the Go language and concise and efficient architecture, provides a solid foundation for content management.However, even such a high-performance system needs a comprehensive operation and maintenance strategy to ensure uninterrupted service.Among them, using `crontab -e` to configure automatic startup tasks is a common method for many AnQiCMS operators to ensure that the application remains online.

2025-11-06