在Linux CentOS上部署Asp.Net Core项目(Tengine、Asp.Net Core、Centos、MySql)

时间:2023-03-08 16:55:56
在Linux CentOS上部署Asp.Net Core项目(Tengine、Asp.Net Core、Centos、MySql)

一、前言

  1、简单记录一下Linux CentOS 7中安装与配置Tengine的详细步骤。

  2、简单比较一下Tengine 和Nginx

  3、搭建Asp.net Core和部署 Web程序

  4、总结一下操作

  5、# 表示目前我使用的权限是root 最高权限,$ 表示我使用的权限是一般用户权限。

二、开始安装环境

  Tengine是淘宝发起的web服务器项目,简单的讲就是对nginx进行了二次开发并提供了更丰富的功能,

  Tengine的性能和稳定性已经在大型的网站如淘宝网,天猫商城等得到了很好的检验

  它的最终目标是打造一个高效、稳定、安全、易用的Web平台。

  从2011年12月开始,Tengine成为一个开源项目。

  现在,它由Tengine团队开发和维护。Tengine团队的核心成员来自于淘宝、搜狗等互联网企业。

  官网地址:http://tengine.taobao.org/,目前最新的稳定版本是2.3.0,我这里也用的这个版本。

1、查看环境

cat /etc/redhat-release
CentOS Linux release 7.6. (Core)

2、下载安装包安装Tengine-2.3.0(这一步可以跳过,直接使用命令安装,比较方便)

  下载pcre-8.39.tar.gz【依赖】 、下载zlib-1.2.11.tar.gz【依赖】 、下载openssl-1.0.1h.tar.gz【依赖】 、下载jemalloc-3.6.0.tar.bz2  【依赖】 、下载 tengine-2.3.0.tar.gz

  【http://tengine.taobao.org/download/tengine-2.3.0.tar.gz】

 安装命令

# cd /usr/local/src/
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
# wget http://zlib.net/zlib-1.2..tar.gz
# wget http://www.openssl.org/source/openssl-1.0.1h.tar.gz
# wget http://www.canonware.com/download/jemalloc/jemalloc-3.6..tar.bz2
# wget http://tengine.taobao.org/download/tengine-2.3..tar.gz

3、通过命令行运行安装Tengine-2.3.0

  在安装之前首先检查一下是否已安装nginx的一些模块依赖的lib库,诸如g++、gcc、pcre-devel、openssl-devel和zlib-devel。所以下面这些命令最好挨个跑一遍,已安装的会提示不用安装,未安装或需要更新的则会执行安装及更新。

 安装命令

 yum install gcc-c++
yum -y install pcre pcre-devel
yum -y install zlib zlib-devel
yum -y install openssl openssl-devel

 执行这个是有用的,让系统自动检测安装比较省事。  我没有使用wget 下载解压安装

 具体操作如下

[root@centos001 ~]# yum install gcc-c++
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
...........................................更新安装
Total download size: 8.7 M
Installed size: M
Is this ok [y/d/N]: y
Downloading packages:
(/): libstdc++-devel-4.8.-.el7_6..x86_64.rpm | 1.5 MB ::
(/): gcc-c++-4.8.-.el7_6..x86_64.rpm | 7.2 MB ::
-----------------------------------------------------------------------------------------------------------------------------------------------
Total MB/s | 8.7 MB ::
Running transaction check
...........................................更新安装
Complete!
[root@centos001 ~]# yum -y install pcre pcre-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Package pcre-8.32-.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
...........................................更新安装
Installed:
pcre-devel.x86_64 :8.32-.el7 Complete!
[root@centos001 ~]# yum -y install zlib zlib-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Package zlib-1.2.-.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package zlib-devel.x86_64 :1.2.-.el7 will be installed
--> Finished Dependency Resolution
...........................................更新安装
Installed: zlib-devel.x86_64 :1.2.-.el7 Complete!
[root@centos001 ~]#  yum -y install openssl openssl-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Package :openssl-1.0.2k-.el7_6..x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
...........................................更新安装
Dependency Installed:
keyutils-libs-devel.x86_64 :1.5.-.el7 krb5-devel.x86_64 :1.15.-.el7_6 libcom_err-devel.x86_64 :1.42.-.el7
libkadm5.x86_64 :1.15.-.el7_6 libselinux-devel.x86_64 :2.5-14.1.el7 libsepol-devel.x86_64 :2.5-.el7
libverto-devel.x86_64 :0.2.-.el7 Complete!

至此,操作结束。依赖包安装完毕

3、安装Tengine,安装主程序在这里

安装命令

