Home > Backend Development > C#.Net Tutorial > Example tutorial of running ZKEACMS on CentOS

Example tutorial of running ZKEACMS on CentOS

零下一度
Release: 2017-05-26 13:28:30
Original
1779 people have browsed it

This article mainly introduces the detailed process of running ZKEACMS on CentOS, which has certain reference value. Interested friends can refer to it

ZKEACMS Core is developed based on .net core. It can run cross-platform on windows, linux, and mac. Next, let's take a look at how to run ZKEACMS on CentOS.

Install .Net Core Runtime

Run the following command to install .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
Copy after login

Install Nginx

sudo yum install epel-release
sudo yum install nginx
sudo systemctl enable nginx
Copy after login

Modify the configuration of Nginx

Modify the configuration of Nginx, let it reverse proxy to localhost:5000, modify the global Configuration file /etc/nginx /nginx.conf, modify the location node to the following content

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;
 }
Copy after login

Start Nginx

sudo systemctl start nginx
Copy after login

At this point, our environment is ready. Next, let’s do Publish ZKEACMS

Publish ZKEACMS.Core

Publishing ZKEACMS.Core is relatively simple, just double-click Publish.cmd

DatabaseSQLite

For the sake of simplicity, SQLite is used as the database here, and a SQLite data is generated named Database.sqlite. In the published program folder, create the App_Data folder and put Database.sqlite into the App_Data directory. Regarding how to generate SQLite data, you can ask in the group or search on Baidu/Google yourself.

Modify the connection string

Open appsettings.json and add the SQLite database connection string. The result is 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"
}
Copy after login

Packaging and uploading server

We will package the released program into cms.zip and upload it to the /root directory. And unzip it to the /root/cms directory, use the following command to unzip

unzip cms.zip -d cms


Run

Locate the directory, and then use the dotnet command to run

cd /root/cms
dotnet ZKEACMS.WebHost.dll
Copy after login

After successful operation, 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. This is because dotnet also exited.

Run as a service

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

yum install nano
Copy after login

Create service

sudo nano /etc/systemd/system/zkeacms.service
Copy after login

Enter the following content 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
Copy after login

Start service

systemctl start zkeacms.service
Copy after login

In this way, you can exit the SSH remote connection with peace of mind.

[Related recommendations]

1. .Net Core graphical verification code

2. .NET Core configuration file loading and DI Inject configuration data

3. .NET Core CLI tool documentation dotnet-publish

4. Detailed introduction to ZKEACMS for .Net Core

5. Share the example code for using forms verification in .net MVC

6. How to make an http request under .net core?

The above is the detailed content of Example tutorial of running ZKEACMS on CentOS. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template