. NET Core cross-platform: the. NET Core project is deployed to linux (Centos7) and corecentos7
1. Opening descriptionA The previous blog briefly explains how to use it. NET Core development of a summary, the address is: (http://www.cnblogs.com/hanyinglong/p/6442148.html), then this blog we on the basis of the previous blog on the code to deploy it under the Linux Centos7. B. on Tuesday this week, that is, March 7, Microsoft released the latest development tool (Visual Studio 2017). After a brief look, it brings a better development experience, it also makes a huge step forward in cross-platform development. NET cross-platform will be more mature. C.. NET Core project is deployed to linux using Jexus. to deploy the. NET Core project to a linux server, you need to prepare the following items (Linux server, Jexus, Database Installation server, and other (Redis ). D. Below we will start to roughly demonstrate how to deploy the. NET Core project to the linux server, test address: http://www.chuxinm.com/2. A brief description of JexusA official website address: http://www.jexus.org/B on Jexus installation, I have also written an article, address is (http://www.cnblogs.com/hanyinglong/p/5456757.html), I wrote this article is installed based on Mono, what does Jexus mean? To install Jexus, you need to install Mono. But now Jexus provides a Mono-free installation solution, which is very convenient. You can try it out. If you have any installation problems, you can search and solve the problem on the official website or elsewhere. C Jexus quick installation (a pair of commands will install Jexus successfully ))
1. Install sudo curl jexus.org/release/install | sh
2. Update: sudo curl jexus.org/release/upgrade | sh
Note: The installation method using this command will install Jexus to the/usr/jexus location.
3.Visual Studio 2015Local release and TestAfter the local system is developed, a needs to be tested in local release. If no error is reported, upload it to the local project structure of server B, as shown in: we will release and deploy this project to Linux. B .1 open cmd, switch to the drive letter of the project, and switch the project to the src root directory (.. /src/project name). Run the command dotnet publish. If no error is reported, the local release is successful. After the command is executed successfully, the path to where the project is published is also displayed. As shown in B .2, go to the release path (under the project root directory/bin/Debug/netcoreapp1.0/publish/) and run the command dotnet ProgrammersLiveShow. dll, according to the prompt access address, Can you test it locally? As shown in: c, we follow the access path (http: // localhost: 5000/). If the access is successful, it proves that there are no problems with local publishing, as shown in: If the login operation function is available, the system login test is conducted to confirm that there are no problems in the release.
4. Configure Jexus and deploy. NET CoreA In the above steps, we will briefly describe some of the system's functions and local release. Now we will briefly describe how to configure Jexus, because jexus has been installed before, we can directly find the installation path in Linux, as shown in Figure B. We can see the jexus installation directory. The Jexus configuration is actually very simple. First, open the website configuration folder siteconf, open the default file and see the configuration shown in. The configuration is described as follows: c, as shown in, deploy the project to the system (/var/www/default/publish). d. First, upload the Locally published file to the server, directly upload the local publish folder to/var/www/default, as shown in e. Because the system itself has been released, therefore, you need to disable the threads running in the background (after the following two commands are executed, the online system will not be accessible). If this is the first release, you do not need to perform this step, the command is as follows: (1): ps-ef | grep ProgrammersLiveShow. dll (2): kill-9 after the PID f is uploaded, the system jumps to publish and runs dotnet ProgrammersLiveShow. dll, which runs successfully and can be accessed, indicates that the release is successful. However, after the release, Xshell cannot be closed. If the release is closed, the default program will be released, we can use the following command to directly set it to run the command in the background: nohup dotnet ProgrammersLiveShow. after the above steps of dll & g are completed, you can use the server domain name and port 80 to access the server. The permission to configure port 80 for external access may exist.
5. Summary of other knowledge pointsA in the Process of frequent system updates, it is critical to back up the system. Execute the following command to back up the system before each release and replacement of the system: tar zcvf/var/www/default/remark/( )h.tar.gz/var/www/default/publish/B Centos7 open port, the implementations of Centos7 and open ports before 7 are inconsistent. B .1 after Centos was upgraded to 7, it was found that iptables could not be used to control the Linuxs port. After google found that Centos 7 replaced the original iptables with firewalld. The following describes how to use firewalld to open the Linux port B .2: firewall-cmd -- zone = public -- add-port = 80/tcp -- permanent -- zone # scope -- add-port = 80/tcp # add a port in the following format: port/communication protocol -- permanent # takes effect permanently. If this parameter is not set, the firewall cannot be restarted and B .3 restarts firewall-cmd -- reload B .4 to Enable firewall: systemctl start firewalld.
Source code of a learning. NET Core permission configuration purchase address: http://www.chuxinm.com/Home/Detail? Id = 8c2e2aff9290446ababf9c5905fa2609
Every day is a little progress
If any problem exists in the article, you are welcome to point it out and I will modify it as soon as possible.