How to ensure that each AnQiCMS site's data is independent when deploying multiple sites on the same server?
In today's digital age, efficiently managing multiple websites has become a core need for many businesses and individual operators.AnQiCMS (AnQiCMS) is an enterprise-level content management system based on the Go language, providing us with an excellent solution with its high performance, ease of use, and multi-site support.How to ensure that each site's data is completely independent and not interfere with each other when you need to deploy multiple AnQiCMS sites on the same server, it is a crucial issue in operation and maintenance.As an experienced website operations expert, I will delve into this point with you.
In the design philosophy of AnQiCMS, multi-site management is not just about stacking content together, but aims to provide each site with an independent and secure data environment.This data independence is the foundation for brand differentiation, accurate content operation, and information security protection.Whether you need to establish sub-brand websites for different product lines or provide independent CMS services for multiple customers, understanding and practicing data independent deployment will be the key to success.
The cornerstone of data independence: the core three elements
Ensure that the data of each AnQiCMS site is independent, and we need to pay attention to the following three core elements, which are like the "exclusive safe" and "exclusive channel" of each site, ensuring that information is not confused:
- Independent database:This is the most fundamental guarantee of data isolation. Each AnQiCMS site should connect to its own dedicated database.This means that even though they run on the same database server, each site has an independent database name, table structure, and storage space.In this way, the content, users, and configuration data of a site will be completely isolated from the data of another site, eliminating the risk of data confusion and incorrect operations from the source.
- Independent file system storage:In addition to the structured data in the database, each site also generates a large number of unstructured files such as images, videos, attachments, cache files, and configurations such as
config.json) logs, etc. Store these files in separate directories under the root of each independent site, which can effectively avoid file conflicts, permission confusion, and facilitate backup, recovery, or migration for individual sites later on. - An independent application instance and port (or logical isolation):Deploying multiple sites means that there will be multiple "AnQiCMS service" running on the server.Each AnQiCMS application instance needs to listen on a unique port to ensure that traffic is accurately directed to the corresponding site.Even in the AnQiCMS built-in multi-site mode, although there may be only one physical application process, it also creates an independent workspace and data context for each site through logical isolation.
The path of practice: two deployment strategies
After understanding the core elements of data independence, let's take a look at how to achieve it in practice through two main strategies:
Strategy one: Utilize the built-in multi-site management feature of AnQiCMS (efficient integration)
This is a deployment method recommended by AnQiCMS, which is powerful and especially suitable for scenarios where multiple sites need to be managed through a unified backend interface.In this mode, you only need to deploy one AnQiCMS application instance and create and manage multiple front-end sites through its management backend.
- Deploy a basic AnQiCMS instance:First, deploy an AnQiCMS master instance on your server according to the official AnQiCMS guide (for example, through Docker, 1Panel, or Baota panel).This instance will default to listening on a port (such as 8001) and connecting to an initial database.
- Add a new site in the AnQiCMS backend:Log in to the backend management interface of this main instance, find the 'Multi-site Management' feature. Here, you can easily click 'Add New Site'.
- Site Name:Name a site name that is easy to identify.
- Site root directory:This is a key item. You need to specify a new site withindependent and not repetitivephysical path, for example
/app/dev_anqicms_com(in a Docker environment, it is usually with/app/The directory starts and uses the domain to replace periods with underscores). AnQiCMS will store the cache, uploaded files, templates, and other files for the new site in this directory, ensuring the independence of the file level. - Database name:It is equally important. Set up one for the new siteUniqueFor example
dev_anqicms_com. AnQiCMS will store all the content and configuration data of the new site in this independent database.Although it will reuse your main instance's database connection information (such as database server address, username, password), the data itself is completely isolated in different database instances. - Administrator account/password:Set up an independent backend login credential for the new site
- Website address:Enter the domain name of the new site, which needs to be pre-resolved to your server IP.
- Configure reverse proxy:After deploying multiple sites, external users need to access them through different domain names.As only one AnQiCMS application instance is running, you need to configure Nginx, Apache, or the reverse proxy function built into the panel to route different domain requests to the same AnQiCMS instance's listening port.
- For example, your main site
www.site1.comand the new sitewww.site2.comwill be directed through reverse proxy tohttps://en.anqicms.com(or the port that the AnQiCMS instance is actually listening on).After receiving a request, AnQiCMS will automatically identify which site it is based on the domain name and load the corresponding independent data and files.
- For example, your main site
The benefits of this method are centralized management, relatively lower resource consumption (only one AnQiCMS application process), but it can effectively utilize database and file system isolation to achieve data independence.
Strategy two: Deploy multiple AnQiCMS applications independently (highly isolated and flexible configuration)
If you追求极致的隔离性, or need to run different versions of AnQiCMS on different sites, or if your server resources are abundant, then deploying an independent AnQiCMS application instance for each site is a better choice.
- Deploy AnQiCMS application multiple times:For each planned site deployment, install and run an AnQiCMS application independently.
- Independent package/Docker container:Each site has its own AnQiCMS binary file copy or an independent Docker container.
- Independent port configuration:Each application instance in its
config.jsonfile needs to configure aUniquelistening port (for example, the first site uses 8001, the second uses 8002, and so on). - An independent database connection:Each AnQiCMS instance's
config.jsonshould be configured to connect to itsdedicated databaseThis means that each instance not only connects to different database names but can also use different database user credentials (if higher permission isolation is needed). *