The most comprehensive solution for deploying .NET Core to Linux (CentOS), advanced version (Docker+Nginx or Jexus)
In the first two articles:
The most comprehensive solution for deploying .NET Core to Linux (CentOS), regular articles
The most complete solution for deploying .NET Core to Linux (CentOS), advanced (Supervisor+Nginx)
We have a full understanding of deploying .net core to Linux and can already meet the application requirements. In this article, we will continue to take you in-depth to learn about using Doker+jexus or Nginx to deploy .net core applications.
In the first two articles:
The most complete solution for deploying .NET Core to Linux (CentOS), regular articles
The most complete solution for deploying .NET Core to Linux (CentOS), advanced (Supervisor+Nginx)
We have a full understanding of deploying .net core to linux and can already meet the application requirements. In this article, we will continue to take you to learn more about using Doker+jexus or Nginx to deploy .net core applications.
1. Use Jexus as web server
Jexus is a high-performance WEB server and load balancing gateway server on the Linux platform. It features support for ASP.NET, ASP.NET CORE, and PHP. It also has important functions such as reverse proxy and intrusion detection. It can be said that Jexus is the best cross-platform host server for .NET and .NET CORE. If we think of it as IIS for the Linux platform, this is not an exaggeration, because Jexus is not only very fast, but also has IIS and other Web servers. A high degree of security that the server does not have. At the same time, Jexus Web Server is a domestic software completely independently developed by the Chinese. It is truly “safe, reliable and controllable” and has the key qualities required for the informatization construction of my country’s party and government agencies and important enterprises and institutions.
jexus official website: https://www.jexus.org/
1.1, Jexus installation
The installation of jexus is very simple, execute the following command:
curl https://jexus.org/release/x64/install.sh|sudo sh
Note: Running the installation command requires the operator to have root privileges.
1.2. Configuration and use of Jexus
After the installation is complete, switch to the /usr/jexus directory and modify the default in the /usr/jexus/siteconf directory. The content is as follows:
Note: Because nginx was used in the previous chapter and port 80 was used, I use port 8099 here.
port=8099 #port
hosts=* #domain name span>
AppHost={cmd=dotnet Core50Test.dll; root =/root/app_data/core50test/publish; port=5000}
Next, we restart jexus and execute the following command:
/usr/jexus/jws restart
After the Ok prompt, our application is started.
You can view the execution results by executing the following command:
ps -aux
You can see that our application has been started. Go to the browser and use port 8099 to browse and see the effect.
For more detailed instructions on using jexus, please refer to the official documentan>(uuidgen |sed ‘s/-//g’)
docker build -f Dockerfile -t core50test:${imtag } .
docker stop core50test
docker rm core50test
docker run -dit --restart=always --name core50test - span>p 81:80 core50test:${imtag}
Set execution permissions for the dockerbuild.sh file. The command is as follows:
chmod 777 dockerbuild.sh
When new code is pushed to the git repository, enter the server and execute dockerbuild.sh to quickly update the application.
./dockerbuild.sh
At this point, the introduction to deploying .net core using docker is completed.
2.5, docker common commands
Docker commonly used commands are generally divided into the following categories:
- Docker environment information —
docker [info|version]
- Container life cycle management —
docker [create|exec|run|start|stop|restart|kill|rm|pause|unpause]
- Container operation and maintenance —
docker [ps|inspect|top|attach|wait|export|port|rename|stat]
- Container rootfs command —
docker [commit|cp|diff]
- Mirror warehouse —
docker [login|pull|push|search]
- Local image management —
docker [build|images|rmi|tag|save|import|load]
- Container resource management —
docker [volume|network]
- System log information —
docker [events|history|logs]
Starting from the use of docker commands, the following command structure diagram is sorted out:
To view more detailed commands, you can view the official website or command help
docker --help
3. Summary
Through the introduction of the previous three articles, we have a very comprehensive understanding of the multi-scheme deployment of .net core to Linux, which is sufficient for small teams. Attentive students will notice that although the current solution can implement one-click deployment updates, you still need to log in to the Linux server to execute the corresponding commands.
It shows that this is not the optimal solution, so is there a better solution? For example: after we submit it to the git warehouse, wouldn’t it be more convenient to automatically launch the deployment command?
The answer is yes, we can achieve it with the help of Jenkins. If you are interested, you can research it yourself, or stay tuned for the explanation later. As well as devops implemented based on k8s in large projects. In fact, the principle of k8s implementing devops is similar to the above introduction. It is based on using gitlab’s runner or jenkins to monitor the status of the git warehouse. When the specified branch is found to have changed, the image is packaged, and then the image of the deployment of k8s is automatically replaced. renew. At the same time, k8s implements functions such as elastic scaling and rolling update.
Author|Guosi Software
This article comes from the blog garden, author: Gudao Qingfeng, please indicate the original link when reprinting: https://www.cnblogs.com/88223100/p/The-most-comprehensive-solution-for-deploying-NET-Core -to-Linux-CentOS-Docker_Nginx__Jexus.html
n-for-deploying-NET-Core-to-Linux-CentOS-Docker_Nginx__Jexus.html