Linux. Net learning notes (1)

Source: Internet
Author: User

Running the. NET program in Linux sounds crazy, but it is so promising. Linux, as a server, has no doubt its advantages. It can be said that Unix-like systems (Linux, Unix ......) It is a natural operating system suitable for servers. Its stability, efficiency, and low cost are not comparable to those of windows.

If we don't talk too much about it, let's go directly to our discussion and study topic. Here we recommend several linux.net study sites: Mono China, Linux DOTNET base camp, and jexus web server technology blog.

At the same time, we also recommend Mr. Zhang Shanyou's blog, which contains many articles about Linux. net.

In this round, we will mainly discuss and learn:

1. What is mono?

2. Why mono?

3. How to deploy a. Net runtime environment in Linux

4. What should we pay attention to during deployment and Analysis of Some Key Steps?

1. What is mono?

Regarding mono, I think no matter what I say, it should not be more detailed than the official explanation, or the encyclopedia. Let's simply put, the reason why Java can operate across platforms is that, is dependent on the Java Virtual Machine JVM, and. net can only run in windows, also because. net runtime depends on the Framework's Runtime (Public runtime), if it can be provided in Linux. net operating environment (including CLR), that. net can also run in Linux, Which is mono.

 

2. Why mono?

There are many reasons for using mono. However, I personally think the following is the most important:

(1) as a server, if the same functions can be implemented, Linux is the main tool. Why? I have listed several instances:

First, if the server needs to be patched, as a Windows server, you must restart it after completing the patch, which will affect your business to a certain extent.

Secondly, we often hear that Windows is poisoned, especially as web servers and email servers. We don't know what users will upload to us. On the contrary, however, we rarely hear such a statement about Linux poisoning. This is because there are too many release versions in Linux, and the software compiled between different versions cannot call each other. Therefore, if the Linux virus that can be infected with version A cannot be infected with Version B's Linux, the damage of the virus is greatly reduced.

Furthermore, as a server, we will try our best to make our system lighter, more efficient, and more stable. Linux provides our requirements, we can customize the installation software and services. For some unnecessary services, we can directly not install them (note that they are not directly installed, rather than disabled after installation). On the contrary, if you use Windows, you can install a lot of software and services as soon as possible. No matter you can't use them, install them first. Maybe this allows your server to play more roles, however, we want servers to be single and efficient, rather than all-around.

Finally, Linux has low hardware requirements, which is determined by the rejection of the desktop environment (as a server, we should not install XWindow) and the absence of many unnecessary services, windows seems to be much more expensive, and it may not be able to operate normally if the hardware configuration is low.

(2) Cost considerations:

It is usually deployed in windows. net programs are using "Windows Server version + IIS + MS sqlserver" this is indeed. net, but it is a pity that they all charge fees, the system charge fees, and the database charge. As a large enterprise, thousands of servers, if they all adopt this model, it will be a huge overhead; for small companies, capital is a difficult problem for them, and basically they hope to save it, if there is a payment option that can achieve the same functions and is free of charge, it is too much to say.

