Taking levenblog as an example, we tried to deploy the Asp.net MVC program on the Linux + mono platform.

Source: Internet
Author: User

I have been paying close attention to it all the time.MonoNot long ago, Mono officially released version 2.6.1, which is a relatively complete version. most of net2.0 content. net3.5 even supports. the net4.0 content (optional) has been officially included in the mono version Asp.net mvc1.0. Therefore, the conditions for deploying levenblog to mono are completely mature, but due to differences between Linux and Windows, not allProgramCan be directly deployed. This time, we will deploy the complete record levenblog to mono2.6.1.

I tested two platforms, debian5 x86 and debian5 x64, and installed mono2.6.1 through source code compilation. However, during installation, the debian5 x64 mono compilation has encountered an inexplicable error (the compiler has not provided any valid error information but an error). Therefore, the latest source code for checkout is successfully installed ). in this way, the linux32-bit and 64-bit platforms should be widely represented. for the levenblog program, previous versions cannot run directly in mono. after preliminary analysis, the following problems exist:

  1. Local path problems, which may be the majority.. Net Program deployment to Linux + Mono is one of the biggest problems, often people write programs on Windows do not pay attention to the path, Linux uses "/" as the path separator, But windows is indeed "\", at the same time, if you operate on the path in the program, manual stitching will basically cause problems. solution to this problem: abandon the practice of manual stitching of local paths, and switch to path. the combine method is used to perform platform-independent path operations. The main issue in levenblog is the skin selection program and upload program.
  2. It is still a path problem, but this time it is a virtual path problem. The main problem is that the files on the master page are used. The view on levenblog uses a lot of master pages. The default reference method is ".. /shared/blog. master ", however, this mode will not be parsed in mono, and a path error is prompted, as if it is not using the actual path of the master page to analyze the relative path, the URL path is used for parsing. In the MVC application, the URL is different from the physical path, which leads to a path error. This is also a mono and. net incompatibility, the solution is to use ~ /Xxx method, such ~ /Skins/default/shared/blog. master. However, this method requires that the relative path is dead. Therefore, the skin directory cannot be renamed; otherwise, the file cannot be found.
  3. Still the path. Sure enough, the biggest problem with mono porting is the path. This time the problematic web. the configuration file is too large. levenblog separates the log, route, highlight, and other configuration files, and. config contains. in windows, we can only use <routeconfigure configsource = "config \ route. config "/>. However, in Linux + mono, such a path is considered as" config \ route. config "file. This is because \ is a valid file character in Linux. Therefore, in Linux + mono, this field should be changed to <routeconfgure configsource = ". /config/route. config "/> however, this configuration method is not expected to work in windows. Exceptions in Windows indicate that the path of the configuration file must be a relative path and cannot contain the character '/', therefore, you must prepare different web pages for levenblog in two different environments. config file.
  4. With regard to Native dll-sqlite3.dll processing, it is clear that sqlite3.dll is a DLL file on Windows, can not run on Linux, and system. data. SQLite. DLL is a function that imports sqlite3.dll through dllimport. At the same time, the Linked Library file on Mono will never be named *. therefore, Mono adopts a dllmap configuration method to switch internally. Therefore, sqlite3.dll is mapped to libsqlite3.so. 0, but unfortunately, libsqlite3.so installed through apt-Get In Debian 5. 0 is unable to support the new version of the system. data. SQLite. DLL. Therefore, we need to find the latest libsqlite3.so. 0. For 32-bit systems Official SQLite website Download is provided. The specific address is: Http://www.sqlite.org/sqlite-3.6.22.so.gz (For 3.6.22), the 64-bit version needs to be compiled by itself. Because this program does not require the support of TCL, you can only download the basic SQLite version. The address is: Http://www.sqlite.org/sqlite-amalgamation-3.6.22.tar.gz after compilation. you can see "libsqlite3.so. 0 "file. In order not to affect system dependencies, we recommend that you do not overwrite the file to/usr/lib. If it is convenient, you can put it in the/usr/local/lib or bin directory. however, the system still cannot find the correct libsqlite3.so. 0. This is because on Linux, neither/usr/local/lib nor the current bin is the Lib search path. To enable mono to search for these paths before execution, you need to manually execute "Export LD_LIBRARY_PATH =/usr/local/lib: $ LD_LIBRARY_PATH" to add/usr/local/lib to Lib. (Note that the environment variables in Linux are separated, if libsqlite3.so. 0 to the current bin directory, you need to add this directory to the LD_LIBRARY_PATH path ). after such a tossing, the system finally found the correct libsqlite3.so. 0 file, the home page is fully open.
  5. The verification code is incorrect. If mono installed through the source code is not displayed, check whether the libgdiplus component is installed. If no, be sure to install this component, which is the system. the working basis of the drawing component, whose 2.6.1 version is:Http://ftp.novell.com/pub/mono/sources/libgdiplus/libgdiplus-2.6.tar.bz2Before installation, make sure that the system has installed the basic libjpeg, libgpng, and libgif libraries. Otherwise, the verification codes in these formats cannot be displayed. After installation, you must also note that you must add the Lib in the installation path to the system lib search path. For example, if I install this component to/usr/local/lib, the path export must be export to LD_LIBRARY_PATH. Otherwise, the corresponding library cannot be found.
  6. The file encoding problem occurs after several basic pages above, but some pages still have garbled characters. After checking that these pages use GBK encoding and change them to UTF-8, garbled Problem Solving
  7. The file name is case-sensitive, which is also a frequent deployment problem. At the beginning, a "system. data. SQLite. DLL "cannot be found. After troubleshooting, it is found that the file name in Bin is too E. data. SQLite. the DLL and Case sensitivity differences make mono unable to load the file. Similarly, When referencing any static file on the page, the paths must be consistent in case. In levenblog, such irregularities appear in the CSS reference image. After modification, all of them are changed to lower case for troubleshooting.
  8. The mono compiler and Microsoft compiler have some incompatibility situations. For levenblog, it is represented in the calendar component, where one lineCodeAs follows:
    Startdate = startdate. adddays (0-startdate. dayofweek );
    Mono prompts that dayofweek cannot be converted to int, while Microsoft compiler supports this conversion.
    Startdate = startdate. adddays (0-(INT) startdate. dayofweek );
    Troubleshooting
  9. Some APIs are not supported. In admin/info. in aspx, cache is called. effectiveprivatebyteslimit gets the server's allocable memory, but this call is not supported in Mono and is still removed. Fortunately, such incompatibility is very rare.
  10. Embedding C # code in JS will cause parsing errors. This is the biggest bug detected by mono currently. in aspx, some JavaScript codes need to be embedded in the C # code. After the result is run, the output is disordered and the JS execution is incorrect. There is no direct solution to this problem, I added an action named js to process JS output,

After solving the above 10 problems, levenblog finally succeeded in running in the Linux + mono environment. In general, there was no major problem with porting,

I configured a levenblog runtime environment through the nginx + fastcgi-mono-server2 mode test, the configuration method refer to the above 10 points, the test address is:Http://leven.name/If you are interested in the release of the next levenblog version, I will provide a complete and stable Linux + mono installation package.

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.