Use mono and jexus to build ASP. NET (MVC) Web server in Ubuntu

Source: Internet
Author: User

Recently, an ASP. NET web server has been built on Ubuntu, and many problems have been encountered. Sort out your ideas for future use.

Build Environment and supporting software

Ubuntu: 11.10
Mono: 3.0.6 (http://download.mono-project.com/sources/mono/mono-3.0.6.tar.bz2) for stability considerations, it is recommended not to use other versions later than this version.
Jexus: 5.0 (http://www.linuxdot.net/down/jexus-5.0.1.tar.gz)

 

Install mono

 
CD/Downloadswget http:// Download.mono-project.com/sources/mono/mono-3.0.6.tar.bz2
Tar-jxvf mono-3.0.6.tar.bz2
CD mono-3.0.6
./Configure -- prefix =/usr/local
Make
Make install

Step 1: Go to the target folder of the downloaded file. You can choose the folder according to your habits. Here, use the system downloads folder.
Step 2: Use the download command to download the mono source code.HTTP:// Configure.
Step 3: decompress and modify the file in the target folder. Different types of decompressed files are different. The file extraction parameter in the tar.bz2 format is-jxvf.
Step 4: After the file is decompressed, go to the directory.
Step 5: Configure is a mono installation configuration file. Here we mainly configure the installation path. In the next jexus installation, You need to configure the mono installation path. The default installation path of jexus is/usr/local/mono. Therefore, we recommend setting it to/usr/local.
Step 5: compile.
Step 6: Install.

NOTE: If other versions of mono are installed in the system, you need to uninstall the revised version of Mono first. The uninstall method is to enter the installation directory, and then run the uninstall command to uninstall it. You can also view the version number of Mono through mono-V (case sensitive.

 
#UninstallCD/usr/local/Monomake uninstall#View version numberMono-V
Install jexus
 #  go to the download directory  Cd/usr/ loacal  #  download file  wget http://www.linuxdot.net/down/jexus-5.0.1  .tar.gz  #  decompress the file  tar-zxvf jexus-5.0  .tar.gz  #  enter the jexus folder   Cd jexus  #  Elevation of Privilege (root permission is required for operations involving jexus)   sudo su  #  Registration . /JWS. regsvr 

Jexus is a tool that can be decompressed.ProgramSo we can select the installation path when downloading. Of course, we can also download it to a dedicated download directory. decompress the package and go to the directory to be installed in the MV.
Operations involving jexus include registration service (regsvr), start service (start), stop service (STOP), and restart. All these operations require the root permission.
After registering the service, jexus generates a default site and uses the following address to check whether the service is started (http: // 120.0.0.1/INFO)

The jexus site configuration file is under the siteconf folder under the installation directory, and each site corresponds to a directory file. The system has a default configuration. In this file, we can find and modify the configuration information such as the root directory and start address of the site. Default: the default website root directory is in/var/www/default (Note: jexus does not automatically create the default directory, which must be created manually .)

Upload MVC website files

To upload website files, you must enable the FTP service. vsftpd is used here. The detailed tutorial is not described here.
Compared with common webform websites, it is relatively difficult to configure MVC websites. It mainly involves collection of some MVC class libraries. The reason why mono 3.0.6 and later versions are used is that more DLL files need to be manually added in earlier versions, here I have sorted out some library files that mvc3 needs to call. The following is a list of library files:

System. Web. helpers. dll 1.0System. Web. MVC. dll3.0System. Web. Razor. dll1.0System. Web. webpages. dll2.0System. Web. webpages. Razor. dll1.0

Put these files in the bin directory of the website and upload them to the root directory of the website. Note that mvc3 requires system. web. webpages. dll2.0 or later versions, and the dll version in the window is 1.0. If you copy the DLL directly from the window, a dependency error will occur.

The next important step is to modify the website configuration file web. config.

 

 <?  XML version = "1.0"  ?>  <! --  For more information on how to configure your ASP. NET application, please visithttp: // go.microsoft.com/fwlink /? Linkid = 152368 -->  <  Configuration  >    <  Appsettings  >      <  Add  Key  = "Clientvalidationenabled"  Value  = "True"  />       <  Add  Key = "Unobtrusivejavascriptenabled"  Value  = "True"  />     </  Appsettings  >        <  System. Web  >      <  Compilation  Debug  = "True"  Targetframework  = "4.0" >        <  Assemblies  >          <  Add  Assembly  = "System. Web. Export actions, version = 4.0.0.0, culture = neutral, publickeytoken = 31bf3856ad364e35"   />          <  Add  Assembly  = "System. Web. helpers, version = 1.0.0.0, culture = neutral, publickeytoken = 31bf3856ad364e35"   />         <  Add  Assembly  = "System. Web. Routing, version = 4.0.0.0, culture = neutral, publickeytoken = 31bf3856ad364e35"   />          <  Add  Assembly  = "System. Web. MVC, version = 3.0.0.0, culture = neutral, publickeytoken = 31bf3856ad364e35"   />          <  Add  Assembly = "System. Web. webpages, version = 1.0.0.0, culture = neutral, publickeytoken = 31bf3856ad364e35"   />        </  Assemblies  >      </  Compilation  >      <  Globalization  Cultrue  = "ZH-CN"  Uicultrue  = "En-us"  />     <  Authentication  Mode  = "Forms"  >        <  Forms  Loginurl  = "~ /Account/logon"  Timeout  = "2880"   />      </  Authentication  >      <  Pages >        <  Namespaces  >          <  Add  Namespace  = "System. Web. helpers"   />          <  Add  Namespace  = "System. Web. MVC"   />          <  Add  Namespace = "System. Web. MVC. Ajax"   />          <  Add  Namespace  = "System. Web. MVC. html"   />          <  Add  Namespace  = "System. Web. Routing"   />          <  Add  Namespace  = "System. Web. webpages" />        </  Namespaces  >      </  Pages  >    </  System. Web  >        <  System. Webserver  >      <  Validation  Validateintegratedmodeconfiguration = "False"  />      <  Modules  Runallmanagedmodulesforallrequests  = "True"  />    </  System. Webserver  >    <  Runtime  >      <  Assemblybinding  Xmlns = "Urn: Schemas-Microsoft-com: ASM. V1"  >        <  Dependentassembly  >          <  Assemblyidentity  Name  = "System. Web. MVC"  Publickeytoken  = "31bf3856ad364e35"   />          <  Bindingredirect  Oldversion = "1.0.0.0-2.0.0.0"  Newversion  = "3.0.0.0"   />        </  Dependentassembly  >      </  Assemblybinding  >    </  Runtime  >  </  Configuration  > 

 

There are two details here. The first one is the version number of system. Web. webpages. dll in the assembly configuration section. The original website may be Version 1.0, which needs to be changed to version 2.0.
Add<GlobalizationCultrue= "ZH-CN"Uicultrue= "En-us"/>Configuration section.

Download Toolkit

Click to download the mvc3 toolkit.

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.