Jexus Web server deployment in the ubuntu16.04-x64 system. Speculation triggered by Netcore and port analysis!

Source: Internet
Author: User
Tags dotnet

Do you have such a complaint?

There is not a week to update the blog, simply say what to do it, mainly the company to arrange docking the interface of a large company, the number of interfaces will be about 10, after docking also need to add to the business system and the app side, so still need to spend some time; the business needs are scheduled to go live in the last week of June, The whole 3 weeks of time, I am a person responsible, because before this to take another company interface, I have set up the overall architecture and provide to the app-side interface, so the main or docking a company interface, as for the details of the changes to the back-end system, the tone data format should be almost , I developed the proficiency of a week time basically can be done, the rest of the time to test, drink tea, study; Due to the interface side description of the document is not complete, the interface is almost every technology responsible for one or two interfaces (yes this is the big company, the division is so thin), and have doubts through the QQ consultation slow response (perhaps others big company people is busy), so to the first week of Friday, From the app test results and docking interface almost all of the situation is still good (my way docking an interface embedded into the business, so you can directly take the app test), who knows the second week, that is, this week in Tuesday, I was testing a number of people under the order of the exception, and then contact each other, The results were told that the docking of the next single interface is not up-to-date, but in addition to several other interfaces are the latest, the latest in the next single interface we wait a while to go online, and so on-line in the docking bar; come at this time I can only no words (who call you are big company), is a waste of my butt

Pre-deployment preparation

Come here to get started, first to prepare the Ubuntu system (I will write a separate article on how to install Ubuntu in the ORACLEVM and precautions), Here I am the 16.04-x64 version, why I focus on the version number, because I download the latest Jexus package on the official website, altogether not run up, later in the good friends brother found an address, after the installation of the trial run is also the same mark is the latest version, but the back with a 64-bit mark, this is a sad reminder of the day;

We also need a. Netcore program, in order to test the convenience I created here is an API program, and the API action inside this modified under:

1 [HttpGet] 2          Public ienumerable<string> Get ()3        {4             return New string [] {$" This site is: {request.host.host}:{request.host.port}"  }; 5         }

Output the IP and port corresponding to the current application, because in the back for better testing and distinguishing, here is also a simple modification of the code in the next Program.cs, also for the convenience of testing:

