As an expert who deeply understands the operation of AnQiCMS, I understand your desire 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 more granular resource isolation, independent process management, or to optimize for specific sites individually, we may need to run each site on an independent AnQiCMS application instance.

This article will detail how to configure a dedicated for each 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 typically allows a single AnQiCMS application instance to host and manage multiple websites.This pattern is efficient and has relatively low resource usage, suitable for most multi-site operation scenarios.

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

Environment preparation

Before starting the configuration, please make sure 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 site that runs independently.
  • 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 independent AnQiCMS instance needs to 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 to forward requests for each domain to the corresponding AnQiCMS instance's listening port.
  • Database Service:Each AnQiCMS instance usually requires an independent database to store its data to ensure data isolation.

Step-by-step configuration of independent start and stop scripts

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

On the server, first create a dedicated installation directory for each site and extract the AnQiCMS installation package into each directory. For example, if the domain name of your first site issite1.comYou can unzip the AnQiCMS file into/www/wwwroot/site1.com/anqicms_app1; the second sitesite2.comand unzip the files into/www/wwwroot/site2.com/anqicms_app2. Continue in this manner.

For each decompressed AnQiCMS instance directory, you need to make the following key configuration changes. First, go into the root directory of each AnQiCMS instance you have decompressed, find the file namedanqicmsThe 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, then rename it toanqicms_site2.

Next, open the configuration file in the root directory of each AnQiCMS instance. Findconfig.jsonthe configuration file.portField, and change it to a unique, unused port 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.shScripts. These scripts need to be modified to adapt to the renamed executable files and their respective installation paths. Open.start.shthe script file, find.BINNAMEandBINPATHthe variables, and update their values.BINPATHShould point to the absolute path of the current AnQiCMS instance.BINNAMEIt should be consistent with the executable file name you renamed previously. It is especially important to note that instart.shUsed to check if a process existsgrepcommand, and the executable file name that matches must also be updated to the newBINNAMEfor examplegrep '\<anqicms_site1\>'Similarly, forstop.shthe same modification to the script, 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 as a reverse proxy.Create a separate server block (Nginx) or virtual host (Apache) configuration for each domain.proxy_passCommand points to127.0.0.1and the unique port that this AnQiCMS instance is listening on. For example,site1.comThe configuration should proxy requests tohttp://127.0.0.1:8001whilesite2.comthen proxy tohttp://127.0.0.1:8002In addition, make sure that each site'srootdirectory points correctly to the directory under the AnQiCMS instance directorypublicfolder, 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.shAdd an entry that runs every minute to the script.

*/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 handled exclusively by its dedicatedstart.shThe script performs monitoring and management. When you need to stop or restart a specific site individually, simply manually execute the corresponding instance directory under.stop.shScript, or through the corresponding scheduled task management interface.

Important notes

When deploying multiple independent AnQiCMS instances, there are several aspects that require your special attention:

Firstly, each independent AnQiCMS instance will have itsConsumption of independent system resources.This 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 for each site, to avoid performance bottlenecks due to insufficient resources.

Secondly,Database managementIs the key to data isolation.Although all instances can be connected 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 separate and does not interfere with each other. Even if the data of one site has a problem, it will not affect other sites.

Finally,Maintenance of configuration filesVital. Each AnQiCMS instance'sconfig.jsonThe file carries the core configuration of the instance, including ports,