zoukankan      html  css  js  c++  java
  • Linux 部署 ASP.NET Core 的一些问题记录

    异常错误:

    image

    关闭 IP6

    #修改
    vi /etc/sysctl.conf
    # 添加如下三条设置
       net.ipv6.conf.all.disable_ipv6 = 1
       net.ipv6.conf.default.disable_ipv6 = 1
       net.ipv6.conf.lo.disable_ipv6 = 1
    # 执行
      sudo sysctl -p
    # 查看状态( 显示应该是1)
    cat /proc/sys/net/ipv6/conf/all/disable_ipv6

    貌似没有啥用,后面只能通配符 *:5000 端口就好了(默认监听本地 localhost:5000 ,但是不建议这么做,最好是监听本地,外层 nginx 代理下配置灵活些)

    var host = new WebHostBuilder()
               .UseKestrel()
               .UseContentRoot(Directory.GetCurrentDirectory())
               .UseIISIntegration()
               .UseStartup<Startup>()
               .UseUrls("http://*:5000")
               .Build();

    查看占用某端口的程序
    #查看已经连接的服务端口(ESTABLISHED)
    netstat -a
    #查看所有的服务端口(LISTEN,ESTABLISHED)
    netstat -ap
    #查看8080端口,则可以结合grep命令:
    netstat -ap | grep 8080
    #查看8888端口
    lsof -i:8888
    #停止使用这个端口的程序
    kill +对应的pid即可

    # MAC 配置 dotnet 环境
    brew update
    brew install openssl
    mkdir -p /usr/local/lib
    ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
    ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
    install .NET Core 1.1

    #工具的选择
    Visual Studio Code
    JetBrains Rider

    #启动爬虫
    curl http://localhost:6800/schedule.json -d project=stockhq -d spider=stock_hq_jrj_spider

    #nginx
    sudo apt-get install nginx
    sudo service nginx start
    sudo service nginx restart

    vi /etc/nginx/nginx.conf

    server {
    listen 80;
    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;
    }
    }

    #supervisor

    sudo apt-get install supervisor
    cd /etc/supervisor/conf.d/
    touch stockhq.conf

    [program:stockhq]
    command=dotnet stockhq-web.dll
    directory=/opt/stockhq-web/
    autostart=true
    autorestart=true
    stderr_logfile=/var/log/stockhq.err.log
    stdout_logfile=/var/log/stockhq.out.log

    #重启服务

    sudo service supervisor stop
    sudo service supervisor start

    #查看日志
    sudo tail -f /var/log/supervisor/supervisord.log
    tail -f /var/log/stockhq.out.log

    #Cope 文件
    dotnet publish
    scp -r //Users/Irving/Desktop/python/irving/stockhq-web/bin/Debug/netcoreapp1.1/publish/ root@120.26.40.126:/opt/stockhq-web/

    REFER:
    https://docs.microsoft.com/zh-cn/aspnet/core/publishing/linuxproduction
    https://github.com/aspnet/Docs/blob/e9c1419175c4dd7e152df3746ba1df5935aaafd5/aspnetcore/publishing/linuxproduction.md
    https://www.microsoft.com/net/core#linuxubuntu
    https://www.microsoft.com/net/core#macos
    http://www.cnblogs.com/cmt/p/5504731.html

  • 相关阅读:
    70.BOM
    69.捕获错误try catch
    68.键盘事件
    523. Continuous Subarray Sum
    901. Online Stock Span
    547. Friend Circles
    162. Find Peak Element
    1008. Construct Binary Search Tree from Preorder Traversal
    889. Construct Binary Tree from Preorder and Postorder Traversal
    106. Construct Binary Tree from Inorder and Postorder Traversal
  • 原文地址:https://www.cnblogs.com/Irving/p/6542675.html
Copyright © 2011-2022 走看看