First, install the. Net Core SDK
Follow the official documentation to install the SDK by executing the following command
Curl HTTPS://PACKAGES.MICROSOFT.COM/KEYS/MICROSOFT.ASC | GPG--dearmor > MICROSOFT.GPG
sudo mv MICROSOFT.GPG/ETC/APT/TRUSTED.GPG.D/MICROSOFT.GPG
sudo sh-c ' echo ' Deb [ARCH=AMD64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main ">/ Etc/apt/sources.list.d/dotnetdev.list '
sudo apt-get install Apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-2.1.103
Second, create a console output program
[Email protected]:/# mkdir codes//1. Create a Codes folder
[Email protected]:/codes# dotnet New Console-o myApp//2. Create a codes project in the Cosole folder specify the project type as the console project location in the MYAPP directory
[Email protected]:/codes/myapp# dotnet run//3. Go to the MYAPP directory.
The following are the template (project) types:
Third, use Nginx Agent to publish MVC Project 1, first build an MVC project
[Email protected]:/codes# dotnet New mvc-o MVC//1. Create an MVC program that specifies the file location under the MVC folder.
[Email protected]:/codes/mvc# dotnet restore//2. Restoring dependencies
[Email protected]:/codes/mvc# dotnet Run//3.
The default listening port is 5000. CTRL + C ends the run.
2. Installing Nginx
sudo apt-get install Nginx
sudo service Ngnix Start services appears in the figure below, indicating that Nginx installation was successful.
Modify the/etc/nginx/sites-available/default file to:
Exit save, and then execute
sudo nginx-t
sudo nginx-c/etc/nginx/nginx.conf
sudo nginx-s reload
In this case, start the project in the MVC project folder, enter the IP in the browser, and if it goes well, the Web interface will appear.
The System.IO.IOException:Failed to bind to address http://[::]:80:address already on use may be reported halfway.
The reason may be to open the Nignx multiple times, execute killall-9 nginx will kill all Nginx, and then restart the Nginx service.
Configuring the. Net Core 2 Environment on Ubuntu16.04