Set up the asp.net platform in Linux using Apache + mono + xsp

Source: Internet
Author: User
Recently, a project needs to be used to build a web server in linux. Although PHP is simple, Microsoft asp.net, therefore, we try our best to build a platform to support the release of asp.net web pages in linux. I have read a variety of materials and summarized them as follows: core: using the open source project mono to assist the linux kernel to build a new project needs to be used to build a web server under linux. Although PHP is simple and easy to use, however, Microsoft asp.net, which has been viewed for a while, tries its best to build a platform to support the release of the asp.net webpage in linux. I have read various materials and summarized them as follows:

Core: use the open-source mono project to assist the Linux kernel to build a platform supporting asp.net

1. First, we need to download the following installation package:

Apache (powerful open source software for web servers. here we only need its httpd component)



Mod-mono (truly implementing the mono module that supports files such as. aspx)

Xsp (lightweight web server. here we only use it to internally support mod-mono-server modules)

Mono (basic installation of open-source projects)

: Mono, mod-mono, xsp:
Http://ftp.novell.com/pub/mono/sources/

Http://ftp.novell.com/pub/mono/sources-stable/

Apache: http://httpd.apache.org/download.cgi

2. install the software package in sequence:

Apache:

./Configure

Make

Make install

Mono:

./Configure

Make

Make install

Note: The following problems may occur after you execute./configure:

(1) error: bison is not installed

Solution: directly install bison through apt-get install. if not, download a bison software package online and manually execute./configure; make install.

(2) error: gettext is not supported

Solution: update the source to the debian source of HKUST, and then directly use apt-get install.

The make command takes 10 minutes to be executed. wait patiently...

Xsp:

./Configure -- prefix =/usr

Make

Make install

Mod-mono:

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

Make

Make install

3. configure httpd. conf

After the above software package is installed, it does not mean that our platform is ready. we also need to modify the apache configuration file httpd. conf.

Vim/usr/local/apache2/conf/httpd. conf

(1) ServerName

Modify the IP address of a web page. As a test, simply set the address of the cost machine:

ServerName local IP address: 80

(2) webpage access permissions

To allow other machines to access the forthcoming Web page, we need Change Deny from all to Allow from all to obtain the maximum permission. Of course, if security is taken into account, you can set it separately. for details, refer to the final references in the article.

(3) load apache into the mod-mono module

Add the following statement at the beginning of the configuration file to make apache load the mod-mono module:

Include/usr/local/apache2/conf/mod_mono.conf

(4) custom asp.net applications

Add the following statement (# followed by a comment) to the end of the configuration file ):


MonoAutoApplication disabled # the following statement is to manually set the mono application. Therefore, the automatic mono application function must be disabled.
AddHandler mono. aspx. ascx. asax. ashx. config. cs. asmx. axd # add the file types to be recognized by mono. you can see that these are common file types in asp.net.
Alias/test "/usr/lib/xsp/test" # configure a virtual directory
MonoApplications "/test:/usr/lib/xsp/test" # configure the asp.net application corresponding to the preceding virtual directory. here, we use the instance webpage code that comes with xsp.
MonoServerPath/usr/bin/mod-mono-server2 # in fact apache can support asp.net is implemented by a server called mod-mono-server, here is the version of mod-mono-server (mod-mono-server only supports asp.net, mod-mono-server2 supports asp.net 2.0)
MonoPath test "/usr/lib/mono/2.0:/usr/lib/xsp/2.0" # tell apache the path of the above mod-mono-server2
# Configure the above application
MonoSetServerAlias test
SetHandler mono


Now we have written the httpd. conf configuration file and enabled apache:

Cd/usr/local/apache2/bin

./Apachectl start

In the browser address bar, enter:

Http: // local IP address/test

If you can see the web page, congratulations, the first step is successful...

Why is the first step successful? Step 2? The answer is: yes

When we try to click menu or gridview on the webpage, we will find that the webpage cannot find gdiplus. dll error!

This is because the webpage in the xsp example needs to use a dynamic link library file gdiplus. dll under window, but of course we do not have linux! Don't worry. we can add the corresponding. so file in linux as follows:

(1) find/-name libgdiplus. so

Libgdiplus found. the so file is located in the directory/usr/local/lib/, so we need to write this path to the system's ld. so. conf configuration file. Otherwise, the system kernel will not find this dynamic link library file even if it exists.

(2) add a line to vim/etc/ld. so. conf: include/usr/local/lib/libgdiplus. so

(3) run the ldconfig command to add the new dynamic link library file to the ld. so. cache so that mono can call

(4) verification: If you enter the command ldconfig-p | grep libgdiplus. so, the configuration is successful. Click menu or gridview again, and the problem is fixed!

4. add your own asp.net website

The above xsp example succeeded. how can we add our own asp.net website? In the same way as above, you only need to add code similar to the following in httpd. conf:

MonoAutoApplication disabled
AddHandler mono. aspx. ascx. asax. ashx. config. cs. asmx. axd
Alias/mypage "/home/fjj/mypages"
MonoApplications "/mypage:/home/fjj/mypages"
MonoServerPath/usr/bin/mod-mono-server2
MonoPath test "/usr/lib/mono/2.0:/usr/lib/xsp/2.0"

MonoSetServerAlias test
SetHandler mono


/Home/fjj/mypages is the root directory of your website, and/mypage is the virtual directory. After configuration, enter in the browser:

Http: // server IP address/mypage, you can see your own asp.net website published on linux!

Last Note !!

1. if a Permission error occurs during Website access, you can try to modify the file access permission through chmod on the server.

2. because the configuration file web. config is required for asp.net website development, it is essential to add a web. config file for linux to support some dynamic controls in asp.net (such as updatepanel! My practice is to use vs2008 in windows to develop a website and copy the entire project to linux for release. although it is a bit stupid, it can successfully display dynamic web pages!
 
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.