1   Public Static voidMain (string[] args)2         {3             varBuilder =NewWebhostbuilder ()4                 . Usekestrel ();5             //parameter Specify port6Builder = args. Length >0? Builder. Useurls (args[0]): Builder;7             varHost =Builder. Usecontentroot (Directory.GetCurrentDirectory ())8                   . Useiisintegration ()9. Usestartup<startup>()Ten                   . Useapplicationinsights () One                   . Build (); A host. Run (); -}

After you change the code, you need to build a run package, how to generate this is not said, interested friends can go to see here asp.netcore1.1 version of the Project.json, so as to generate cross-platform packages , and then in a variety of ways to upload the package to the virtual machine, Here I pass through the way of sharing the directory, if there are friends need to have a chance to share it;

The rest is in Ubuntu using the Jexus Web Server service, for my virtual machine space, here I am operating in TMP, the main following steps to open the terminal:

1. cd/tmp (Enter temp directory)

2. wget linuxdot.net/down/jexus-5.8.2-x64.tar.gz (download Jexus file pack)

3. Tar zxvf jexus-5.8.2-x64.tar.gz (extract to current directory, no installation required)

4. chmod o+w/tmp/jexus/siteconf (in order to conveniently set the Siteconf configuration folder in the Jexus folder can be directly manipulated)

5. chmod o+w/tmp/jexus/siteconf/default (Setting the default configuration defaults file can be modified directly by opening the file: I do not like to change by command, only this step)

6. CD Jexus (enter the Jexus directory Note: Because if you follow my steps, so you can go directly to the Jexus directory, the actual Jexus directory in Cd/tmp/jexus)

7../jws Start (test Jexus whether it is working properly, as I write a blog when the first execution of this command returns the result is: Failure, because I do not use root authority to execute the command, change to root to execute the command on the line, how root after the opportunity to speak again)

Jexus Web server begins deployment. Netcore

First directly by clicking on the folder to enter the following directory (you can also access through the terminal, personal preferences convenient):/tmp/jexus/siteconf; can see the name of the file that asked the default, this file is not root-readable at the time of installation, Since we use the command above: chmod O+w/tmp/jexus/siteconf/default set the user to run other permissions can modify the content, so here I directly change, other information temporarily do not change, only need to increase the Apphost node:

1 port=2 root=//var/www/default3 hosts=*    #OR your.com, *. your.com4#增加apphost节点 5 apphost={cmdline=dotnet/home/wangrudong003/ Netcore/publish01/t_jexus.dll; APPROOT=/HOME/WANGRUDONG003/NETCORE/PUBLISH01; port=

Add several property descriptions for the Apphost node:

CmdLine: Execute the command (be familiar with a little. Netcore running friends may know that. Netcore run the command can be like this: dotnet Xxx.dll so can run up the program, the same can be seen as the same, but need to specify the application specific directory, here my is/ HOME/WANGRUDONG003/NETCORE/PUBLISH01)
AppRoot: Represents the directory of the application, here is my/home/wangrudong003/netcore/publish01
Port: Listening ports;

Jexus Attention points (you can go here to learn more about: https://www.linuxdot.net/bbsfile-3084):
PORT=80: means to access our /home/wangrudong003/netcore/publish01/t_jexus.dll program by listening to port 80 via Jexus
root=//var/www/default: The specified virtual directory

The last root permission goes into the Cd/tmp/jesux directory and then opens the service:./jws start; If nothing happens, you can see the following information:

And then we come through 80 ports to access the following our deployed interface (here my Ubuntu server IP is 172.16.9.66): Http://172.16.9.66/api/values, Access succeeded:

Analyze if the port in the Apphost configuration works

There's a test we've seen through 80 ports to access our interface site, now we use the Linux command to view the server on the listening port, view the TCP Listening Port command: sudo netstat-lntp , can be cast

By the figure can see the Jexus service listening to the 80 port, dotnet command execution of 5000 port, in order to better test the role of Apphost port, we need to change the default file port 5000 port to 5001来 test, change the configuration after:

1 apphost={cmdline=dotnet/home/wangrudong003/netcore/publish01/t_jexus.dll; APPROOT=/HOME/WANGRUDONG003/NETCORE/PUBLISH01; port=5001}

You will then need to restart the Jexus service via the following command: ./jws Restart :

After restarting, we also visited: Http://172.16.9.66/api/values, this time will not be able to access the interface:

Although our Jexus server is OK, but the interface is inaccessible, let's take a look at the listening port:

Port Graph Comparison Analysis

This compares to the previous port, can find dotnet execution or 5000 port, and we modify the configuration file port:5001 can not correspond, this is a bit strange, this can let us be bold to guess Jexus this port is not set the effect , and the last 5000 port should be the default port that dotnet comes with;

Questions

However, let us strange is, if the 5000 port operation is not a problem, then why Jexus released the 80 port can not access API interface, we come to the bold guess, is not because we set the Jexus port:5001 port is also true monitoring of the 5000 does not correspond to the cause? In order to test the configuration information for the next apphost we modified:

Apphost={cmdline=dotnet/home/wangrudong003/netcore/publish01/t_jexus.dll http://127.0.0.1:5001; APPROOT=/HOME/WANGRUDONG003/NETCORE/PUBLISH01; PORT=5001}

This time we follow the Netcore command format: dotnet Xxx.dll http://127.0.0.1:5001 to set the Netcore listening port, which is why I modified the Program.cs code in the beginning of the reason, Everything in order to test conjecture; After the same modification, we execute the Jexus Service command:./jws restart; command execution OK there, first to access the next 80 port interface:

At this point can normally access the interface, then the best thing to verify is to look at the listening port:

Analysis of the second and third port graphs

Through the above third-party diagram can see the Netcore program is now bound to 5001 port, this time by the Jexus open port 80 also can access the interface of our interfaces, That means that the port:5001 in the Apphost node in the Jexus Defaut file must be consistent with the port that the Dotnetcore itself listens to, yes, if the Jexus port is 8080, then the Netcore listener port must be 8080, So that we can access the address through the Jexus open to the normal visit; Good to here this article to share the end of the article, I hope to bring you a good help, but also hope that we have a lot of praise recommended , thank you!!!

Jexus Web server deployment in the ubuntu16.04-x64 system. Speculation triggered by Netcore and port analysis!

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.