分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 教程案例

ASP.NET core 2.1部署到 Centos 7

发布时间:2023-09-06 02:17责任编辑:胡小海关键词:.NET

步骤要点:

一、关闭Linuxselinux:

操作方式:

1.永久关闭:打开/etc/selinux/config文件,设置SELINUX=disabled,注意,不是SELINUXTYPE=disabled(否则重启后无法进入linux)。

2.临时关闭,不用重启:setenforce 0    #设置SELinux为permissive模式

二、安装微软产品密匙及dotnet:

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

再安装asp.net core 2.1:yum -y install dotnet-sdk-2.1

安装完成后,运行:dotnet -verison可以查看是否安装成功。

三、上传项目:

首先在服务器端安装lrzsz工具包,所需命令:yum install lrzsz

安装完成后,用xshell链接到服务器,并切换到所需上传的目录下,运行命令:rz,然后选择所需文件上传即可。

四、测试dotnet及项目文件:

在项目文件目录下,运行 dotnet *****dll,默认启动5000端口,然后在浏览器查看项目运行情况。

五、安装nginx:

curl -o  nginx.rpm http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

rpm -ivh nginx.rpm

yum install nginx

安装完成后,启动nginx:systemctl start nginx 及 systemctl enable nginx

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

systemctl restart firewalld

这时候,还需要配置nginx,打开 /etc/nginx/conf.d/default.conf 文件,修改其server部分,如下:

server { ???listen ??????80; ???#server_name ?localhost; ???#charset koi8-r; ???#access_log ?/var/log/nginx/host.access.log ?main; ????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; ???}}

之后,运行命令:nginx -s reload,重启nginx

最终,项目结果如下:

参考文献:http://www.cnblogs.com/ants/p/5732337.html,在此表示感谢。

ASP.NET core 2.1部署到 Centos 7

原文地址:https://www.cnblogs.com/jizhong/p/9746272.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved