As a website operator who deeply understands the operation of AnQiCMS, I know the importance of a stable and reliable online environment for a content management system.Ensure that the AnQiCMS program can automatically run with the server startup and can recover itself after an unexpected interruption, which is the cornerstone of ensuring the website remains online and provides high-quality content services.The following will explain in detail how to set up the boot self-start and process guard of the AnQiCMS program on a Linux server.

Deploy and monitor the AnQiCMS program on a Linux server

AnQiCMS is a corporate-level content management system developed based on the Go language, known for its efficiency, security, and ease of use.But in a production environment, simply deploying the program is not enough, we also need a set of mechanisms to ensure its continuous operation.This includes automatic startup after server restart and timely recovery in case of program crashes, achieving boot-up self-start and process guardianship.

Prepare the environment

Before starting the configuration, make sure that your Linux server meets the following conditions:

  • The MySQL database service has been installed, AnQiCMS needs it to store website data.
  • Nginx or Apache web server has been installed, used to handle user HTTP/HTTPS requests and reverse proxy to AnQiCMS.
  • You have connected to the server via SSH client and have sufficient privileges to perform installation and configuration operations.
  • You have downloaded the latest program installation package for Linux from the AnQiCMS official website.

Deployment and auto-start configuration of AnQiCMS program

First, upload the AnQiCMS Linux installation package you downloaded to the server. Typically, we would choose a standard path to store it, such as/www/wwwroot/your_domain.com/(Please move theyour_domain.comReplace your actual domain name). After uploading, useunzipCommand to unzip the installation package.

AnQiCMS programs usually exist in the form of an executable file, for example, namedanqicms. To achieve boot-up automatic startup and basic process guardianship, we can use tools配合 a simple script.crontab. You need to create a named

. namedstart.shThe script file, its content is as follows. This script checks if the AnQiCMS process is running, and if not, it starts AnQiCMS and redirects its output to a log file.

#!/bin/bash
### check and start AnqiCMS
# author AnQiCMS Operator
# the bin name is anqicms
BINNAME=anqicms # 您的AnQiCMS可执行文件名,默认为anqicms
BINPATH=/www/wwwroot/your_domain.com # 您的AnQiCMS程序所在目录,请替换为实际路径

# 检查AnQiCMS进程是否存在
exists=`ps -ef | grep '\<anqicms\>' |grep -v grep |wc -l`
echo "$(date +'%Y%m%d %H:%M:%S') $BINNAME PID check: $exists" >> $BINPATH/check.log
echo "PID $BINNAME check: $exists"

# 如果进程不存在,则启动AnQiCMS
if [ $exists -eq 0 ]; then
    echo "$BINNAME NOT running, attempting to start..."
    # 进入程序目录,以后台方式运行AnQiCMS,并将标准输出和错误输出重定向到running.log
    cd $BINPATH && nohup $BINPATH/$BINNAME >> $BINPATH/running.log 2>&1 &
    echo "$(date +'%Y%m%d %H:%M:%S') $BINNAME started." >> $BINPATH/check.log
else
    echo "$BINNAME is already running." >> $BINPATH/check.log
fi

Be sure to setBINNAMEandBINPATHVariable is modified to the actual path of the AnQiCMS executable file and the directory it is in. Save this script asstart.shto the AnQiCMS program directory and give it execution permissions:chmod +x /www/wwwroot/your_domain.com/start.sh.

We will configure nextcrontabTo achieve self-startup and process guardianship.crontabAllow you to set periodic tasks. By lettingcrontabexecute once a minutestart.shScript, you can ensure that AnQiCMS starts on the server (becausecrontabThe service will start automatically and will run automatically, and even if the program stops unexpectedly for some reason, it will be restarted within the next minutecrontaband restarted.

Execute the following command to editcrontabTask List:

crontab -e

Add the following line in the open text editor:

*/1 * * * * /www/wwwroot/your_domain.com/start.sh

Please replace the path with yourstart.shactual script storage path. Save and exit the editor. This configuration will enablestart.shThe script runs every minute. To start AnQiCMS immediately, you can run it manually once.sh /www/wwwroot/your_domain.com/start.sh.

Configure Web Server Reverse Proxy

AnQiCMS program listens by default.8001Port. In order for users to access your website via standard HTTP (port 80) or HTTPS (port 443), you need to configure Nginx or Apache as a reverse proxy.

For example, with Nginx, you can in its site configuration file