What is the relationship between the port configuration in the `config.` file of AnQiCMS and stopping/startup?

Calendar 👁️ 66

In the daily operation and maintenance of AnQi CMS, we often deal with various configuration files. Among them,config.jsonThe file is undoubtedly one of the 'lifelines' of AnQiCMS operation, carrying the core parameters for system startup. Today, as an old soldier who has been deeply involved in website operation for many years, I will delve into it with everyone.config.jsonThe configuration of ports in the file, and its inseparable association with the start and stop of the AnQiCMS service.

The 'lifeblood' of AnQiCMS running:config.jsonport configuration in Chinese

In the world of AnQiCMS,config.jsonThe file is the starting point of the 'ID card' and 'code of conduct' for each site instance. It defines critical information such as database connections, cache settings, and the most fundamental and directly impacting the service startup is the embedded port (port)configuration.

Generally, in the root directory where you install AnQiCMS, you will find a file likeconfig.json. Open it, and you will find a field namedportwith a default value often being8001. This number is not arbitrarily set; it specifies the specific 'address number' that the AnQiCMS service listens for external connections on your server.Imagine that your server is a building, AnQiCMS is a shop inside the building, and this port number is the only entrance that this shop opens to the public.All requests that wish to access this AnQiCMS site must be received and processed by the AnQiCMS service through this specified port.

Port association with AnQiCMS service "Breath": start and stop

This seemingly simple port number is actually directly and profoundly related to the 'breath' (i.e., start and stop) of AnQiCMS services.

When the service starts: the "listening" port

When you start the AnQiCMS service, whether by executingstart.shScript, or start the "Go project" in visualization tools like Baota panel, the first step of the AnQiCMS program is to try to occupy and proceedconfig.jsonThe port configured. If all goes well, AnQiCMS will successfully bind to this port and start listening for requests from clients (such as browsers).At this moment, this port is like the only 'window' opened by AnQiCMS to the outside world, ready to receive and process all HTTP traffic.

However, if this port has been occupied by another program on the server (possibly another AnQiCMS instance, or another web service), the AnQiCMS service will not be able to start successfully.The system will throw an error message indicating that the port is already occupied because the same 'door number' cannot be used by two stores at the same time.This requires us to promptly identify and resolve port conflicts to ensure that each AnQiCMS instance has its exclusive 'address'.

Port release when the service stops

When you decide to stop the AnQiCMS service, whether by executingstop.shscript, or by ending it in the Windows Task Manageranqicms.exeProcess, the system will try to close the AnQiCMS program gracefully.In normal shutdown, AnQiCMS will "release" the port it previously occupied.This port is now free and can be used by other programs, or it can be reused by itself when AnQiCMS starts up next time.

A clean shutdown process is crucial. If the AnQiCMS service terminates abnormally for some reason (such as a sudden power outage or being forcibly killed with 'kill -9'), it may not have the opportunity to release the port normally.Although programs developed in Go language usually handle such situations well, theoretically, a port accidentally occupied may be in the "TIME_WAIT" state for a short period of time, causing AnQiCMS or other services to be unable to use the port immediately within a short period of time, thereby affecting the rapid recovery of the service.Therefore, following the startup/shutdown script provided by the official, performing an elegant shutdown is a practice to ensure the smooth release of ports and stable operation of the system.

The actual application of port configuration: the art of multiple sites and reverse proxy

After understanding the relationship between ports and service start/stop, we can better utilize this mechanism for more advanced deployment and operation strategies.

Deployment of multiple sites on a single server: ports are crucial

One of AnQiCMS' highlights is the support for multi-site management.Imagine you need to manage multiple content sites on the same server, each running independently.At this moment, simply through one8001Ports are not enough. In order for each AnQiCMS instance to work independently, you need to prepare an independent AnQiCMS program file (or a logically independent running environment) for each instance on the server, and modify the root directory of each instance'sconfig.jsonFiles, set theirportparameters to different port numbers, for example8001/8002/8003And so, each AnQiCMS site can run on its independent 'door number' without interference.