下载Tengine-2.3.0主程序,查询下载安装包情况

 cd /usr/local/src/
wget http://tengine.taobao.org/download/tengine-2.3..tar.gz
ls

解压安装包文件  

tar -zxvf tengine-2.3..tar.gz

到指定目录修改安装配置

cd /usr/local/src/tengine-2.3.
./configure 

生成编译

make
sudo make install

具体操作如下

[root@centos001 ~]# cd /usr/local/src/
[root@centos001 src]# wget http://tengine.taobao.org/download/tengine-2.3..tar.gz
---- ::-- http://tengine.taobao.org/download/tengine-2.3..tar.gz
Resolving tengine.taobao.org (tengine.taobao.org)... 140.205.230.4
Connecting to tengine.taobao.org (tengine.taobao.org)|140.205.230.4|:... connected.
HTTP request sent, awaiting response... OK
Length: (.3M) [application/octet-stream]
Saving to: ‘tengine-2.3..tar.gz’ %[=====================================================================================================>] ,, .30MB/s in .8s -- :: (1.30 MB/s) - ‘tengine-2.3..tar.gz’ saved [/] [root@centos001 src]# ls
tengine-2.3..tar.gz
[root@centos001 src]# tar -zxvf tengine-2.3.0.tar.gz
...........................................解压一堆文件
tengine-2.3.0/tests/test-nginx/test-nginx/t/syntax.t
[root@centos001 src]# ls
tengine-2.3.0 tengine-2.3.0.tar.gz
[root@centos001 ~]# cd /usr/local/src/tengine-2.3.0
[root@centos001 tengine-2.3.0]# ./configure
checking for OS
+ Linux 3.10.0-957.5.1.el7.x86_64 x86_64
checking for C compiler ... found
+ using GNU C compiler
+ gcc version: 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
checking for gcc -pipe switch ... found
checking for -Wl,-E switch ... found
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ using system zlib library
+ jemalloc library is disabled nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
 [root@centos001 tengine-2.3.0]# make
make -f objs/Makefile
make[1]: Entering directory `/usr/local/src/tengine-2.3.0'
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I src/proc -I objs \
...........................................一堆文件
sed -e "s|%%PREFIX%%|/usr/local/nginx|" \ -e 
"s|%%PID_PATH%%|/usr/local/nginx/logs/nginx.pid|"
\ -e "s|%%CONF_PATH%%|/usr/local/nginx/conf/nginx.conf|" \
-e "s|%%ERROR_LOG_PATH%%|/usr/local/nginx/logs/error.log|" \
< man/nginx.8 > objs/nginx.8 make[1]: Leaving directory `/usr/local/src/tengine-2.3.0'

[root@centos001 tengine-2.3.0]# sudo make install
  make -f objs/Makefile install
  make[1]: Entering directory `/usr/local/src/tengine-2.3.0'
  test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx'
  test -d '/usr/local/nginx/sbin' \
  || mkdir -p '/usr/local/nginx/logs'
  make[1]: Leaving directory `/usr/local/src/tengine-2.3.0'
  [root@centos001 tengine-2.3.0]#

至此,安装基本结束,剩下配置文件

4、配置Tengine

  Tengine完全兼容Nginx,因此可以参照Nginx的方式来配置Tengine。

  我们在此只列出Tengine中值得注意的功能。关于详细的Tengine的相对于Nginx的差别,可以访问变更列表

编辑文件

vi /lib/systemd/system/nginx.service 

输入内容 ,点击编辑,按键:esc 输入 :wq 保存配置文件

