. NET core deployment to Ubuntu

Source: Internet
Author: User

1. Using vs2017 to create an ASP. NET core Web application, choose the 2.1 version of the version installed in Ubuntu:

2. Right-click to publish the project, select File System release:

3. Install vsftpd in Ubuntu (Ubuntu installs vsftpd and connect via xftp) and upload the Publish directory to Ubuntu server via Xftp, or you can publish to Ubuntu directly via FTP, you need to configure VSFTPD, More configuration items, you can refer to: FTP Server VSFTPD configuration detailed

4. Execute dotnet WebApp.dll, then you can open the localhost:5000 in the browser (5000 is the default port, if there is a modification, use the actual port) but now it is not IP access, which requires NGINX implementation

5. Install Nginx by command (equivalent to IIS under Linux)

sudo Install Nginx

Then configure Nginx proxy forwarding, modify the/etc/nginx/sites-available/default, modify the content 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;    }}

Save exit, then reload Nginx

sudo nginx-tsudo nginx-s reload

6. Through the nginx through the IP access, however, after restarting we will find that the site does not boot up, this time we need to supervisor

Installing Supervisor

sudo Install Supervisor

After the installation is complete, create a new configuration file in the/ect/supervisor/confg.d/directory named webapp.conf

Edit the configuration file

VI webapp.conf

Modified to:

[Program:webapp]command=dotnet WebApp.dll #要执行的命令directory=/Dotnetcorewebapp # The directory that the command executes environment=aspnetcore__environment=Production #环境变量user=www-data #进程执行的用户身份stopsignal =Intautostart=true  #是否自动启动autorestart=true  #是否自动重启startsecs= 1 #自动重启间隔stderr_logfile=/var/log/WebApp.err.log #标准错误日志stdout_logfile=/var/log/ WebApp.out.log #标准输出日志

Restart Supervisor

sudo service supervisor Restart

Restart the machine at this time, the IP address can also access the

7. If you are a non-native access IP, you need to add port 80 to the firewall exception

sudo /tcp

. NET core deployment to Ubuntu

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.