Reverse proxy: the 'behind-the-scenes hero' of ports.

However, let the user directly pass throughhttp://您的域名:8001This way of accessing the website is not common in actual production environments and is not professional enough.At this point, reverse proxy (such as Nginx, Apache) has become an indispensable 'behind-the-scenes hero'.

The reverse proxy server listens to standard HTTP (port 80) or HTTPS (port 443), and when users access, the request first reaches the reverse proxy. The reverse proxy then forwards the request to the backend AnQiCMS service that listens on a non-standard port (such as127.0.0.1:8001)

This deployment method has many advantages:

  1. Standardized access: Users do not need to remember non-standard port numbers.
  2. Enhanced securityHide the real port of AnQiCMS service to reduce the direct attack surface.
  3. SSL/TLS encryption: Reverse proxy can handle SSL certificates uniformly, implement HTTPS access, and AnQiCMS itself does not need to be directly configured.
  4. Load balancingIf multiple AnQiCMS instances are deployed, the reverse proxy can distribute traffic and achieve load balancing.
  5. Site reuseOn a single 80/443 port, Nginx can distribute requests to different AnQiCMS instances (i.e., different internal ports) based on domain names.

Therefore, in a multi-site deployment, you will see that each AnQiCMS instance is configured with a unique internal port, and all external traffic is routed intelligently through a reverse proxy to the correct internal port, finally presented to the user.

Summary

config.jsonThe port configuration is the core element for starting, running, and stopping AnQiCMS.It not only determines how AnQiCMS service listens and responds to network requests, but also plays a crucial role in multi-site deployment and reverse proxy architecture.A deep understanding of this configuration and its relationship with the service lifecycle can help us operate and manage the AnQiCMS website more efficiently and securely, providing users with a smooth and stable access experience.


Frequently Asked Questions (FAQ)

  1. Q: How to deal with the server prompt 'Port is already in use'?A: When you try to start AnQiCMS and encounter the error 'Port is already in use', it usually means that youconfig.jsonThe port configured is already occupied by another process on the server (it may be another AnQiCMS instance, or other web services, databases, etc.). Under Linux, you can uselsof -i:{端口号}Use the command to check which process is occupying the port (for examplelsof -i:8001). After finding the PID (process ID) of the occupying process, you can usekill -9 {PID}Command to force terminate the process. After termination, you can try to restart the AnQiCMS service. In Windows, you can find it in the Task Manager.anqicms.exeProcess and end it, or check if other applications are using the port. Always ensure that the port required by AnQiCMS is exclusive each time it starts.

  2. Q: How to change the default port of AnQiCMS after installation?A: Modifying the AnQiCMS runtime port is very simple. You just need to find the AnQiCMS installation directory andconfig.jsonfile, open it with a text editor. Find the following in it."port": 8001(or the port number you are currently configured) this line will8001modify it to the other port number you want to use, such as8002). After modifying and saving the file, please make sure to stop the AnQiCMS service that is currently running, and then restart it so that the new port configuration can take effect.If your website uses Nginx or Apache and other reverse proxies, don't forget to synchronize the update of the reverse proxy configuration, and itsproxy_passThe port number in the target address must also be changed to the new value, otherwise the user will not be able to access the website normally.

  3. Q: Since AnQiCMS has its own port, why do we still need to set up a reverse proxy?A: Using a reverse proxy (such as Nginx, Apache) to forward access to AnQiCMS is recommended in a production environment, as it brings many benefits:

    • Standardized port accessUsers are accustomed to accessing through standard 80 (HTTP) or 443 (HTTPS)

Related articles

How to temporarily disable some features of AnQiCMS without completely stopping it?

