首页 > Web开发 > 详细

Centos 8 简单部署asp.net core 示例项目一

时间:2020-09-22 09:21:22      阅读:64      评论:0      收藏:0      [点我收藏+]

1.创建一个示例项目

技术分享图片

 

 

 

2.发布镜像,然后将文件复制到linux服务器中

将文件复制到/opt下

sudo mv AspStartExmaple /opt/

3.编写管理脚本

启动

#!/bin/sh
# 无交互启动,主要是演示,实际上应该放在/opt下
nohup dotnet /opt/AspStartExmaple/AutoStartExample.dll --urls "http://+80" > /opt/AspStartExmaple/run.log &

# 记录进程Id。
echo $! > /var/run/aspstartexample.pid
~

停止

#!/bin/sh
# 获取之前启动的Id,将其停止
PID=$(cat /var/run/aspstartexample.pid)
kill -15 PID

管理脚本 aspstartexample.service

# 服务的说明
[Unit]
Description=AspStartExmaple
After:network.target

# 服务运行参数的设置
[Service] 

# 后台运行的形式
Type=forking

# 为服务的具体运行命令
ExecStart=/opt/AspStartExmaple/aspstart.sh

# 为服务的重启命令
ExecReload=/opt/AspStartExmaple/reload.sh              

# 为服务的停止命令
ExecStop=/opt/AspStartExmaple/stopasp.sh

# 表示给服务分配独立的临时空间
PrivateTmp=True         

#服务安装的相关设置,可设置为多用户
[Install]               
WantedBy=multi-user.target

4.给与文件执行权限

chmod +x *

5.将文件aspstartexample.service移动至

 sudo cp aspstartexample.service /etc/systemd/system/

开放端口

sudo firewall-cmd --zone=public --add-port=80/tcp --permanent

6.开机启动

 sudo systemctl  enable aspstartexample.service

启动程序

sudo systemctl start  aspstartexample

停止

sudo systemctl stop  aspstartexample

 如果无法启动,可能是因为SLinux的问题,信任该目录

sudo restorecon -rv  /opt/

测试一下

技术分享图片

 

Centos 8 简单部署asp.net core 示例项目一

原文:https://www.cnblogs.com/yeqifeng2288/p/13709640.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!