If we use mono. net is deployed in Linux. We can use the following combination: "Linux + mono + jexus (Apache/nginx + xsp2) + MySQL (postgersql or other free databases )", all of these are free regardless of whether they are open source (jexus is not open source.

What do you choose as the boss?

 

3. Deployment of the mono Environment

The introduction is nothing more than a discussion on paper, and the actual practice is the final principle. To do a good job, you must first sharpen the tool. to do it, you must first have this environment. Next, we will go to the key link of this round and configure the mono environment.

There are also a lot of posts on Mono environment setup on the Internet, basically with the following two types of Mono environment: the free and non-open-source jexus are used as the mono environment of the server software and Apache (or nginx) as the mono environment of the server software. Readers can choose which environment to choose. If you select the former, you can refer to Mr. Zhang Shanyou's "Install mono 2.10.8 and jexus 6.0 in 32-bit and 64-bit centos 5.0"; readers who select the latter can refer to centos 6.0 to install mono 2.10.8.

Here we will select the former [the reason for selection I plan to put it in the next round to explain].

Select the version, and select the latest version that can be downloaded. (You can download the latest version ):

Operating System: CentOS-6.4-x86_64

Libgdiplus: libgdiplus-2.10.9

Mono: mono-3.0.7

Jexus: jexus-5.2.3 (the latest version here is actually jexus-5.3.0 beta3, but based on stability, I chose the latest stable release)

First, install the system with the hyper-V virtual machine. You can also choose to use the VM or other virtual machines to install the operating system.

After installing the Linux system, we officially set up the mono environment. We uploaded all the required source code packages to Linux.

(1) update the system Yum Update (I will not update it here, because it is the latest version)

(2) install and compile the required mono library through yum

Yum-y install GCC gcc-C ++ bison pkgconfig glib2-devel gettext make libpng-devel libjpeg-devel LibTIFF-devel libexif-devel giflib-devel libX11-devel FreeType-devel fontconfig-devel Cairo-devel
(3) Compile and install libgdiplus

Tar jxf libgdiplus-2.10.9.tar.bz2

CD libgdiplus-2.10.9

./Configure -- prefix =/usr/local/MONO/

Make & make install

Echo "/usr/local/MONO/lib">/etc/lD. So. conf. d/mono. conf

(4) install mono

Because Mono is relatively large, it takes a long time to decompress and compile and install it.

Tar jxf mono-3.0.7.tar.bz2

CD mono-3.0.7

./Configure -- prefix =/usr/local/MONO/

Make

Make install

Ldconfig

Echo Path =/usr/local/MONO/bin: $ PATH >> ~ /. Bash_profile

Source ~ /. Bash_profile

Run "Mono-V". If mono version information is displayed, the compilation and installation are successful.

(5) install jexus

Jexus installation is relatively simple. jexus installation can be divided into two types: new installation and upgrade installation. Because we have a new installation here, we only talk about the new installation part, for upgrade and installation, read the self-contained readme document in jexus, which contains details.

Tar xzf jexus-5.2.3.tar.gz

MV jexus-5.2.3/usr/local/jexus

CD/usr/local/jexus/

./JWS. regsvr

Ln-S/usr/local/MONO // opt/mono

Now, jexus has been installed.

 

Enter "./JWS. Start" to start the server and enter xxxx/info.

 

4. Precautions and explanations for deployment

In the last round, we only talked about how to deploy mono, but did not explain the role of every step in deploying mono. Many readers may not understand what is going on after the deployment, therefore, we will explain the operations of the previous round and understand the important things to be paid attention.

(1) What does the last step mean when libgdiplus is deployed?

When libgdiplus was deployed in the previous collection, we performed step "Echo"/usr/local/MONO/lib ">/etc/lD. so. conf. d/mono. conf ", the role of this step is actually the role of executing ldconfig during mono deployment. Because libgdiplus and mono are not deployed in the default/usr of the system, the system does not search for and read dynamic library files in the folder where we deploy mono by default, in/etc/lD. so. conf. d/folder, manually add the address of the mono dynamic library folder, and then execute ldconfig to allow the system to find our dynamic library file.

(2) It is important to execute ldconfig after Mono is deployed.

After compiling and deploying mono, we will get a large number of dynamic library files to be loaded. These dynamic library files will be used in the next step, so we need to reload the system. (If there is no reload, various problems may occur when jexus is deployed)

(3) After deploying mono, add the bin directory path to the environment variable path.

After installing JDK, You need to register environment variables in the same way.

(4) jexus deployment requires registration.

The jexus deployment process is quite simple. You only need to extract the package and copy the folder to the directory where we want it to be stored. However, after that, we need to register the global assembly (. /JWS. regsvr). This is very important.

(5) Why do I need to add a soft link after jexus registration?

In fact, this soft link will not be written, because the service can run normally after jexus is registered during mono deployment. But this time, after registration, ". /JWS. after "start", the Service does not get up and is executed ". /JWS. stop "the system reports a notfoundxxx (xxx cannot be found ). So I opened a script with VI and noticed the following code:

Obviously, the JWS script contains the mono search path, and the deployed Mono is not in these paths. Therefore, jexus cannot find the file in the desired bin directory, so it cannot start the service or report a notfound. At this time, we only need to be in/opt/MONO/(of course, any one of the paths will work, or you can manually add the mono directory path to a script file) add a soft link and link it to the mono deployment directory. Then, jexus can find the desired file.

Well, now we have to talk about it so much that our Linux. NET environment is basically set up. Readers are eager to try it at this moment. If so, you are welcome to take immediate action. You may wish to know it on paper.

In addition. net has not been in contact for a long time, and there is no effective materials on hand. Therefore, many times we study it by feeling the stones and crossing the river. If there are any mistakes in the course of discussion and learning, you are welcome to give your comments or suggestions.

In the next round, we will discuss the advantages of jexus as a mono-based. NET Server in Linux? Jexus configuration and features, as well as some precautions and tips.

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.