linux环境上运行.net core 初探

1、安装 .net core 环境

rpm --import https://packages.microsoft.com/keys/microsoft.asc
sh -c 'echo -e "[packages-microsoft-com-prod]\nname=packages-microsoft-com-prod \nbaseurl= https://packages.microsoft.com/yumrepos/microsoft-rhel7.3-prod\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/dotnetdev.repo'
yum update
yum install libunwind libicu
yum install dotnet-sdk-2.0.2

2、运行.net core

dotnet new console -o myApp
cd myApp
dotnet run

 3、运行asp.net core程序

需要安装nginx,具体操作见:https://www.cnblogs.com/taiyonghai/p/6728707.html

查看nigix是否运行:

[root@localhost ~]# ps -ef |grep nginx
root     13159     1  0 15:28 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody   13160 13159  0 15:28 ?        00:00:00 nginx: worker process
root     13251 13223  0 15:32 pts/1    00:00:00 grep --color=auto nginx
[root@localhost ~]# netstat -tlnup|grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      13159/nginx: master 

配置 nginx.conf

[root@localhost nginx]# vi /usr/local/nginx/conf/nginx.conf
#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  192.168.2.118;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            #root   html;
            #index  index.html index.htm;
            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;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

4,、启动aspnetcore程序

5、在宿主机上访问:http://192.168.2.118/

 

转载于:https://www.cnblogs.com/huangjianping/p/8065042.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值