centos 7 安装donet core2.0环境

本文档介绍了如何在CentOS 7.0上安装.NET Core 2.0 SDK,并创建Web应用程序。接着详细说明了安装Nginx以及配置反向代理的步骤,以便外部可以通过Nginx访问运行在80端口的Web应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装环境: centOS 7.0

其他环境参照: https://www.microsoft.com/net/download/linux-package-manager/centos/sdk-current

Add the dotnet product feed

Before installing .NET, you’ll need to register the Microsoft key, register the product repository, and install required dependencies. This only needs to be done once per machine.

Open a command prompt and run the following commands:

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

Install the .NET SDK

sudo yum update
sudo yum install libunwind libicu
sudo yum install dotnet-sdk-2.1.200
创建Web应用
cd /usr/local/dotnetLearn
dotnet new razor -o aspnetcoreapp
cd aspnetcoreapp
dotnet run

站点已启动, 此时外面还不能访问,需要使用nginx做代理

安装ngxin
##安装依赖
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

yum install gcc gcc-c++


yum install nginx

修改配置文件
首先查看配置文件位置:

nginx -t

得到配置文件位置在:/etc/nginx/nginx.conf

修改配置文件, 添加反向代理.

upstream apachephp  {
#    server 127.0.0.1:5001; #Apache
 server 127.0.0.1:5000;
}
server {
       listen       80;
       location / {            
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;                       
        proxy_pass  http://apachephp;
           client_max_body_size    1000m; 
       }          
    }

启动nginx

systemctl start nginx
#把Nginx加到系统启动项
systemctl enable nginx

外部直接访问虚拟机80端口即可.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值