#pei zhi wen jian
[Unit] Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target [Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true [Install]
WantedBy=multi-user.target

 设置权限,我设置失败了,使用默认权限

chmod  nginx.service

  操作命令 

###--启动nginx服务
systemctl start nginx.service ###--设置开机自启动
systemctl enable nginx.service ###--停止开机自启动
# systemctl disable nginx.service ###--查看服务当前状态
systemctl status nginx.service ###--重新启动服务
systemctl restart nginx.service ###--查看所有已启动的服务
systemctl list-units --type=service

 具体操作如下

make[1]: Leaving directory `/usr/local/src/tengine-2.3.0'
[root@centos001 tengine-2.3.0]# vi /lib/systemd/system/nginx.service
[root@centos001 tengine-2.3.0]# chmod 745 nginx.service
chmod: cannot access ‘nginx.service’: No such file or directory
[root@centos001 tengine-2.3.0]# cd
[root@centos001 ~]# chmod 745 nginx.service
chmod: cannot access ‘nginx.service’: No such file or directory
[root@centos001 ~]# systemctl start nginx.service
[root@centos001 ~]# chmod 745 nginx.service
chmod: cannot access ‘nginx.service’: No such file or directory
[root@centos001 ~]# systemctl status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2019-05-08 17:48:40 CST; 4min 44s ago
Process: 9286 ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf (code=exited, status=0/SUCCESS)
Process: 9285 ExecStartPre=/usr/local/nginx/sbin/nginx -t (code=exited, status=0/SUCCESS)
Main PID: 9290 (nginx)
CGroup: /system.slice/nginx.service
├─9290 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
└─9291 nginx: worker process

May 08 17:48:40 centos001 systemd[1]: Starting The nginx HTTP and reverse proxy server...
May 08 17:48:40 centos001 nginx[9285]: nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
May 08 17:48:40 centos001 nginx[9285]: nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
May 08 17:48:40 centos001 systemd[1]: Failed to read PID from file /usr/local/nginx/logs/nginx.pid: Invalid argument
May 08 17:48:40 centos001 systemd[1]: Started The nginx HTTP and reverse proxy server.
[root@centos001 ~]#

配置结束,访问可以看到一个介绍页面。表示成功

Welcome to tengine!

If you see this page, the tengine web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to tengine.taobao.org.

Thank you for using tengine.

二、安装Net Core环境

官方推荐安装方式:

Install .NET Core SDK on Linux CentOS / Oracle - x64

下载安装NET包 

In your terminal, run the following commands:

sudo rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm

安装 .NET SDK

Update the products available for installation, then install the .NET SDK.

In your terminal, run the following commands:

sudo yum update
sudo yum install dotnet-sdk-2.2

#可以看到版本号意味着安装成功

dotnet --version
dotnet --info

 具体操作如下

[root@centos001 ~]# sudo rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm
Retrieving https://packages.microsoft.com/config/rhel//packages-microsoft-prod.rpm
warning: /var/tmp/rpm-tmp.wBQ0lQ: Header V4 RSA/SHA256 Signature, key ID be1229cf: NOKEY
Preparing... ################################# [%]
Updating / installing...
:packages-microsoft-prod-1.0-.el7################################# [%]
[root@centos001 ~]# sudo yum update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
packages-microsoft-com-prod | 2.9 kB ::
packages-microsoft-com-prod/primary_db | kB ::
Resolving Dependencies
--> Running transaction check
......................................................等待漫长安装

Install 2 Packages
  Upgrade 49 Packages

Total download size: 167 M
  Is this ok [y/d/N]: y
  Downloading packages:

......................................................等待漫长安装

Complete!

[root@centos001 ~]# sudo yum install dotnet-sdk-2.2
  Loaded plugins: fastestmirror
  Loading mirror speeds from cached hostfile
  Resolving Dependencies
  --> Running transaction check

......................................................等待漫长安装

Dependency Installed:
  aspnetcore-runtime-2.2.x86_64 0:2.2.4-1 dotnet-host.x86_64 0:2.2.4-1 dotnet-hostfxr-2.2.x86_64 0:2.2.4-1
  dotnet-runtime-2.2.x86_64 0:2.2.4-1 dotnet-runtime-deps-2.2.x86_64 0:2.2.4-1 libicu.x86_64 0:50.1.2-17.el7

Complete!
  [root@centos001 ~]# dotnet --info
  .NET Core SDK (reflecting any global.json):
  Version: 2.2.101
  Commit: 236713b0b7

Runtime Environment:
  OS Name: centos
  OS Version: 7
  OS Platform: Linux
  RID: centos.7-x64
  Base Path: /root/dotnet/sdk/2.2.101/

Host (useful for support):
  Version: 2.2.0
  Commit: 1249f08fed

.NET Core SDKs installed:
  2.2.101 [/root/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.2.0 [/root/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.2.0 [/root/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.2.0 [/root/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

三、部署Net Core web 程序

1、利用ftp服务器上传web文件

我这里上传程序文件到Centos服务的目录是:/home/sopftpuser/ftp/upload/Tools

详细文章看:https://www.cnblogs.com/sopcce/p/10743241.html

2、访问你部署的程序

cd /root/sop/tools
dotnet Sop.Tools.dll #运行web应用,这里就是web程序运行的类库
dotnet Sop.Tools.dll --server.urls http://*:5000 

3、部署服务

vi /usr/lib/systemd/system/sop.tools.service
[Unit]
Description=Example .NET Web API App running on CentOS [Service]
WorkingDirectory=/root/sop/tools
ExecStart=/usr/bin/dotnet /root/sop/tools/Sop.Tools.dll
Restart=always
# Restart service after seconds if the dotnet service crashes:
RestartSec=
KillSignal=SIGINT
SyslogIdentifier=dotnet-sop-tools
User=root
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false [Install]
WantedBy=multi-user.target
##--后台程序重新编译生产
systemctl daemon-reload
##--启动服务
systemctl start sop.tools.service
##--停止服务
systemctl stop sop.tools.service
##--重启服务
systemctl restart sop.tools.service
##--查看服务
systemctl status sop.tools.service
##--输入日志
journalctl -fu sop.tools.service

 具体操作如下

[root@centos----20G ~]# systemctl daemon-reload
[root@centos----20G ~]# systemctl start sop.tools.service
[root@centos----20G ~]# systemctl status sop.tools.service
● sop.tools.service - Example .NET Web API App running on CentOS
Loaded: loaded (/usr/lib/systemd/system/sop.tools.service; disabled; vendor preset: disabled)
Active: activating (auto-restart) since Thu -- :: CST; 2s ago
Process: ExecStart=/usr/bin/dotnet /root/sop/tools/Sop.Tools.dll (code=exited, status=/SUCCESS)
Main PID: (code=exited, status=/SUCCESS)
[root@centos----20G ~]# systemctl restart sop.tools.service
[root@centos----20G ~]# systemctl status sop.tools.service
● sop.tools.service - Example .NET Web API App running on CentOS
Loaded: loaded (/usr/lib/systemd/system/sop.tools.service; disabled; vendor preset: disabled)
Active: active (running) since Thu -- :: CST; 4s ago
Main PID: (dotnet)
CGroup: /system.slice/sop.tools.service
└─ /usr/bin/dotnet /root/sop/tools/Sop.Tools.dll May :: centos----20G dotnet-sop-tools[]: User profile is available. Using '/root/.aspnet/DataProtection-Keys...rest.
May :: centos----20G dotnet-sop-tools[]: warn: Microsoft.AspNetCore.Server.Kestrel[]
May :: centos----20G dotnet-sop-tools[]: Unable to bind to http://localhost:5000 on the IPv6 loopback interf...ess'.
May :: centos----20G dotnet-sop-tools[]: Hosting environment: Production
May :: centos----20G dotnet-sop-tools[]: Content root path: /root/sop/tools
May :: centos----20G dotnet-sop-tools[]: Now listening on: http://localhost:5000
May :: centos----20G dotnet-sop-tools[]: Now listening on: https://localhost:5001
May :: centos----20G dotnet-sop-tools[]: Application started. Press Ctrl+C to shut down.
May :: centos----20G dotnet-sop-tools[]: warn: Microsoft.AspNetCore.Server.Kestrel[]
May :: centos----20G dotnet-sop-tools[]: Unable to bind to https://localhost:5001 on the IPv6 loopback inter...ess'.
Hint: Some lines were ellipsized, use -l to show in full.
[root@centos----20G ~]#

查看日志

sudo journalctl -fu sop.tools.service

有关进一步筛选,使用时间选项(如 --since today--until 1 hour ago)或这些选项的组合可以减少返回的条目数。

sudo journalctl -fu kestrel-helloapp.service --since "2016-10-18" --until "2016-10-18 04:00"

4、部署服务nginx

vi /usr/local/nginx/conf/nginx.conf
server {
    listen        80;
server_name example.com *.example.com;
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;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

这样一个简单的nginx反向代理服务器就配置完毕了,启动并查看运行状态

--重新启动
systemctl restart nginx.service
--查看状态
systemctl status nginx.service
[root@centos----20G ~]# systemctl status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Thu -- :: CST; 4s ago
Process: ExecStop=/bin/kill -s QUIT $MAINPID (code=exited, status=/SUCCESS)
Process: ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf (code=exited, status=/SUCCESS)
Process: ExecStartPre=/usr/local/nginx/sbin/nginx -t (code=exited, status=/SUCCESS)
Main PID: (nginx)
CGroup: /system.slice/nginx.service
├─ nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
└─ nginx: worker process May :: centos----20G systemd[]: Stopped The nginx HTTP and reverse proxy server.
May :: centos----20G systemd[]: Starting The nginx HTTP and reverse proxy server...
May :: centos----20G nginx[]: nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
May :: centos----20G nginx[]: nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
May :: centos----20G systemd[]: Failed to read PID from file /usr/local/nginx/logs/nginx.pid: Invalid argument
May :: centos----20G systemd[]: Started The nginx HTTP and reverse proxy server.

5、再次部署服务

1、上传FTP源码文件,停掉{sop.tools.service}服务。

##--后台程序重新编译生产
systemctl daemon-reload
##--启动服务
systemctl start sop.tools.service
##--停止服务
systemctl stop sop.tools.service
##--重启服务
systemctl restart sop.tools.service
##--查看服务
systemctl status sop.tools.service ##运行程序
cd /root/sop/tools
dotnet Sop.Tools.dll #运行web应用,这里就是web程序运行的类库 ##其他服务原则上不用停止,只停止Sop.tools.service

操作如下

[root@centos-7-06-64-20G ~]# systemctl status sop.tools.service
● sop.tools.service - Example .NET Web API App running on CentOS
Loaded: loaded (/usr/lib/systemd/system/sop.tools.service; disabled; vendor preset: disabled)
Active: inactive (dead) May 22 12:18:40 centos-7-06-64-20G systemd[1]: Started Example .NET Web API App running on CentOS.
May 22 12:18:41 centos-7-06-64-20G dotnet-sop-tools[27432]: info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
May 22 12:18:41 centos-7-06-64-20G dotnet-sop-tools[27432]: User profile is available. Using '/root/.aspnet/DataProtection-Keys' as ke... rest.
May 22 12:18:41 centos-7-06-64-20G dotnet-sop-tools[27432]: Hosting environment: Production
May 22 12:18:41 centos-7-06-64-20G dotnet-sop-tools[27432]: Content root path: /root/sop/tools
May 22 12:18:41 centos-7-06-64-20G dotnet-sop-tools[27432]: Now listening on: http://[::]:5000
May 22 12:18:41 centos-7-06-64-20G dotnet-sop-tools[27432]: Application started. Press Ctrl+C to shut down.
May 22 12:18:50 centos-7-06-64-20G systemd[1]: Stopping Example .NET Web API App running on CentOS...
May 22 12:18:50 centos-7-06-64-20G dotnet-sop-tools[27432]: Application is shutting down...
May 22 12:18:50 centos-7-06-64-20G systemd[1]: Stopped Example .NET Web API App running on CentOS.
Hint: Some lines were ellipsized, use -l to show in full.
[root@centos-7-06-64-20G ~]# systemctl restart sop.tools.service
[root@centos-7-06-64-20G ~]# systemctl status sop.tools.service
● sop.tools.service - Example .NET Web API App running on CentOS
Loaded: loaded (/usr/lib/systemd/system/sop.tools.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2019-05-22 13:20:51 CST; 3s ago
Main PID: 28333 (dotnet)
CGroup: /system.slice/sop.tools.service
└─28333 /usr/bin/dotnet /root/sop/tools/Sop.Tools.dll May 22 13:20:51 centos-7-06-64-20G systemd[1]: Started Example .NET Web API App running on CentOS.
May 22 13:20:51 centos-7-06-64-20G dotnet-sop-tools[28333]: info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
May 22 13:20:51 centos-7-06-64-20G dotnet-sop-tools[28333]: User profile is available. Using '/root/.aspnet/DataProtection-Keys' as ke... rest.
May 22 13:20:52 centos-7-06-64-20G dotnet-sop-tools[28333]: Hosting environment: Production
May 22 13:20:52 centos-7-06-64-20G dotnet-sop-tools[28333]: Content root path: /root/sop/tools
May 22 13:20:52 centos-7-06-64-20G dotnet-sop-tools[28333]: Now listening on: http://[::]:5000
May 22 13:20:52 centos-7-06-64-20G dotnet-sop-tools[28333]: Application started. Press Ctrl+C to shut down.
Hint: Some lines were ellipsized, use -l to show in full.
[root@centos-7-06-64-20G ~]#

  




 四、总结

到这里就结束了

不足:

对CentOS命令不熟悉

对Tengine和Nginx不太熟悉

这里下次查询资料后在做补充此介绍文档。

相关介绍

  1. 部署资料介绍:https://www.vultr.com/docs/how-to-deploy-a-net-core-web-application-on-centos-7
  2. Nginx配置介绍:http://nginx.org/en/docs/
  3. 部署资料介绍:https://www.danielcrabtree.com/blog/481/how-to-setup-asp-net-core-2-1-on-linux-in-under-10-minutes
  4. 部署资料介绍:https://blog.tekspace.io/hosting-asp-net-core-2-1-application-on-centos-7-with-nginx/
  5. CentOS 7 Systemd介绍:http://www.jinbuguo.com/systemd/systemd.service.html
  6. Tengine 官方详细介绍:http://tengine.taobao.org/document_cn/install_cn.html
  7. Tengine相关介绍https://hacpai.com/article/1536585912527
  8. https://docs.microsoft.com/zh-cn/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-2.2
systemctl start sop.tools.service
sop.tools.service