As a senior CMS website operation personnel for an information security company, I am well aware of the importance of managing multiple sites 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 operational process.Let's take a detailed look at how to modify the port and make it effective for each AnQiCMS site.
Understanding the difference between multi-site and multi-instance
Before starting, 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 toAnQiCMS program instanceBelow, through backend configuration and reverse proxy, manage multiple domains 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", this 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 and test environment isolation, or for special business requirements.The following will explain 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 are required to ensure that the new port configuration can be saved and put into use smoothly.
Firstly, make sure you have at least one AnQiCMS instance running, and be 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 an independent running 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 the original AnQiCMS installation directory underall files and foldersCompletely copy 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 newly created AnQiCMS directory, 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 server未被占用The new port number. For example, if your first instance uses8001, then the new instance can use8002, the next instance can use8003. Continue in this manner.
After the modification is complete, be sure to saveconfig.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 brand new AnQiCMS instance, it requires a separate 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's.config.jsonFile (or through the Web interface when first accessed), locate the configuration items related to the database (such asDB_NAME,DB_USER,DB_PASS,DB_HOSTEnglish") according to the new database information you have created, update these configuration items. Ensure each independent AnQiCMS instance points to its own database to avoid data conflicts.
4. Rename the executable file (recommended)
To facilitate management and distinguish different AnQiCMS processes, it is strongly recommended that you place the executable file of AnQiCMS (usually on Linux) in the installation directory of the new instance.anqicmsRename it to a more distinctive name, for examplenewsite_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 scripts and task schedules for new instances
To ensure that your new AnQiCMS instance can automatically start after the server restarts and remains stable during operation, you need to configure the startup script and task scheduler for it.
Find the original AnQiCMS instance.start.shandstop.sh(If used), copy the script to the directory of the new instance. Then, edit these scripts and update the following in them:BINPATH(Program path) andBINNAMEAn executable file name variable, making it point to the directory and renamed executable file of the new instance.
Next, set the new instance ofstart.shScript added to the server's task scheduler (for example, using on Linux)crontab -eAdd an entry that runs every minute, or add it through the Task Scheduler feature of Baota Panel/1Panel.So, the system will check regularly and ensure that your new AnQiCMS instance is running.
After configuration is complete, manually execute a newstart.shscript to start your new AnQiCMS instance.
6. Configure Web Server Reverse Proxy
Because your AnQiCMS instance is now listening on a non-standard Web port (such as8002),Users cannot access directly via domain name. You need to set up reverse proxy through a web server (Nginx or Apache) to allow users to access through standard HTTP/HTTPS ports (80/443)Access requests to the new domain name are forwarded to the port that the new AnQiCMS instance is listening on.
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 that
rootThe path points to a new instance.publicThe directory, andproxy_passThe port number inconfig.jsonmatches the new port you set in.Apache configuration example:For Apache, you need to configure the site configuration file (such as
httpd-vhosts.confor by adding a rule 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