Linux. Net learning notes (2)

Source: Internet
Author: User
Tags comparable

In the last round, we discussed and learned how to build an environment for. Net Running in the Linux environment. I wonder if you have completed the environment setup? However, no matter whether you use the methods described in the previous round or other methods provided on the Internet to build Linux. in the. NET environment, it is very important to select which version of Linux to use. in other words, it is necessary to ensure that the created environment works properly. The so-called "the Third Army has not moved grain and grass first", all about Linux in the future. net learning experiments are based on this environment. If you cannot connect to this environment, we will use Linux in the future. net learning and experiment will become difficult, or even unable to continue.

Well, let's get down to the truth. When we make a website that we want to publish, we generally mount the website to the server, then, set the public IP address, subnet mask, database connection string, and other parameters of the server. users on the internet can enter the domain name (if any) in the address bar of the browser) or directly enter an IP address to access our website. In this series of events, the server software plays an important role. If the server software cannot work normally, users on the Internet are basically unable to access your website through a browser.

Well, the smart readers must have guessed the content to be discussed and learned in this round. By the way, we will discuss the content of this round: Server Software jexus.

Because jexus has a lot of knowledge to discuss and learn, I will explain jexus in two separate rounds, which explain some concepts and basic configurations of jexus in this round, and demonstration and explanation of advanced features of jexus website configuration in the next round.

In this round, we will discuss the learning content:

(1) conceptual understanding of jexus: What is jexus?

(2) analyze the issues left over during the last round of building the environment: Why should jexus be selected?

(3) basic operations of jexus

(4) Overall jexus Configuration

(5) Introduce and use jexus's process daemon tool JWS. Guard

1. What is jexus?

There are a variety of different types of server software in the world, of course, including the one you wrote to play without publishing, among these many software products, the most famous ones are: IIS, Apache, nginx, Lighttpd, etc. As one of the many server software members, jexus ranks three thousand among the 73rd, that is, the one that has not yet become famous.

Indeed, jexus is not born in the nobility. It does not have a trusted father like IIS to help it modify and promote it, like Apache server software, it is not recognized by the world as the top-level project of the Apache Foundation, nor is it as popular as Lighttpd to possess the noble Community blood. There are only a few lines of jexus introduction in Baidu Encyclopedia (until this article is written). The existence of jexus cannot be found in Wikipedia, many readers are still unfamiliar with jexus. The perception of jexus may be simply "this thing can be run in Linux. net ", even directly unaware of the existence of such a software.

Even though only 72 of Confucius disciples were named sages, who could say 172nd were not Sages? What if 720th disciples are not good? Among the remaining two thousand members, many of them are excellent, but for various reasons they have not been called "sages" by others ". In the past two days, I have talked a lot with the group owner (author of jexus), consulted a lot about jexus, and thanked the author for some of my asp. through the discussion of jexus, I realized that jexus is indeed a good server software, but not very famous, that is, the "outstanding but not famous disciple ".

In one sentence, we will introduce jexus: jexus is a Chinese-made product based on. NET environment is conditional open-source free web server software. Currently, the supported platforms include Linux, FreeBSD, and Dragon core (the old version of the Sea supports windows) one-person dedicated development and long-term maintenance, the official forum is: Linux DOTNET base camp.

Let's take a look at the features of jexus (extracted from the jexus manual)

(1) high-performance ASP. NET processing capability. This is the core function of jexus. Jexus provides excellent support for ASP. NET, regardless of stability, ease of use, concurrency capacity, and parallel processing speed;
(2) fast-CGI is supported. Through fast-CGI, jexus can support all web applications with fast-CGI service functions, including PHP;
(3) Powerful URL rewriting based on regular expressions;
(4) powerful reverse proxy function. Supports multi-target load balancing and seamless integration of local websites and remote websites;
(5) Powerful streaming media support, supports FLV/f4v video file drag playback, and supports Microsoft's smooth streaming media technology;
(6) Support for "server push" technology with corresponding server-side and client-side development interfaces, which is a powerful tool for developing modern Web applications. (Note, this feature has been removed from Version 5.3 and will not be available until it is proven in HTML5 and supported by most browsers)
(7) controllable "ASP. NET pre-Cache", which can maximize the load carrying capacity and response speed of ASP. NET websites;
(8) Support for HTTPS and secure transmission of SSL encrypted data;
(9) provides basic and practical Intrusion Detection Functions to automatically terminate identified illegal requests;
(10) easy to install and deploy, and easy to operate and use.

Jexus embodies the wisdom and painstaking efforts of the author for the current Linux.. NET Server software is developed in a targeted manner. net customized server software, coupled with its rich features, is indeed a good software.


2. Why choose jexus?

