Detailed procedure for running zkeacms on CentOS

Time:2021-9-18

Zkeacms core is developed based on. Net core and can run across platforms on windows, Linux and MAC. Next, let’s see how to run zkeacms on CentOS.

Installing the. Net core runtime

Run the following command to install the. Net core runtime


sudo yum install libunwind libicu
curl -sSL -o dotnet.tar.gz https://go.microsoft.com/fwlink/?linkid=843420
sudo mkdir -p /opt/dotnet && sudo tar zxf dotnet.tar.gz -C /opt/dotnet
sudo ln -s /opt/dotnet/dotnet /usr/local/bin

Installing nginx


sudo yum install epel-release
sudo yum install nginx
sudo systemctl enable nginx

Modify the configuration of nginx

Modify the configuration of nginx to reverse proxy to localhost: 5000, modify the global configuration file / etc / nginx / nginx.conf, and modify the location node as follows


location / {
  proxy_pass http://localhost:5000;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection keep-alive;
  proxy_set_header Host $host;
  proxy_cache_bypass $http_upgrade;
 }

Start nginx


sudo systemctl start nginx

Here, we have a good environment. Next, let’s release zkeacms

Release zkeacms.core

It is easy to publish zkeacms.core. Double click publish.cmd

Database SQLite

For simplicity, SQLite is used as the database to generate a SQLite data named database.sqlite. In the published program folder, create an app_ Data folder and put database.sqlite into app_ Data directory. About how to generate SQLite data, you can enter the group to ask, or Baidu / Google by yourself.

Modify connection string

Open appsettings.json and add the SQLite database connection string. The results are as follows


{
 "ConnectionStrings": {
  "DefaultConnection": "",
  "Sqlite": "Data Source=App_Data/Database.sqlite",
  "MySql": ""
 },
 "ApplicationInsights": {
  "InstrumentationKey": ""
 },
 "Logging": {
  "IncludeScopes": false,
  "LogLevel": {
   "Default": "Debug",
   "System": "Information",
   "Microsoft": "Information"
  }
 },
 "Culture": "zh-CN"
}


Package upload server

We package the published program as cms.zip and upload it to the / root directory. Extract it to the / root / CMS directory and use the following command to extract it

unzip cms.zip -d cms

function

Navigate to the directory and run with the dotnet command


cd /root/cms
dotnet ZKEACMS.WebHost.dll

After running successfully, you can use your server’s IP or domain name to access:)

After exiting the SSH Remote connection client, I found that I could not access it because dotnet also exited.

Run as a service

Create a service and let dotnet run in the background. Install nano editor


yum install nano

Create service


sudo nano /etc/systemd/system/zkeacms.service

Enter the following to save


[Unit]
  Description=ZKEACMS

  [Service]
  WorkingDirectory=/root/cms
  ExecStart=/usr/local/bin/dotnet /root/cms/ZKEACMS.WebHost.dll
  Restart=always
  RestartSec=10
  SyslogIdentifier=zkeacms
  User=root
  Environment=ASPNETCORE_ENVIRONMENT=Production

  [Install]
  WantedBy=multi-user.target

Start service


systemctl start zkeacms.service

In this way, you can safely exit the SSH Remote connection.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support developpaer.