• linux环境上运行.net core 初探


    1、安装 .net core 环境

    rpm --import https://packages.microsoft.com/keys/microsoft.asc
    sh -c 'echo -e "[packages-microsoft-com-prod] name=packages-microsoft-com-prod baseurl= https://packages.microsoft.com/yumrepos/microsoft-rhel7.3-prod enabled=1 gpgcheck=1 gpgkey=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/

  • 相关阅读:
    列表元素的删,添,复制
    序列的通用操作
    列排(list)排序
    列表(list)
    str的常用操作
    复制/etc/profile至/tmp/目录,用查找替换命令删除/tmp/profile文件中的行首的空白字符;在vim中设置tab缩进为4个字符
    Linux上的文件管理类命令都有那些,其中常用的使用方法及相关示例演示
    总结软连接和硬连接区别,并用实例操作
    文件的元信息有那些,分别表示什么含义,如何查看?如何修改文件的时间戳信息?
    Linux发行版的系统目录名称命名规则以及用途
  • 原文地址:https://www.cnblogs.com/huangjianping/p/8065042.html
Copyright © 2020-2023  润新知