In the last round, when we deployed mono, we chose jexus as the server software and left a question worth discussing: Why did we choose jexus as the server software instead of others? Below I will use two main comparisons to show why we chose jexus:

(1) Comparison between Windows and Linux Server Software

In the previous round of articles, I read the messages sent to me by all the readers, many of which are interesting. One of the comments is: ". net Running in Linux is more efficient and stable than in Windows Server 2003. "Then I wondered. net does not run Linux in winserv03? Isn't it comparable to others in their own environment? In addition, I also got a message from the author of jexus: "IIS 6.0 cannot run jexus 4. x in the same physical environment ".


The above two images show a simple Performance Test on iis6.0 and jexus 4.3. It is obvious that jexus 4.3 has better load capacity than IIS 6. Of course, this simple test is far from enough to determine that jexus is more powerful than IIS, which requires more rigorous and systematic tests, in addition, the performance comparison between them must be determined through long-term practical use.

At the same time, I would like to reiterate that "IIS is definitely a server software with excellent performance ", as to why does IIS fail to run jexus (the discussion here is limited to the comparison between the two versions in the figure. We will not discuss the comparison between the new versions of IIS and jexus ), I think the bigger reason is the difference in operating platforms.

IIS runs in windows, while jexus runs in Linux. They run on different platforms. By comparing platform differences, it may be easier to get their differences. Iis6.0's low performance (compared with jexus4.3) is largely due to the drag-down of the Windows system. Why? If you are interested, you can right-click the computer (my computer) and open its service list to see how many services are in the list, how many other services are running? (I have just counted my computer, and there are 178 services in total. 92 are running. This is a common system, of course, there are not so many Server versions ).

How many services can readers recognize? Can you tell clearly why each service is used? I believe that readers should not recognize the number of services that are currently running. Many of these services provide some experience functions for Windows systems. Even if we disable them, they will not have much impact on the system, although these services are dispensable, they will be automatically installed to us when we install the system, and the default boot operation means that the system consumes computing power from the CPU, we need to divide the space from the memory, which will waste the resources of our servers. On the contrary, let's look at Linux. When installing the system, we can customize software packages and services. We can choose to minimize installation or install only the services we need, we can ignore services we don't need. I also remember a teacher who was responsible for server management once said: "For servers running, we hope that the lighter the better, the more simple the services we provide, the better, the fewer services that are enabled, the less error-prone ". When we look back at windows, we will inevitably think: "windows, you are too heavy ".

In addition, it is more important to have a greater impact on Windows performance, that is, the GUI of windows. Graphics Processing consumes a lot of system resources, while windows needs to waste a lot of valuable resources in the server while maintaining its system interface. I have always had this idea: "Linux should not have a graphical interface." Similarly, the server version of the operating system should not have a graphical interface. Regular servers should be shut down in the data center, even though the winserv03 interface is not beautiful at all, it is ugly. Maintaining this interface consumes a lot of system resources, when centos6.4 is installed, if the memory does not have 1 GB, the graphic installation interface cannot start. This shows the amount of resources consumed by the graphic interface. At the same time, if you remotely log on to the server in the data center for management, network problems will also become a bottleneck for graphic interface pushing.

In this way, too many services, coupled with a graphical interface, have wasted a precious amount of system resources before the server is actually put into production. servers with the same physical configuration seem to have the same environment configured, the actual system resources that can be provided to server software are different. It is not surprising that IIS 6.0 cannot run jexus 4.3.

(2) Comparison of. NET Server Software in Linux

In Linux, the running environment is truly the same, which is more comparable than Windows/Linux. In Linux, in addition to mono + jexus, there is also a way to set up the. NET environment, that is, mono + xsp. Xsp is.. Net parsing container, which can. the net program parses and maintains efficient operation, but it has a disadvantage that the processing capability of static resources is quite limited. In a website, most of them are static files such as images, CSS, and JS. There are not many dynamic files. In this case, xsp will expose its weakness. In this case, xsp generally integrates an efficient server software to make up for its shortcomings. Similar to Tomcat + Apache. This is derived from: the establishment of Linux provided on the Internet.. NET is another way for Linux + Apache (nginx) + mono. They both have a plug-in between Apache (nginx) and mono, And the principle is actually the same as xsp.

Here we recommend an article: "Why is jexus more suitable for building enterprise-level ASP Based on Linux/Unix systems. NET platform, this article was written by the author of jexus, which compares the advantages of using jexus in Linux in detail. After reading this article, I believe that the reader will understand why jexus was selected when the environment was set up in the last round.

This is why we choose jexus.


3. jexus operations

After two chapters on jexus, I believe that the reader has a conceptual understanding of jexus. Starting from this chapter, we will perform practical operations on the use of jexus, we also discuss the phenomena generated during operations on jexus to further understand and learn how to use jexus.