## Flexible Control: Disabling Specific AnQiCMS Features Without Interrupting Service As an experienced website operations expert, I know that in our daily work, we often need to fine-tune website features, sometimes to test new modules, sometimes to temporarily disable certain services that are no longer applicable, or to maintain and upgrade without affecting core business.How to temporarily disable some functions of AnQiCMS without completely stopping it?

2025-11-06

What negative impacts will there be on the SEO spider crawling the website after the AnQiCMS service is stopped?

As an experienced website operations expert, I know that every CMS system is crucial for the SEO performance of a website, especially systems like AnQiCMS (AnQiCMS) that integrate a large number of SEO-friendly features from the very beginning.It not only provides the efficiency of content management, but also secures a place for the website in search engines through a series of advanced SEO tools.

2025-11-06

Where is the default directory of AnQiCMS's `start.sh` and `stop.sh` scripts?

As an experienced website operations expert, I know that a high-efficiency and stable content management system (CMS) is crucial for the successful operation of a corporate website.AnQiCMS with its lightweight and efficient Go language stands out among many CMS systems, providing us with a solid foundation.In daily system maintenance and troubleshooting, the `start.sh` and `stop.sh` service management scripts of AnQiCMS play a core role.

2025-11-06

How to check if the AnQiCMS project has stopped successfully and released the port using the `lsof` command?

## Website Operation Tool: How to check if the AnQiCMS project has stopped successfully and released the port using the `lsof` command?As a high-performance content management system developed based on the Go language, AnQiCMS, while pursuing efficiency, also has refined requirements for the use of server resources.Whether it is for system maintenance, version upgrade, or daily deployment adjustment, ensuring that the AnQiCMS project can stop running cleanly and release the ports it occupies is an indispensable part of website operation.

2025-11-06

How to smoothly migrate old data after stopping the AnQiCMS project and redeploying a new version?

In the dynamic journey of website operation, technological iteration and upgrade is the norm.How can you ensure that the data of the old website can be seamlessly migrated to the new environment when you decide to stop the current AnQiCMS project and plan to deploy a completely new and more powerful version, while minimizing business disruption, which is a key challenge that every operator must face.As an experienced website operations expert, I am well aware of the importance of data. Next, I will elaborate on the strategy and steps of this smooth migration based on the characteristics of AnQiCMS and relevant documents.

2025-11-06

The AnQiCMS Operation Manual: Easily resolve the startup dilemma of 'port already in use'

When using AnQiCMS to manage your website, you may occasionally encounter a pesky but quite common error: "The port is already in use".As a content management system developed based on Go language, known for its efficiency and stability, AnQiCMS usually runs smoothly.However, when it throws this error during startup or restart, many operators may feel at a loss.Don't worry, this problem is not unique to AnQiCMS, but a challenge that all network service-based applications may encounter.

2025-11-06

What specific improvements are mentioned in the "elegant startup and restart" of AnQiCMS's changelog?

As an experienced website operations expert, I am well aware of the importance of a stable and efficient CMS system for the operation of a corporate website.In the update log of AnQiCMS (AnQi CMS), we noticed that the feature of "elegant startup and restart of the blog" was proposed in version v1.0.0-alpha, which was then inherited and developed throughout the AnQiCMS system.This seemingly simple description actually contains profound considerations of AnQiCMS in system design and operation experience.In my opinion

2025-11-06

How to confirm that all related processes have exited after stopping the service in the AnQiCMS command-line deployment environment?

AnQiCMS, as an efficient content management system built with Go language, is known for its lightweight and high performance in command-line deployment environments.The characteristics of Go language make AnQiCMS usually compiled into an independent binary file, which simplifies deployment, but also means that we need to clearly understand how to manage its lifecycle.Especially when we need to stop the service, how to ensure that all related background processes have been completely exited, to avoid resource occupation or potential service conflicts, is a critical step to ensure the stable operation of the system and prevent the appearance of 'zombie processes'.###

2025-11-06