Use lighttpd + mono to run ASP. NET programs on Linux

Source: Internet
Author: User

Yes, that's right. You can use lighttpd (called lighty) + mono to run Linux programs on Linux.
Lighttpd is a lightweight server designed with + static Web page concurrency. when I first set lighttpd to a good configuration, I browsed the static Web page, and the speed was just like flying. it is said that Douban relies on lighttpd to support over 2500 daily visits. lighttpd also supports FastCGI extension to support more dynamic web page programs. I just installed FastCGI of another mono so that lighttpd can run ASP.. NET program.

I. Let's take a look at how to install lighttpd: (one of the features of installing software in Linux is to compile it by yourself, and then make install. After a long time, I feel very comfortable. I am not used to it at the beginning .)
1. Go to http://www.lighttpd.net/#to download the source code. Then, uncompress the code and set lighttpd_srcas the source code directory.
2. Compile and install.
Assume that the installation path is $ install_root. The following uses "/usr/local/lighttpd" as an example.
# Cd $ lighttpd_src
#./Configure -- prefix =/usr/local/lighttpd
First, check the class library dependency to see if all the class libraries are available. if not, check which one is missing and use apt-get In ubuntu. In my openSuSE10.3, click "Install software". Enter the name and install the software. in addition, if openSuSE 10.3 is used, the lighttpd 1.4.18 (my machine) can be installed by default. if it is not too troublesome, install 1.4.19.
# Make
# Sudo make install
At this point, lighttpd is basically installed, and the configuration of lighttpd is similar. lighttpd can be used if you don't want to configure it. it depends on your hobbies. I don't want to get it all done, but it's big.
The startup of lighttpd is:
# $ Install_root/sbin/lighttpd-f $ lighttpd_src/doc/lighttpd. conf
You can copy the conf file to a location that is easy to use. The default value of openSuSE is/etc/lighttpd. conf.
Disable lighttpd: (su permission is required)
# Killall lighttpd
3. Configure the lighttpd. conf file to view the static Web page.
Open the file and click "server.document-root". Then, enter the static Web page. For example, server.doc ument-root ="/home/egmkang/Program/html /".
Then start lighttpd and enter localhost in the browser to check whether it is okay. If you are unfortunate, check what is entered in server. bind = "192.168.1.110", which is generally 127.0.0.1 or localhost.

2. Now, lighttpd can work completely. If you want to run the ASP. NET program, you have to add the mono FastCGI module. Then we will install xsp and configure the conf file.
1. Go to the mono official website to down an xsp. This is required and is generally an rpm package.
When you install this rpm package, you will definitely say that you need to download the package on that page. because I installed it with YaST and did not pay attention to this issue. suSE users can look at this update source
Http://en.opensuse.org/Additional_YaST_Package_Repositories#Mono
2. Configure the lighttpd. conf file.
Add it to the file:

######################################## ########
# Fastcgi-mono-server2
######################################## ########

Var. mono_dir = "/usr /"
Var. mono_shared_dir = "/tmp /"
Var. mono_fcgi_root = server.doc ument-root
Var. mono_fcgi_applications = "/:."

$ HTTP ["host"] = "192.168.1.110 "{
Server.doc ument-root = "/home/egmkang/Program/html /"
Fastcgi. server = (
"" => ((
"Socket" => "/tmp/fastcgi-mono-server ",
"Bin-path" => "/usr/bin/fastcgi-mono-server2 ",
"Bin-environment" => (
"PATH" => "/bin:/usr/bin:" + mono_dir + "bin ",
"LD_LIBRARY_PATH" => mono_dir + "lib :",
"MONO_SHARED_DIR" => mono_shared_dir,
"MONO_FCGI_LOGLEVELS" => "Standard ",
"MONO_FCGI_LOGFILE" => mono_shared_dir + "fastcgi. log ",
"MONO_FCGI_ROOT" => mono_fcgi_root,
"MONO_FCGI_APPLICATIONS" => mono_fcgi_applications
),
# This is the maximum number of instances of the cgi Module.
"Max-procs" => 1,
"Check-local" => "disable"
))
)
Fastcgi. map-extensions = (
". Asmx" => ". aspx ",
". Ashx" => ". aspx ",
". Asax" => ". aspx ",
". Ascx" => ". aspx ",
". Soap" => ". aspx ",
". Rem" => ". aspx ",
". Axd" => ". aspx ",
". Cs" => ". aspx ",
". Config" => ". aspx ",
". Dll" => ". aspx ",
". Castle" => ". castle ",
". Rails" => ". rails"
)
}

Restart lighttpd and place an info under "virtual directory. aspx to see if it can be accessed. If it can, it will be configured. if not, I basically cannot .... khan, this configuration file is on my machine .........
This is my info. aspx screenshot http://images.cnblogs.com/cnblogs_com/egmkang/127872/r_info.aspx.png.

3. You just saw. castle. That's right. I ran the example of MonoRail on this server.
(Note: The program in the MonoRail example has some problems, that is, the Case sensitivity of the file name. I tested the project just now, and it is all about the file name, he did not pay attention when writing his own program. in addition, simply changing the file name's case sensitivity cannot make the website fully run. You have to modify the name in the program. Otherwise, he will access the Index later. vm, and then access index. vm ........)
Copy the file of the built-in MonoRail case to your virtual directory and modify the Web. the config File Name Is web. config ,. the Home folder under the/Views folder is home ,. /Views/home/Index under the folder. vm is index. vm. in Linux, files are case-sensitive and Windows files are case-insensitive. so that project can run normally under Win, not necessarily under Linux.
(I don't know if this step can be omitted, because there is no way to conduct a comparative experiment ....) copy the dll class library files of Castle to the mono installation directory. on my machine, it is/usr/lib/mono/2.0. if it's not on your machine, check out whereis mono.: lol
This is the screenshot: http://images.cnblogs.com/cnblogs_com/egmkang/127872/r_monorail.png
The garden changed the size of the image and looked very fuzzy. You will try again.

The last thing I want to talk about is that lighttpd has good performance. This doesn't need to be nonsense, but it is not easy to debug and optimize it by yourself to achieve the optimal effect. (I am still a dish. it will be used just now: lol) if it is done well, it is also possible to use one or two broken servers to achieve 2500 + W/day of Hits traffic. I don't know how much pv the garden has in a day? It seems that garden uses 8-core CPU ....... (It seems very excited. I thought the pv would be 2500 million a day. Later I thought it was about 500 million. it is hereby revised. thank you, Lao Zhao .)

Author: Shui mu
Source: http://hsapphire.cnblogs.com

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