Manual deployment of AnQi CMS on the server
Applicable scenarios: Linux server without panel (such as CentOS / Ubuntu), suitable for users familiar with command line operations. Deployment is completed by downloading the installation package, configuring Nginx reverse proxy, and MySQL database.
Preparation
- A Linux server (CentOS 7+ or Ubuntu 20.04+)
- Nginx and MySQL 5.6.35+ installed (recommended to use)LNMP one-click installation package)
- A domain name has been resolved to the server
- AnQiCMS Linux installation package has been downloaded
Installation steps
Step 1: Download and extract
# 登录服务器
ssh root@your-server-ip
# 下载安装包(以 v3.6.2 为例)
wget https://github.com/fesiong/anqicms/releases/download/v3.6.2/anqicms-linux-v3.6.2.zip
# 创建站点目录
mkdir -p /data/wwwroot/anqicms
# 解压安装包
unzip anqicms-linux-v3.6.2.zip -d /data/wwwroot/anqicms
# 进入站点目录
cd /data/wwwroot/anqicms
# 查看文件列表
ls -la
Directory structure after extraction:
/data/wwwroot/anqicms/
├── anqicms # 主程序(可执行文件)
├── start.sh # 启动脚本
├── stop.sh # 停止脚本
├── config.json # 配置文件
├── public/ # Web 根目录
├── template/ # 模板目录
└── system/ # 后台管理界面
Step 2: Start AnQiCMS
# 启动前确保 config.json 中的端口配置正确(默认 8001)
cat config.json
# {"server":{"site_name":"","env":"production","port":8001,"log_level":"release"}}
# 执行启动脚本
./start.sh
# 检查是否启动成功
ps -ef | grep anqicms
# 如果看到 anqicms 进程,说明启动成功
Step 3: Configure Nginx reverse proxy
Create or edit the Nginx site configuration file:
vim /etc/nginx/conf.d/anqicms.conf
Write the following configuration:
server
{
listen 80;
server_name www.anqicms.com m.anqicms.com;
root /data/wwwroot/anqicms/public;
location @AnqiCMS {
proxy_pass http://127.0.0.1:8001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location / {
try_files $uri $uri/index.html @AnqiCMS;
}
# 静态资源直接由 Nginx 处理,不经过反向代理
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css|ico)$ {
expires 30d;
access_log off;
}
access_log /var/log/nginx/anqicms-access.log;
error_log /var/log/nginx/anqicms-error.log;
}
Note: To
server_nameandrootReplace the path with your actual domain name and site path.
Verify the configuration and reload Nginx:
# 测试配置是否正确
nginx -t
# 重载 Nginx 使配置生效
nginx -s reload
Step 4: Add the task to keep the service alive
To make AnQiCMS run automatically after the server restart, add a crontab scheduled task:
# 编辑 crontab
crontab -e
# 添加以下行(每分钟检查一次 anqicms 进程)
*/1 * * * * /data/wwwroot/anqicms/start.sh
# 保存并退出(vim 中 :wq)
Manually execute the startup script once:
./start.sh
Step 5: Configure HTTPS (optional)
Recommended to use the free SSL certificate from Let’s Encrypt:
# 安装 certbot
# CentOS:
yum install certbot python3-certbot-nginx
# Ubuntu:
apt install certbot python3-certbot-nginx
# 获取并自动配置 SSL 证书
certbot --nginx -d www.anqicms.com -d m.anqicms.com
# 按照提示完成验证,certbot 会自动修改 Nginx 配置
Step 6: Initialize installation
- Access in the browser
http://www.anqicms.com - Enter the initial installation interface
- Fill in the database information and administrator account
Apache Reverse Proxy Configuration (optional)
If you use Apache instead of Nginx, the configuration is as follows:
<VirtualHost *:80>
ServerName www.anqicms.com
ServerAlias m.anqicms.com
DocumentRoot /data/wwwroot/anqicms/public
ProxyPass / http://127.0.0.1:8001/
ProxyPassReverse / http://127.0.0.1:8001/
<Directory /data/wwwroot/anqicms/public>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache2/anqicms-error.log
CustomLog /var/log/apache2/anqicms-access.log combined
</VirtualHost>
You need to enable Apache's proxy module:
a2enmod proxy proxy_http
systemctl restart apache2
Common management commands
# 启动
cd /data/wwwroot/anqicms && ./start.sh
# 停止
cd /data/wwwroot/anqicms && ./stop.sh
# 查看运行状态
ps -ef | grep anqicms
# 查看运行日志
tail -f /data/wwwroot/anqicms/running.log
# 查看启动检测日志
tail -f /data/wwwroot/anqicms/check.log
# 修改端口(编辑 config.json 后重启)
vim /data/wwwroot/anqicms/config.json
# 修改 "port": 8001 为其他端口
Verify Installation
# 1. 检查进程是否运行
ps -ef | grep anqicms | grep -v grep
# 2. 检查端口是否监听
netstat -tlnp | grep 8001
# 3. 浏览器访问域名,应看到网站首页或安装界面
# 4. 访问 域名/system/ 进入后台
❓ I installed MySQL but don't know what the root password is, what should I do?
If MySQL is installed using the LNMP one-click installation package, the root password is usually saved in the following location:
# LNMP 安装包
cat /root/.mysql_root_password
# 或
cat /usr/local/mysql/root.txt
# 宝塔面板安装的 MySQL
cat /www/server/mysql/default.pass
If the above does not work, you can bypass MySQL authentication to reset the password (for Ubuntu):
# 1. 停止 MySQL
systemctl stop mysql
# 2. 以跳过权限检查的方式启动
mysqld_safe --skip-grant-tables &
# 3. 无密码登录 MySQL
mysql -u root
# 4. 在 MySQL 命令行中重置密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '你的新密码';
FLUSH PRIVILEGES;
EXIT;
# 5. 重启 MySQL
systemctl restart mysql
❓ After configuring Nginx, why does the domain access show the Nginx default welcome page instead of the installation interface?
This is the most common mistake made by beginners.The reasons are usually the following two:
Reason one: The Nginx root path points to the default website directory.
# 检查默认网站配置文件中是否还有 server 块
ls /etc/nginx/conf.d/default.conf
# 如果有,暂时将其重命名禁用
mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak
nginx -s reload
Reason two: The root in the Nginx configuration does not point to the public subdirectory.
# ❌ 错误
root /data/wwwroot/anqicms;
# ✅ 正确
root /data/wwwroot/anqicms/public;
Reason three: DNS has not taken effect.
The domain name resolution just added may take a few minutes to a few hours to take effect globally. You can use the following command to test:
# 直接通过服务器 IP 测试(如果 AnQiCMS 监听在 8001 端口)
curl -I http://127.0.0.1:8001
# 如果返回 200 或 302,说明 AnQiCMS 正常运行,是 Nginx 或 DNS 的问题
❓ I changed the port in the config. to 8080. Do I need to synchronize any modifications?
After changing the port,The following two must be synchronized.:
| Position | Modification content |
|---|---|
In the Nginx configurationproxy_pass |
proxy_pass http://127.0.0.1:8080;(not 8001) |
| Restart AnQiCMS | After changing config., the process must be restarted for it to take effect |
If you do not modify Nginx'sproxy_pass, Nginx will still try to forward requests to the 8001 port, while AnQiCMS is already listening on the 8080 port, and the user will see 502 Bad Gateway.