In the wave of digitalization, an efficient and stable content management system (CMS) is an indispensable cornerstone for both enterprises and individuals to operate websites.AnQiCMS (AnQiCMS) is an enterprise-level CMS developed based on the Go language, which has won a good reputation in the industry with its excellent performance, security, and flexible scalability.It is particularly suitable for users who pursue lightweight, efficient, and customizable solutions, whether they are small and medium-sized enterprises, self-media, or multi-site managers.

Many senior system administrators and developers prefer to deploy applications on Linux servers without a graphical interface, which not only maximizes the use of server resources but also provides higher security and more flexible control.This article will focus on this requirement, and will elaborate in detail on how to efficiently and stably deploy AnQiCMS in a pure command-line environment, so that your website can run smoothly on the solid foundation of Linux.


In a pure command-line environment, deploy AnQiCMS efficiently

Deploying AnQiCMS on a Linux server without a visual panel means you will connect to the server via SSH and operate throughout using the command line.This approach may seem a bit of a threshold at first glance, but once mastered, you will have a deeper understanding and control over the server and application, which is the essence of efficient operation and maintenance.

Before starting the deployment of AnQiCMS, you need to make sure that the server environment is ready.This usually includes a server running a Linux distribution (such as Ubuntu, CentOS, etc.), which is already configured with a web server (Nginx or Apache) for reverse proxy, and a database service (MySQL is recommended), all of which are the foundation for running backend applications and data storage.Assuming you already have these basic environments.

First step: Download and unzip the AnQiCMS installation package

The first step in deploying AnQiCMS is to download its installation package to your Linux server.You can download the latest Linux version package from the official AnQiCMS website.anqicms-linux-v3.x.x.zip.

PasswgetorcurlThe command can directly download the installation package to the server:

wget https://en.anqicms.com/download/anqicms-linux-v3.x.x.zip

After the download is complete, we need to create a special directory to store the AnQiCMS program. For example, we choose to store it in/www/wwwroot/Create a directory named after your domain, which helps with multi-site management and permission isolation: English

mkdir -p /www/wwwroot/yourdomain.com
cd /www/wwwroot/yourdomain.com

Then, move the downloaded installation package to this newly created directory and unzip it. If the server does not haveunzipcommand, you may need to install it first (such assudo apt install unziporsudo yum install unzip).

mv /path/to/anqicms-linux-v3.x.x.zip .
unzip anqicms-linux-v3.x.x.zip

After unpacking, you will see a file namedanqicmsan executable file and other necessary files and directories such aspublic(static resources),template(template files) and so on.

第二步:Configure AnQiCMS service for automatic startup and monitoring

AnQiCMS is an application written in Go, which generates an independent binary file after compilation. To ensure that the service can continue to run, even if the server restarts, and can automatically recover if the program stops unexpectedly, we need to utilizecrontabSet up a guard task.

First, edit the crontab configuration:

crontab -e

This will open a text editor where you can add scheduled tasks. Add the following two lines at the end of the file:

*/1 * * * * /www/wwwroot/yourdomain.com/start.sh
@reboot /www/wwwroot/yourdomain.com/start.sh

The first line indicates to check the running status of AnQiCMS every minute, and if it is not running, start it to act as a watchdog.The second line ensures that AnQiCMS can start immediately after the server restart.

Here are thestart.shIt is the startup script bundled with the AnQiCMS installation package, it will checkanqicmswhether the process exists, if not, it will start in the background (nohup). Please make sure to confirm.start.shscript, make sure it points to the correct directory of the AnQiCMS executable file, and that the directory containsBINPATHandBINNAMEThe variable points to the correct path and executable filename. If your AnQiCMS executable file is notanqicmsstart.shto modify.

After addingcrontabTask completed, you still need to manually execute once.start.shScript to immediately start the AnQiCMS service:

cd /www/wwwroot/yourdomain.com
./start.sh

At this point, the AnQiCMS service is already running in the background, listening by default on8001port.

Third step: Configure the Web server reverse proxy

Since AnQiCMS listens on a non-standard port (8001) by default, we need a web server (Nginx or Apache) as a frontend to receive users' HTTP/HTTPS requests and then forward the requests to the AnQiCMS service.This is called reverse proxy, which not only allows websites to be accessed through standard ports (80 or 443), but also provides advanced features such as SSL certificates, load balancing, caching, etc.

For example, using Nginx, you need to edit or create a configuration file for the Nginx site. This file is usually located in/etc/nginx/conf.d/or/etc/nginx/sites-available/The directory. For example, create a file namedyourdomain.com.conf:

sudo vim /etc/nginx/conf.d/yourdomain.com.conf

Add the following Nginx configuration in the file:

server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com; # 替换为您的实际域名

    # 网站根目录指向AnQiCMS的public目录
    root /www/wwwroot/yourdomain.com/public;

    # AnQiCMS的反向代理配置
    location @AnqiCMS {
        proxy_pass http://127.0.0.1:8001; # AnQiCMS监听的端口
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    # 优先尝试匹配文件,如果找不到,则交由AnqiCMS处理
    location / {
       try_files $uri $uri/index.html @AnqiCMS;
    }

    # 可选:配置SSL证书
    # listen 443 ssl;
    # ssl_certificate /etc/nginx/ssl/yourdomain.com.pem;
    # ssl_certificate_key /etc/nginx/ssl/yourdomain.com.key;

    access_log /var/log/nginx/yourdomain.com_access.log;
    error_log /var/log/nginx/yourdomain.com_error.log;
}

Configuration points explanation:

  • listen 80;andserver_name yourdomain.com www.yourdomain.com;: Defines the listening port and your website domain.
  • root /www/wwwroot/yourdomain.com/public;:Extremely importantThe document root directory of Nginx is pointed to the AnQiCMS program directory underpublicfolder, which is the place to store static resources.
  • location @AnqiCMS { ... }:English-defined an internal forwarding rule, proxying requests to the local.8001Port running AnQiCMS service.
  • try_files $uri $uri/index.html @AnqiCMS;:This is the core pseudo-static rule. It first tries to find inpublicLocate the requested URI (such as static files) under the directory, if not found, try to locateindex.htmlIf not found again, then forward the request to@AnqiCMSProcess. This can make use of Nginx to efficiently handle static files and delegate dynamic requests to AnQiCMS.
  • error_page 404 =200 @AnqiCMS;Ensure that 404 errors can also be handled by AnQiCMS, maintaining the consistency of the URL structure.

Save and close the configuration file, then you need to check if the Nginx configuration file syntax is correct, and reload the Nginx service to make the configuration take effect: “`bash