The Linux software package has a very good job, that is, the user manuals and help documents for this software often exist in the software itself, such as the man command) "-- Help" and other commands can be used for quick reference. Similarly, for how to use jexus, you can also obtain it through "readme" in the jexus software package.

Let's take a look at something in the jexus directory:

There is nothing in it, including four folders (in blue), six script files (in green), and some other files (in White ). In this section, we will introduce the operations of jexus, which are actually operations and descriptions of jexus scripts.

Jexus provides six operation scripts (for versions earlier than 5.3, 5.3 has integrated all JWS into JWS. /JWS parameters). Their names and functions are:

JWS. start: Start jexus. (If you need to enable jexus, you can add the full path of the script to/etc/rc. local; 5.3 has been changed to: JWS start)
JWS. Restart: restart jexus. If the website name is added as a parameter after the command, it indicates that the specified website is started or restarted. (JWS restart has been changed to JWS in 5.3)
JWS. Stop: Stop jexus. If the website name is added as a parameter after the command, the specified website is stopped. (JWS stop has been changed to JWS stop in 5.3)
JWS. regsvr: register the global assembly required by jexus (this command is only used after jexus is installed or updated, and must be used; JWS regsvr has been changed to in 5.3 ).
State. Start: Start the ASP. NET status service provided by jexus. (This script has been removed from jesux 5.3 and jexus is enabled by default)
State. Stop: Stop the ASP. NET status service provided by jexus. (This script has been removed from jesux 5.3 and jexus is enabled by default)

In addition, the following features are added in 5.3:

JWS status: Check the running status of jexus.

JWS-V: view the jexus version.

The operation method is the same as running a common script./XXX, which has little technical content. It is worth noting that the owner of these footstep files should be a root user and have the operation permission.


4. jexus Configuration

Jexus configuration is divided into two aspects: one is jexus overall configuration (JWS. conf), and the other is website independent configuration (by default, all website configuration files are in the siteconf folder ). The independent configuration of the website can call many advanced features of jexus. We will discuss it later in the next round. In this chapter, we will mainly configure the entire site of jexus. Use VI to open JWS. conf and see what configuration items are in it:

Here, I will explain the functions and precautions of each option:

(1) sitelogdir: This setting must exist and be enabled. This setting sets jexus running log records and website running log records to be stored in this folder. In addition, when the size of the recorded log file reaches a certain level, jexus automatically writes the log to a new log file, all log records will not be written to the same file by append writing.

(2) siteconfigdir: this is also a configuration item that must exist and be enabled. This setting item sets the storage locations configured for each website in jexus, in jexus, the default website configuration is stored in siteconf because the default value is siteconf. In addition, the files stored in this configuration folder can only be website configuration files, other files cannot be stored in this directory (including the backup files of the website configuration file itself), because everything in the Linux system is stored as files, therefore, no matter what suffix you use, it is treated as a common file in Linux.

(3) runtime: This setting item is used to configure the runtime version. Unless you have special requirements to change the runtime version, you generally do not need to modify it.

Let's take a look at some advanced settings. these settings are disabled by default,

(4) llvm: whether to enable the llvm compiler function. When llvm is enabled, the intermediate language compilation can be handed over to the llvm compiler, which can speed up compilation and improve the compiled code performance. However, it is worth noting that not all Linux systems have llvm compilers, and the compilation efficiency of Mono's built-in compilers and the performance of compiled code are not bad. Therefore, if there is no special need, this option can be disabled by default.

(5) HTTPD. processes: In jexus, the default number of worker processes is 1, and the maximum number of concurrent processes for a single process is fixed to 10 thousand. By enabling multiple worker processes, the jexus processing concurrency can be improved, it is easy to start multiple processes. You only need to modify httpd. and restart jexus. However, here are some notes: [1] jexus supports up to four worker processes, so you can enter up to 4 here; [2] If multiple jexus workflow is enabled, pay attention to the session storage method of the website. Modify the config file of the website to modify the session storage method, avoid using the process to save the session; otherwise, the session will not be synchronized, causing unnecessary trouble for the website operation, session storage can be stored by a third party (such as a database or a powerful ASP. net service status saving); [3] jexus Worker Process settings are related to the number of CPU cores on the server and the number of memory. If your CPU has only one core, however, if you enable two processes in your configuration, you can only achieve one fault tolerance effect, and the number of concurrent processes that can be carried will not go up. For details, refer to the article "how to optimize jexus to support high-concurrency requests".

