I haven’t touched .net for almost two months, but I use Linux every day, so I want to try running my favorite .net application on Linux.
Install CentOS
##Install .Net core for Linux<span style="font-size: medium;"></span>
Create Asp.net Core application<span style="font-size: medium;"></span>
Install Nginx<span style="font-size: medium;"></span>
Configure Nginx proxy<span style="font-size: medium;"></span>
1,<span style="font-size: medium;"></span>Install CentOS system<span style="font-size: medium;"></span>
This online tutorial has too many filters. <span style="font-size: medium;"></span>
2. Install the cross-platform .NET Core SDK for CentOS7<span style="font-size: medium;"></span>
sudo yum update
sudo yum install libunwind libicu
sudo yum install dotnet-sdk-2.0.0
##dotnet --infocan confirm Is the installation successful
#3. Create an Asp.net Core application
<span style="font-size: medium;"></span>
dotnet new web<span style="font-size: medium;"></span>
Due to the need for external access to the virtual machine, the default localhost settings must be modified:<span style="font-size: medium;"></span>
vi Program.cs<span style="font-size: medium;"></span>
Add UseUrls("http://*:5000")<span style="font-size: medium;"></span>
## Publish and test
<span style="font-size: medium;"></span>dotnet publish –c release
<span style="font-size: medium;"></span>dotnet TestAspnetCore.dll
<span style="font-size: medium;"></span>
Key points: Setting up the firewall
sudo firewall-cmd --permanent --zone=public --add-service=http sudo firewall-cmd --permanent --zone=public --add-service=https sudo firewall-cmd --permanent --zone=public --add-port=5000/tcp
sudo firewall-cmd --reload
##Virtual machine external access confirmation
4, install Nginx
<span style="font-size: medium;"></span>sudo yum install epel-release
<span style="font-size: medium;"></span>
sudo yum install nginx
<span style="font-size: medium;"></span>
nginx –v View version
<span style="font-size: medium;"></span>
Find the IP address of Linux and start the Nginx service
<span style="font-size: medium;"></span>
##Virtual machine External access addressNote: If this page cannot be displayed, it is likely that the firewall is not set. <span style="font-size: medium;"></span>
5, configure Nginx proxy
<span style="font-size: medium;"></span>
nginx detailed settings to be continued
The above is the detailed content of Detailed graphic and text explanation of Asp.net Core application deployment on Linux. For more information, please follow other related articles on the PHP Chinese website!