How to manually deploy AnQiCMS on a Linux server?
As an experienced website operations manager, I am well aware of the importance of a stable and efficient content management system for the development of a company.AnQiCMS with its excellent performance in Go language and many enterprise-level features has become an ideal choice for many small and medium-sized enterprises and content operation teams.Deploy AnQiCMS on a Linux server to fully utilize its high performance and security advantages.Below, I will elaborate on the steps and key points of manually deploying AnQiCMS on a Linux server, aiming to help you successfully set up and run your content platform.
Manual deployment of AnQiCMS on Linux server
Deploy AnQiCMS on a Linux server requires a series of detailed steps to ensure stable operation and maximize its performance.We will explain step by step from environmental preparation, file processing, core service configuration, to the final reverse proxy setup.
Preparation: Deployment Environment and Necessary Components
Before starting to deploy AnQiCMS, your Linux server needs to be configured with some basic environments and software components.Firstly, your server should be based on a Linux distribution with X86 architecture, such as Ubuntu, CentOS, Debian, etc.At the same time, ensure that you have SSH access privileges to operate the server via the command line, and be prepared with an FTP or SCP tool for file transfer.
The database is the core of any content management system, AnQiCMS requires the backend database to be MySQL 5.6.35 or higher version.Please make sure to install and configure the MySQL service in advance, and prepare a MySQL user with database creation and management permissions (usually the root user or a user specifically created for AnQiCMS).
In order to expose the AnQiCMS service to internet users, you also need a web server as a reverse proxy.Nginx and Apache are excellent choices, they can forward requests coming from port 80 (HTTP) or port 443 (HTTPS) to the internal ports where AnQiCMS is running.Ensure that one of the web servers is installed and running.
Obtain AnQiCMS Installation Package
The first step in deployment is to download the latest Linux installation package from the AnQiCMS official website. Please visit the official download page.https://en.anqicms.com/downloadSelect the distribution package suitable for the Linux system (usuallyanqicms-linux-vX.X.X.zipor.tar.gzformat). Download this package to your local computer.
File upload and extraction
After the download is complete, you need to upload the AnQiCMS installation package to the Linux server. It is recommended that you/www/wwwroot/Create a dedicated directory for your AnQiCMS site under the directory/www/wwwroot/yourdomain.com. Upload the installation package to this newly created directory using SCP tools or an FTP client.
After the file upload is complete, log in to your server via SSH, enter the directory, and use the appropriate command to unzip the installation package. If the.zipfile can be usedunzip anqicms-linux-vX.X.X.zipcommand; if it is.tar.gzfile, then usetar -xzvf anqicms-linux-vX.X.X.tar.gzcommand. After unpacking, you will see the core files of AnQiCMS, includinganqicmsexecutable files and related scripts and template files.
Database configuration and initialization
The initialization process of AnQiCMS will automatically guide you when you visit the browser for the first time.When you complete the subsequent web server configuration and first open the AnQiCMS site, the system will prompt you to enter the database connection information.Here, you need to fill in the previously prepared MySQL database host (usually127.0.0.1)、Port(default as)3306) database name, and the MySQL username and password with corresponding permissions.In addition, you will also set up the admin account and password for the website backend, as well as the website access address.Ensure that all information is accurate and correct, as incorrect database credentials or insufficient permissions may cause the installation to fail.
AnQiCMS process guardian
To ensure that the AnQiCMS service can run continuously and stably, even if the server restarts or the program exits unexpectedly, we need to set up a process guard mechanism. The AnQiCMS installation package providesstart.shandstop.shScript to start and stop the service.
First, you need to add the executable file path of AnQiCMS to your.start.shscript. Assuming AnQiCMS has been extracted to/www/wwwroot/anqicms.com/The directory and the executable file name isanqicmsthenstart.shThe script should be configured as follows:
#!/bin/bash
### check and start AnqiCMS
# author fesion
# the bin name is anqicms
BINNAME=anqicms
BINPATH=/www/wwwroot/anqicms.com # 请替换为您的AnQiCMS实际安装路径
# check the pid if exists
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"
if [ $exists -eq 0 ]; then
echo "$BINNAME NOT running"
cd $BINPATH && nohup $BINPATH/$BINNAME >> $BINPATH/running.log 2>&1 &
fi
Next, use Linux'scrontabtools to execute periodicallystart.shScript to achieve process guardianship. Open the crontab editor:
crontab -e
In the open editor interface, add the following line to check every minute and start AnQiCMS (if it is not running):
*/1 * * * * /www/wwwroot/anqicms.com/start.sh
save and exitcrontabEditor. After adding a scheduled task, to start the AnQiCMS service immediately, you can manually execute it once.start.shScript:
cd /www/wwwroot/anqicms.com
./start.sh
Configure Web Server Reverse Proxy
AnQiCMS runs on the default internal port (usually8001To allow external users to access your website through a domain name, you need to configure a web server (Nginx or Apache) as a reverse proxy to forward external requests to the internal port of AnQiCMS.At the same time, the web server'srootThe directory points to the installation directory of AnQiCMSpublicfolder to provide static resources.
Nginx configuration example:
Create a new site configuration file in the Nginx configuration directory (for example/etc/nginx/conf.d/yourdomain.com.conf),and add the following content:
server {
listen 80;
server_name www.yourdomain.com; # 替换为您的域名
root /www/wwwroot/anqicms.com/public; # 替换为您的AnQiCMS public目录
location @AnqiCMS {
proxy_pass https://en.anqicms.com; # 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;
}
error_page 404 =200 @AnqiCMS; # 确保所有请求都经过AnQiCMS处理
location / {
try_files $uri $uri/index.html @AnqiCMS;
}
access_log /var/log/nginx/yourdomain.com.access.log; # 访问日志路径
error_log /var/log/nginx/yourdomain.com.error.log; # 错误日志路径
}
After the configuration is complete, please check the syntax of the Nginx configuration file:nginx -t. If there are no errors, then reload the Nginx service to make the configuration take effect:systemctl reload nginxorservice nginx reload.
Apache configuration example:
If you choose to use Apache as a web server, make sure it is enabledmod_proxyandmod_proxy_httpModule. Then add the reverse proxy rule in your virtual host configuration file. First, add the virtual host'sDocumentRootpointing to AnQiCMSpublicDirectory.
`apache
ServerName www.yourdomain.com # 替换为您的域名
DocumentRoot /www/wwwroot/anqicms.com/public # 替换为您的AnQiCMS public目录
<Directory /www/wwwroot/anqicms.com/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / https://en.anqicms.com/