步骤要点:一、关闭Linuxselinux:操作方式:1.永久关闭:打开/etc/selinux/config文件,设置SELINUX=disabled,注意,不是SELINUXTYPE=disabled(否则重启后无法进入linux)。2.临时关闭,不用重启:setenforce ...

步骤要点:
一、关闭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


基础教程推荐
- Apache CarbonData 1.0.0发布及其新特性介绍 2023-09-11
- 为Win2003服务器打造铜墙铁壁的方法步骤 2022-09-01
- 通过StatefulSet部署有状态服务应用实现方式 2022-10-01
- windows环境下apache-apollo服务器搭建 2023-09-10
- Docker容器操作方法详解 2022-11-13
- P3 利用Vulnhub复现漏洞 - Apache SSI 远程命令执行漏洞 2023-09-10
- Apache Kafka 2.5 稳定版发布,新特性抢先看 2023-09-11
- Centos7 nginx的安装以及开机自启动的设置 2023-09-22
- RFO SIG之openEuler AWS AMI 制作详解 2022-12-28
- Centos 安装Django2.1 2023-09-24