在 CentOS 7(Linux)上部署ASP.NET Core 2.2 Web應用程序(Tengine、Asp.Net Core MVC、Centos 7、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.1810 (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.11.tar.gz 
# wget http://www.openssl.org/source/openssl-1.0.1h.tar.gz
# wget http://www.canonware.com/download/jemalloc/jemalloc-3.6.0.tar.bz2
# wget http://tengine.taobao.org/download/tengine-2.3.0.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: 25 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): libstdc++-devel-4.8.5-36.el7_6.2.x86_64.rpm                                                                      | 1.5 MB  00:00:00     
(2/2): gcc-c++-4.8.5-36.el7_6.2.x86_64.rpm                                                                              | 7.2 MB  00:00:00     
-----------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                           31 MB/s | 8.7 MB  00:00:00     
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-17.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
 ...........................................更新安裝
Installed:
  pcre-devel.x86_64 0:8.32-17.el7                                                                                                              

Complete!
[root@centos001 ~]# yum -y install zlib zlib-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Package zlib-1.2.7-18.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package zlib-devel.x86_64 0:1.2.7-18.el7 will be installed
--> Finished Dependency Resolution
...........................................更新安裝
Installed: zlib-devel.x86_64 0:1.2.7-18.el7 Complete!
[root@centos001 ~]#  yum -y install openssl openssl-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Package 1:openssl-1.0.2k-16.el7_6.1.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
 ...........................................更新安裝
Dependency Installed: keyutils
-libs-devel.x86_64 0:1.5.8-3.el7 krb5-devel.x86_64 0:1.15.1-37.el7_6 libcom_err-devel.x86_64 0:1.42.9-13.el7 libkadm5.x86_64 0:1.15.1-37.el7_6 libselinux-devel.x86_64 0:2.5-14.1.el7 libsepol-devel.x86_64 0:2.5-10.el7 libverto-devel.x86_64 0:0.2.5-4.el7 Complete!

至此,操作結束。依賴包安裝完畢

 3、安裝Tengine,安裝主程序在這里

安裝命令 

下載Tengine-2.3.0主程序,查詢下載安裝包情況

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

解壓安裝包文件  

tar -zxvf tengine-2.3.0.tar.gz

到指定目錄修改安裝配置

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

生成編譯

make
sudo make install

 

具體操作如下

[root@centos001 ~]# cd /usr/local/src/
[root@centos001 src]# wget http://tengine.taobao.org/download/tengine-2.3.0.tar.gz
--2019-05-08 17:21:35--  http://tengine.taobao.org/download/tengine-2.3.0.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|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2389514 (2.3M) [application/octet-stream]
Saving to: ‘tengine-2.3.0.tar.gz’

100%[=====================================================================================================>] 2,389,514   1.30MB/s   in 1.8s   

2019-05-08 17:21:37 (1.30 MB/s) - ‘tengine-2.3.0.tar.gz’ saved [2389514/2389514]

[root@centos001 src]# ls
tengine-2.3.0.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 745 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/7/packages-microsoft-prod.rpm
warning: /var/tmp/rpm-tmp.wBQ0lQ: Header V4 RSA/SHA256 Signature, key ID be1229cf: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:packages-microsoft-prod-1.0-1.el7################################# [100%]
[root@centos001 ~]# sudo yum update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
packages-microsoft-com-prod                                                                                             | 2.9 kB  00:00:00     
packages-microsoft-com-prod/primary_db                                                                                  | 168 kB  00:00:02     
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

 詳細文章看:http://www.jsfhjj.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 10 seconds if the dotnet service crashes:
RestartSec=10
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-7-06-64-20G ~]# systemctl daemon-reload
[root@centos-7-06-64-20G ~]# systemctl start 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: activating (auto-restart) since Thu 2019-05-09 17:33:36 CST; 2s ago
  Process: 15933 ExecStart=/usr/bin/dotnet /root/sop/tools/Sop.Tools.dll (code=exited, status=0/SUCCESS)
 Main PID: 15933 (code=exited, status=0/SUCCESS)
[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 Thu 2019-05-09 17:33:47 CST; 4s ago
 Main PID: 15955 (dotnet)
   CGroup: /system.slice/sop.tools.service
           └─15955 /usr/bin/dotnet /root/sop/tools/Sop.Tools.dll

May 09 17:33:47 centos-7-06-64-20G dotnet-sop-tools[15955]: User profile is available. Using '/root/.aspnet/DataProtection-Keys...rest.
May 09 17:33:48 centos-7-06-64-20G dotnet-sop-tools[15955]: warn: Microsoft.AspNetCore.Server.Kestrel[0]
May 09 17:33:48 centos-7-06-64-20G dotnet-sop-tools[15955]: Unable to bind to http://localhost:5000 on the IPv6 loopback interf...ess'.
May 09 17:33:48 centos-7-06-64-20G dotnet-sop-tools[15955]: Hosting environment: Production
May 09 17:33:48 centos-7-06-64-20G dotnet-sop-tools[15955]: Content root path: /root/sop/tools
May 09 17:33:48 centos-7-06-64-20G dotnet-sop-tools[15955]: Now listening on: http://localhost:5000
May 09 17:33:48 centos-7-06-64-20G dotnet-sop-tools[15955]: Now listening on: https://localhost:5001
May 09 17:33:48 centos-7-06-64-20G dotnet-sop-tools[15955]: Application started. Press Ctrl+C to shut down.
May 09 17:33:48 centos-7-06-64-20G dotnet-sop-tools[15955]: warn: Microsoft.AspNetCore.Server.Kestrel[0]
May 09 17:33:48 centos-7-06-64-20G dotnet-sop-tools[15955]: 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-7-06-64-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-7-06-64-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 2019-05-09 15:06:16 CST; 4s ago
  Process: 12420 ExecStop=/bin/kill -s QUIT $MAINPID (code=exited, status=0/SUCCESS)
  Process: 12425 ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf (code=exited, status=0/SUCCESS)
  Process: 12424 ExecStartPre=/usr/local/nginx/sbin/nginx -t (code=exited, status=0/SUCCESS)
 Main PID: 12428 (nginx)
   CGroup: /system.slice/nginx.service
           ├─12428 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
           └─12429 nginx: worker process

May 09 15:06:16 centos-7-06-64-20G systemd[1]: Stopped The nginx HTTP and reverse proxy server.
May 09 15:06:16 centos-7-06-64-20G systemd[1]: Starting The nginx HTTP and reverse proxy server...
May 09 15:06:16 centos-7-06-64-20G nginx[12424]: nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
May 09 15:06:16 centos-7-06-64-20G nginx[12424]: nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
May 09 15:06:16 centos-7-06-64-20G systemd[1]: Failed to read PID from file /usr/local/nginx/logs/nginx.pid: Invalid argument
May 09 15:06:16 centos-7-06-64-20G systemd[1]: 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
posted @ 2019-04-22 00:00  sopcce  閱讀(280)  評論(2編輯  收藏
最新chease0ldman老人