What is the complete procedure for saving and exiting the configuration and making the new port effective after modifying the `port` port of each site in the multi-site configuration?
As a senior Anqi CMS website operations personnel, I am well aware of the importance of multi-site management for efficient operation.When you need to deploy multiple independent AnQiCMS instances on the same server and want each instance to listen on a different port, it indeed requires a clear operation procedure.Let's go through it in detail on how to modify and make the port effective for each AnQiCMS site.
Understand the difference between multi-site and multi-instance
Before we start, we need to clarify the two "multi-site" modes supported by AnQiCMS. One is the built-in multi-site management feature of AnQiCMS, which allows you toAn AnQiCMS program instanceBelow, through backend configuration and reverse proxy, manage multiple domain names and independent website data.In this mode, all sites share the same AnQiCMS process, so there is no need to modify the port for each site.
The requirement you proposed - 'Modify each site'portPort', which actually refers to running on the same serverMultiple independent AnQiCMS program instancesEach instance has its own code copy, independent database, and listens on different ports.This pattern is often used for development, test environment isolation, or special business requirements.We will elaborate on this multi-instance, multi-port configuration.
Complete process of modifying the port and making the new site effective
When you decide to allocate a unique port for each AnQiCMS instance, the following detailed steps should be followed to ensure that the new port configuration can be saved and put into use smoothly.
First, make sure you have at least one AnQiCMS instance running and are familiar with your server file system and the reverse proxy configuration of web servers such as Nginx or Apache.
1. Copy AnQiCMS program code
Firstly, you need to prepare a separate runtime environment for the new AnQiCMS instance. Find the installation directory of your existing AnQiCMS instance, for example/www/wwwroot/anqicms.com. Then, create a new directory on your server, for example/www/wwwroot/newsite.com, and move all files and folders from the original AnQiCMS installation directoryto the new directoryCopy it completely to this new directory. This is because each independent instance needs to have its own code copy.
2. Modify the configuration file of the new instance.
In the AnQiCMS directory created, locate toconfig.jsonthe file. This file contains the core configuration information of the AnQiCMS instance. Open it with a text editor.
Inconfig.jsonIn the file, you will find a namedportconfiguration item, whose default value is usually8001. You need to change this value to one that is currently on the serverNot occupiedThe new port number. For example, if your first instance uses8001then the new instance can use8002the next instance can use8003and so on.
Be sure to save after modificationconfig.jsonFile. This step is to inform the new AnQiCMS instance which port it should listen on to provide services.
3. Configure the database information for the new instance.
Since this is a new AnQiCMS instance, it requires an independent database to store data.You need to create a new database on your database server (such as MySQL) and set up the corresponding user and password.
Then, go back to the new instance'sconfig.jsonFile (or through the Web interface during the first visit), find the database-related configuration items (such asDB_NAME,DB_USER,DB_PASS,DB_HOSTWait).Update these configuration items based on the database information you have just created. Make sure each independent AnQiCMS instance points to its own database to avoid data conflicts.
4. Rename the executable file (recommended)
It is strongly recommended for easy management and differentiation of different AnQiCMS processes to place the AnQiCMS executable file (usually on Linux) in the installation directory of a new instance.anqicmsRename to a more identifiable name, such asnewsite_anqicms.
This step is not mandatory, but it can effectively avoid confusion when you need to manage a specific AnQiCMS instance through the command line or task manager.
5. Configure startup script and task scheduler for new instance
To ensure that your new AnQiCMS instance can automatically start after the server restart and remain stable during operation, you need to configure its startup script and task scheduler.
Find the original AnQiCMS instance ofstart.shandstop.shScript (if used), copy it to the directory of the new instance. Then, edit these scripts and update theBINPATH(program path) andBINNAME(Executable file name) variable, making it point to the directory of the new instance and the renamed executable file.
Next, rename the new instance'sstart.shAdd the script to the server's task scheduler (for example, using Linux oncrontab -eAdd an entry that runs every minute, or add it through the task scheduler feature of Baota panel/1Panel).This system will check regularly and ensure that your new AnQiCMS instance is running.
After the configuration is complete, manually run a newstart.shscript to start your new AnQiCMS instance.
6. Configure Web Server Reverse Proxy
Since your AnQiCMS instance is now listening on a non-standard Web port (such as8002),users cannot access directly through the domain name. You need to set up a reverse proxy through a web server (Nginx or Apache) to route users through standard HTTP/HTTPS ports(80/443) Forward requests to the port that the new AnQiCMS instance is listening on for the new domain.
Nginx configuration example:Create a new Nginx server block file (for example
/etc/nginx/conf.d/newsite.com.conf), the content is similar to the following:server { listen 80; server_name newsite.com www.newsite.com; # 替换为您的新域名 root /www/wwwroot/newsite.com/public; # 指向新实例的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; } error_page 404 =200 @AnqiCMS; location / { try_files $uri $uri/index.html @AnqiCMS; } }Make sure
rootThe path points to a new instance ofpublicdirectory, andproxy_passthe port number in it matches theconfig.jsonnew port you set inApache configuration example:For Apache, you need to configure the site configuration file (such as
httpd-vhosts.confOr by adding rules similar to the following through the Baota panel's reverse proxy settings:`apache
ServerName newsite.com ServerAlias www.newsite.com DocumentRoot /www/wwwroot/newsite.com/public # 指向新实例的public目录 RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ http://127.0