ASP. NET Core Linux Publishing

Source: Internet
Author: User
Tags dotnet

This blog post references the following articles:

1, http://www.cnblogs.com/ants/p/5732337.html

2, http://www.linuxidc.com/Linux/2016-11/137010.htm

broadly similar, just encountered some problems during the release and made some records. Other people may encounter different problems, and can refer to two other articles .

Configuration:
    1. Server: CENTOS7 (Hyper virtual machine)
    2. Related tools: WinSCP (FTP tool), PuTTY
    3. Development tools: vs2017
    4. Related software: Nginx, supervisor
Overview:

Please note that the time of the blog release, is now the 1.0 version of ASP. On Linux, Microsoft officially recommended Nginx as a Web server, monitoring 80 ports, and then forwarded to the ASP. ASP. NET core site with supervisor Guardian.

Get ready:

VS2017 Create a new empty ASP. NET Core project, and then publish the project as a file system to make sure that everything is working properly locally.

First step: Install the centos,.net Core SDK
  • Installing CentOS
  • install. NET Core sdk 
    • Install the dependency   input command first  
       sudo  yum  install  libunwind libicu 

      / strong>

    • Download SDK   address:https://www.microsoft.com/net/download/linux    Select centos7.1, download completed by WINSCP upload to CentOS (note the location of the upload)  

    • Note the downloaded file name and the uploaded directory address.
    • Create folder:  
       sudo  mkdir -P/ Opt/dotnet 

      Uncompressed:

       sudo  tar  zxf dotnet. tar . Gz-c/opt/dotnet 

      Create connection:

    •  sudo  ln -s/opt/dotnet/dotnet/usr/local/bin 

      Input:

       dotnet--info  

       

The installation of this SDK is successful!!

Step two: Upload ASP. NET Core
  • Upload files to/home/yin/wwwroot/with WINSCP.
  • Execute under the Wwwroot folder:
    Dotnet Demoweb.dll

    Note that the assembly name is replaced by its own local assembly name

  • Step Three: Configure Nginx
  • Install Nginx using Source installation method
  • : https://nginx.org/download/nginx-1.12.0.tar.gz Note that the corresponding version number is selected when downloading
  • Execute the following command
  • TAR-ZXVF nginx-1.12.0.tar.gz
    CD nginx-1.12.0
    ./Configuremakesudomakeinstall

    Note if the./configure fails, most are not installed by the compile tool, which executes:

    Yum Install  Make gcc-c++ libtool  OpenSSL openssl-devel

    The Nginx execution path is added to the PATH environment variable, and the Nginx directory should be avoided every time the nginx is started.

  • VI ~/.BASHRC

    Add to

    Export path="/usr/local/nginx/sbin: $PATH"

    Then enter the following command to apply:

    SOURCE ~/.BASHRC

    To modify the Nginx configuration file:

    VI /usr/local/nginx/conf/nginx.conf

    The configuration is as follows:

    server {    a;     / {        proxy_pass http://localhost:5000;        1.1 ;        Proxy_set_header Upgrade $http _upgrade;        Proxy_set_header Connection Keep-alive;        Proxy_set_header Host $host;        Proxy_cache_bypass $http _upgrade;    }}

    Restart Nginx:

    Nginx-s Reload

    Open port number (Administrator action):

    Firewall-cmd--zone=public--add-port=/tcp-permanentsystemctl restartfirewalld

    Perform:

    Dotnet/home/yin/wwwroot/demoweb.dll

    Here you can access the ^.^

Fourth Step: Install Supervisor

We need to monitor the operation of the ASP. We need to install supervisor in order to solve this problem if an exception is required to restart automatically.

  • Download the source code: https://pypi.python.org/packages/7b/17/88adf8cb25f80e2bc0d18e094fcd7ab300632ea00b601cbbbb84c2419eae/ Supervisor-3.3.2.tar.gz
  • Upload to Server, execute command:
    tar zxvf  supervisor-3.3.  2. Tar . GZCD Supervisor-3.3. 2 sudo Install

  • During installation, you may be prompted to: meld3>=0.6.5 error
  • Workaround:
    wget http://dl.fedoraproject.org/pub/epel/7/x86_64/p/python-meld3-0.6.10-1.el7.x86_ 64.rpmsudo rpm-ivh python-meld3-0.6. 1. el7.x86_64.rpm

    Configuration Supervisor:

    mkdir /etc/>/etc/supervisor/supervisord.conf

    Modify Supervisord.conf:

    VI /etc/supervisor/supervisord.conf

    Add the following content:

    = CONF.D/*. conf

    Create configuration file demoweb.conf:

    mkdir CONF.D VI demoweb.conf

    Add the following content:

    [Program:demoweb]command=dotnet demoweb.dll directory=/home/yin/wwwroot/autorestart= true stderr_logfile=/var/log/demoweb.err.logstdout_logfile=/var/log/  Demoweb.out.logenvironment=aspnetcore_environment=Production User=root stopsignal=int

    Run Supervisor:

    Supervisord-c/etc/supervisor/supervisord.conf

To this big announcement into!! Access address

ASP. NET Core Linux Publishing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.