As an experienced CMS website operations personnel for an information security company, I am well aware of the importance of maintaining the stable operation of the website, especially when adjusting the core system files.AnQiCMS is widely popular in actual operation due to its advantages such as efficiency and lightweight in Go language.However, any modification to the core components requires meticulous adjustments to ensure the normal operation of the system.start.shIt must also be adapted for compatibility.


Understanding the AnQiCMS startup scriptstart.shcore function

The deployment of AnQiCMS, especially under Linux environments, usually depends on a name calledstart.shThe script used to manage the application's startup and monitoring.This script is mainly responsible for checking if AnQiCMS is running, and if it is not running, it will automatically start the application.This mechanism ensures that AnQiCMS can automatically recover services even after unexpected crashes or server restarts, greatly improving the availability and stability of the website.

start.shThe script contains several key variables and commands, which work together to identify and execute the main program of AnQiCMS. Among them,BINNAMEThe variable is used to specify the name of the executable file,ps -ef | grepThe command is used to find the process corresponding to the name in the system process list.If these names do not match the actual executable files in use, the script will not be able to detect and start AnQiCMS correctly.

Change the script adjustment after renaming the executable file of AnQiCMS

When you decide to change the executable filename of AnQiCMS for some reasons (such as improving security, avoiding conflicts with other programs in the system, or distinguishing between multiple different instances running on the same server),start.shThe related references in the script must also be synchronized.If the executable file itself exists and can be manually run, the auto-start script will still be unable to find it, causing AnQiCMS to fail to auto-start or restart when needed.

To adjuststart.shThe script needs to be modified to accommodate the new executable filename. You will need to make changes to two critical locations in the script.

Firstly, you need to find the part of the script whereBINNAMEVariable definition line. It is usually set toBINNAME=anqicms. You need to replace it withanqicmsyour new executable file name. For example, if your new executable file name ismyanqicms_webThen this line should be modified toBINNAME=myanqicms_web.

Next, the script needs to be modified to usegrepThe command to find the running processes also needs to be modified. This line of code usually containsgrep '\<anqicms\>'Here,anqicmsThe same needs to be replaced with your new executable filename. Please make sure to keep it.\<and\>These special characters, they are ingrepThe command indicates 'word boundary', ensuring that only complete filenames are matched, rather than strings containing the name, thus avoiding damage to other unrelated processes. For example, if your new filename ismyanqicms_webIf so, this line should be modifiedexists=\ps -ef | grep '<myanqicms_web>' | grep -v grep | wc -l`.

It is worth noting that the commands actually executed by AnQiCMS in the script will usually refer to$BINNAMEvariables, such asnohup $BINPATH/$BINNAME >> $BINPATH/running.log 2>&1 &. Since you have updatedBINNAMEVariable definition, this line of code will automatically use the new executable filename without any additional modification.

Detailed operation steps

To complete these modifications, please follow the following steps:

Firstly, use SSH to connect to your AnQiCMS server.

Secondly, navigate to the installation directory of AnQiCMS, which is usually/www/wwwroot/anqicmsOr the path you customize. Find it in the directory.start.shThe script file.

Then, open the file with your preferred text editor (such as)viornano).start.shFor example, runnano start.sh.

In the opened file, locate toBINNAMEthe line of variable definition, and change its value fromanqicmsto your new executable filename.

Next, find the line containinggrep '\<anqicms\>'and change it.anqicmsReplace with your new executable filename, while ensuring that\<and\>.

After the modification is complete, save the file and exit the editor.

To ensurestop.shThe script can also work normally, performing the same modification steps instop.shYou also need to change, BINNAMEvariables and grepthe executable file names referenced in the command. Keep two scripts, BINNAMEConsistency is the key to ensure that AnQiCMS can be started and stopped correctly.

Finally, execute./start.shCommand manually test the new script and check if AnQiCMS can start normally. You can useps -ef | grep your_new_executable_namecommand to verify if the new executable file is running. At the same time, checkrunning.logandcheck.logFile, confirm there is no abnormal information.

Through the above adjustments, the operation of changing the executable file name of AnQiCMS will not affect its automatic startup and management functions, ensuring the stability of website operation.


Frequently Asked Questions

If I change the executable file name but forget to modifystart.shwhat will happen to the script?

If the executable file name of AnQiCMS is changed without corresponding updatestart.shScript, the system will not be able to automatically start AnQiCMS with this script.This means that your website will not be able to automatically restore services after a server restart or an unexpected termination of the AnQiCMS process.start.shAttempt to start again after the script. In the long run, this will affect the stability and availability of the website, and increase the burden of operation and maintenance.

Why would it be necessary to change the name of the AnQiCMS executable file?

There are various practical application scenarios for changing the name of an executable file.When deploying multiple AnQiCMS instances on the same server, assigning different executable filenames to each instance helps distinguish and manage them, preventing process conflicts.Secondly, from a security perspective, changing the default filename to something less common or custom can slightly increase some 'fuzzy security', making it harder for potential attackers to guess or identify the running service.In addition, custom executable filenames may also bring convenience for certain specific operational maintenance processes or tool integrations.

Modifystart.shWould the script affect the database connection or configuration of AnQiCMS?

No. Modifystart.shThe script is just to make the system able to correctly identify and start the binary file of AnQiCMS application.This operation is purely for the application startup logic and will not affect any internal configuration of AnQiCMS (such as database connection, port settings, website address, etc.).config.jsonThe configuration files or other files related to the executable file name are irrelevant. You just need to make sure that the executable file can correctly read these configuration files.