As an experienced security CMS website operations person, I know that every file, especially the key scripts related to system startup and shutdown, carry the responsibility of the normal operation of the website.start.shandstop.shThe script is the 'switch' of this 'building' of AnQiCMS, any abnormality in them may lead to the website being inaccessible or unmanageable.When you accidentally modify these scripts and save and exit, do not panic, a system troubleshooting process will help you restore the service.
Understand the issue: The potential impact of modifying the script
start.shThe script is responsible for starting the AnQiCMS core service process, it usually checks if the process exists, and runs in the background (usingnohupCommand) Run the executable file of AnQiCMS and output the log to the specified file.stop.shThe script is responsible for finding and terminating the running AnQiCMS process.Once these scripts are incorrectly modified, it may lead to a series of problems such as AnQiCMS failing to start, fail to stop, repeatedly starting to produce multiple processes, and even exhausting system resources.
Fault symptom identification
When you find any of the following situations, it may be the case thatstart.shorstop.shScript has encountered an issue:
- Website is inaccessible:The most direct symptom, the browser prompts connection failure or cannot find the server.
- No response after attempting to start/stop:After executing the script, the website status did not change, the AnQiCMS process was not started nor stopped.
- After starting the script, it was still inaccessible, but the system showed that the process existed:This may mean that the AnQiCMS core program failed to load correctly or there is a port conflict.
- Abnormal system resource usage:There may be multiple AnQiCMS processes running, or a process is consuming CPU or memory abnormally.
- No update to the log file:
running.logorcheck.logNo new records for a long time (if configured).
Initial troubleshooting steps
Before delving into the script content, we can perform some preliminary system status checks.
First, connect to your server via SSH, check if the AnQiCMS process is running. In Linux, you can useps -ef | grep anqicmsCommand. If multiple AnQiCMS processes are found, it may meanstart.shThe script was executed incorrectly multiple times, or the script failed to stop properly.
Secondly, check if the port used by AnQiCMS is occupied. AnQiCMS uses the port by default.8001port. You can use thelsof -i:8001command (to8001Replace with the actual port number used by your AnQiCMS to view port usage. If the port is occupied by another process, AnQiCMS will not start.
Finally, check the AnQiCMS log file.start.shIn the script, the startup log is usually output torunning.logorcheck.log. These log files may contain specific error information for the failure of AnQiCMS startup, such as database connection problems, configuration errors, etc., which helps to narrow down the problem scope.
Detailed script troubleshooting and recovery
When you confirm that the problem may lie instart.shorstop.shthe script itself, the next steps are crucial.
The first step isLocate and back up the current problematic script. Through the SFTP tool or file manager, find the AnQiCMS installation directory understart.shandstop.shthe file. By default, this path may be/www/wwwroot/anqicms/Make sure to copy them and rename them before making any changes to the scriptstart.sh.bakandstop.sh.bakTo prevent irreversible damage due to further operations
The second step isReview the script content. Open with a text editorstart.shandstop.shfile. Refer to the AnQiCMS official documentation (for examplestart.mdand check your script content provided in the examples. Common errors include:
- Path error:
BINPATHThe variable defines the installation path of AnQiCMS,BINNAMEDefined the name of the executable file.If your AnQiCMS is installed in a non-default path or the executable file is renamed, and these two variables in the script are not updated synchronously, it will cause the script to be unable to find the AnQiCMS program. - Syntax error:The shell script is very sensitive to syntax. A simple space, newline, or special character mistake can cause the script to fail.
- Command error: For example,
ps -ef | grepin the commandanqicmsThe string may be mistakenly deleted or modified, causing the process to be unable to identify correctly.kill -9The process ID variable in the command may also be destroyed. nohupor&Lost:start.shThe script should usenohup ... &Put the AnQiCMS process into the background and prevent the process from being terminated when the terminal closes.If these commands are missing, AnQiCMS may not start normally or run in the background.
The third step isManually test and recover. If you have found any errors in the script and have made corrections, do not hurry to execute the task scheduler. It is recommended to manually execute the script in the SSH terminal:
- Manually stop:If AnQiCMS may still be running, first try to execute:
./stop.sh. Observe the terminal output, if it prompts successful stop, then use:ps -ef | grep anqicmsThe process has been confirmed to have terminated. If the stop fails, you can try to manually find the process ID (ps -ef | grep anqicms | awk '{print $2}') and usekill -9 <PID>force termination. - Manual start:Execute
./start.sh.Observe the terminal output. If the script executes successfully, AnQiCMS should start running. Use it againps -ef | grep anqicmsConfirm the process has started. At this time, try to access your website to see if it has returned to normal.
If the script is severely damaged and difficult to repair, the safest method is to obtain a standard version from the official documentation or a known functioning AnQiCMS installation.start.shandstop.shScript, replace the problematic script on your server, then modify the script according to your actual installation path and executable file name, and manually start the test.BINPATHandBINNAMEVariables, and then perform manual startup testing.
Post-event handling and prevention
After AnQiCMS resumes normal operation, you still need to do some post-event work and take preventive measures
first, Reconfirm the task configuration.If during troubleshooting, you disabled the scheduled task for testing, make sure to re-enable or create a Cron task responsible for AnQiCMS automatic startup and shutdown to ensure AnQiCMS can run automatically after server restart.
secondly,Check the website function. Log in to the AnQiCMS backend, confirm that all functions (such as content publishing, image upload, database connection, etc.) are working properly, and ensure that the data is complete and intact.
Finally,Establish good operation and maintenance habits.Always create a backup before modifying any script files in a production environment.Consider using version control tools (such as Git) to manage critical scripts and configuration files.After modifying any configuration or script, it is best to first validate in a test environment or a pre-production environment to ensure that there are no errors before deploying to the production environment.
Even though the above detailed troubleshooting and recovery steps,start.shorstop.shThe script was modified incorrectly, and you can also quickly and effectively solve the problem, ensuring the stable operation of the AnQiCMS website.
Frequently Asked Questions (FAQ)
Q1: I modified the script and saved it, but the website won't open. What should I do?
A1: If the website becomes inaccessible immediately, it is likely that your modification has caused the AnQiCMS service to stop or fail to start. First, connect to the server via SSH to check if the AnQiCMS process is still running (ps -ef | grep anqicmsIf the process does not exist, try to execute manually./start.shAnd check the terminal output and log files (such asrunning.log)to get error information. If the process exists but the website is inaccessible, it may be due to a script causing the service to fail or a port conflict. In this case, you can try to manually execute it./stop.shTerminate the process, then check the logs and restart.If the script content has been severely damaged, it is recommended to restore it as soon as possible using a backup file, or to recreate and modify the path parameters according to the standard script provided in the official documentation.
Q2: Have I restored the script content, but AnQiCMS still cannot start? Are there other possible reasons?
A2: Even if the script content is restored, there may be other reasons why AnQiCMS cannot be started. You can check the following points:
- Port conflict:Even if the script itself is fine, the 8001 port used by AnQiCMS by default may be occupied by other applications. Use
lsof -i:8001Check the port occupancy status, if occupied, you can try to terminate the occupying process or modify the AnQiCMS'sconfig.jsonservice port change. - Permission issue:Ensure that the executable files, script files, and log directories of AnQiCMS have the correct execution and write permissions.
- Insufficient system resources:The server's memory or CPU resources may be exhausted, which may also cause the service to fail to start. Check the system resource usage.
- Other configuration errors:
config.jsonOr other AnQiCMS internal configuration files may contain errors. Check in detailrunning.logorcheck.logThey usually record more specific startup failure reasons. - Database issue:The database service is not running or there is a connection configuration error, which may also cause AnQiCMS to fail to start. Please check the status of MySQL and other database services.
Q3: How should I backup?start.shandstop.shscript?
A3: It is very simple and important to back up these key scripts. The most direct method is to copy them before making modifications throughcpcommands and add.baksuffix:
cp /www/wwwroot/anqicms/start.sh /www/wwwroot/anqicms/start.sh.bakcp /www/wwwroot/anqicms/stop.sh /www/wwwroot/anqicms/stop.sh.bakIt is better to regularly backup the entire AnQiCMS installation directory, or use a version control system (such as Git) to manage these files for easy tracking of changes and quick rollback.At the same time, ensure that these backup files are stored in a safe location outside the server to prevent server failure.