(6) HTTPD. user: I don't know if you have used apache. httpd in Apache. conf has such a setting user = xxx: Apache can be started as a user, and the operation permissions of the user are granted to the Apache process. Similarly, httpd. the role of user is the same as that of user in Apache. You only need to enter the user name of an existing user to httpd. in User, jexus will have the operation permission of this user. What is the purpose? Well, for example, if the website runs and generates some new files (such as static pages), what solutions will readers adopt? Chmod 777? This can be solved, but setting the directory permission to 777 poses a security problem. If there is a solution: the process and some users can perform read and write operations on the directory, other users cannot solve the security problem. Well, right. At this time, httpd. user is useful. We only need to create a directory that can only be read and written by a user and enter the user name in httpd. user.

(7), php-fcgi.set: This function is used to make jexus support PHP, because here. net does not matter much, so I will not introduce it too much here. Readers who need to know about it can refer to this article: "Let jexus v5.1 support PHP operation steps".

(8) certificatefile and certificatekeyfile: This configuration item enables jexus to support SSL. Refer to the article for the usage method: linux + Apache installation and configuration of SSL certificates and How to Make jexus support SSL

In these eight jexus website configurations, there is an ultimate Note: after each configuration, remember to restart jexus, otherwise the configuration just won't take effect !!!


5. jexus process daemon tool JWS. Guard

A running process will inevitably go down for no reason due to various reasons (for example, the website's instantaneous load is too high or the memory is insufficient), and jexus usually has only one consequence: websites that provide external services cannot be accessed. Therefore, we need to ensure that our website can provide uninterrupted access, and the process of a website or process being down is instantaneous, maybe the previous second was still well accessed, and the next second suddenly reported a 404 error, and the process of dropping from the website or process to our manual discovery and restarting the service was long, unless the website has a single point of failure solution, the website is in a black period that cannot be accessed during this long period of time. If the down website is an enterprise website, this will lead to a decline in the credibility of the enterprise; if it is a mall website, it will cause economic and popularity losses; therefore, we need to enable the system to automatically detect the running status of the website, and automatically restart when the process service crashes.

JWS. guard is a Python script, and its working principle is relatively simple: According to the preset value, access the specified port and file once every 10 seconds, run JWS if the website fails to be accessed within 30 seconds. restart to restart the website. Thirty seconds indicates that the website cannot be accessed three times in a row, preventing the website from being mistakenly restarted due to the busy jexus during the detection.

JWS. the use of guard is also relatively simple, as long as the "guard. py and JWS. guard "copies two script files to the jexus working directory (with JWS. start the same directory), and then configure JWS. the default value in guard.

First, copy the two files.


Cp jws. Guard. py/usr/local/jexus/


We have copied the two scripts to the working directory.


Open and edit JWS. Guard with vi

Change host, port, and path to the configuration we need. They represent the host address, port, and check path respectively. Generally, if jexus uses port 80, it can be used directly without modification. If jexus does not use port 80, you only need to modify the port, change to the correct port and save and exit. Generally, the host and path do not need to be modified, and unnecessary modifications are not recommended because JWS is modified. guard must ensure that the modified configuration item is correct, otherwise JWS. guard repeatedly restarts jexus because it cannot access the configured website, causing unnecessary trouble.

After modification, you only need to execute./JWS. Guard to start the jexus process daemon.

We tried to disable jexus.

...... 30 seconds later ......

Jexus again.

Through the JWS. Guard daemon tool, we can easily enable the system to automatically discover that the jexus process is down and quickly restart the process. At the same time, you only need to check the jexus running log to find the problem.

There are three reminders:

(1) If you need to disable the jexus service for more than 30 seconds, run the command before closing jexus. /JWS. guard stsafeguard disables JWS. guard daemon tool to prevent the daemon tool from automatically starting jexus again.

(2). JWS. guard is a script written in Python. When you need to run this tool, make sure that python is installed in the system. You can run Python-V in the check mode, if the Python version information does not appear, it indicates that python is not installed in the system. you can install Python using Yum or other methods before running JWS. guard.

(3) Repeat once. Make sure that the configuration value is correct when JWS. Guard is configured.

The stability of the new jexus version is already very strong, and JWS. Guard can be used for reinforcement.

Okay. Now jexus daemon JWS. Guard has been introduced.

So far, this round of Basic discussions on jexus have been fully explained. I hope that you will have a basic understanding of jexus after reading the articles in this round. At the same time, if you discover any mistakes in this collection, have any comments or suggestions on this article, or have any comments or suggestions on Linux. any comments on the development of net are welcome to leave a message.

In the next round, we will explain in depth the advanced features of jexus: access IP filtering, server cache, URL rewriting, and other functions. At the same time, I also hope that Linux has not been built. net readers can set up the environment, because all the demos in the next round are based on this environment for actual operation. Okay, let's see you next time.

Related Article

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: 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.