Set up the Asp.net mvc3 environment on Linux (centos + nginx + mono)

Source: Internet
Author: User

 

Mvc3 running target environment
  • Linux: centos6.2
  • Nginx: 1.2
  • Mono: 2.11.4
  • Xsp: 2.10.2.0

 

 Installation steps:

1. Download the program source code (you can download it from the official website)

    • Nginx source package: http://nginx.org/download/nginx-1.2.4.tar.gz
    • Mono source package: http://download.mono-project.com/sources/mono/
    • Xsp source package: http://download.mono-project.com/sources/xsp/xsp-2.10.2.tar.bz2

    2. Compile and install the source code

      • The three source code packages downloaded here will be compiled and installed. If the components are missing during installation, you can install them by yourself.
      • Some components that need to be used mainly are installed through Yum: Yum install GCC gcc-C ++ glibc-devel glib2

      • Compile and install nginx: tar-zxvf nginx-1.2.4.tar.gz
        CD nginx-1.2.4/
        ./Configure
        Make & make install

      • Compile and install Mono:

        Tar-jxvf mono-2.11.4.tar.bz2
        CD mono-2.11.4/
        ./Configure -- prefix =/opt/mono-2.11
        Make

        Make install

         

        Echo export pkg_config_path =/opt/MONO/lib/pkgconfig: $ pkg_config_path> ~ /. Bash_profile
        Echo export LD_LIBRARY_PATH =/opt/MONO/lib: $ LD_LIBRARY_PATH> ~ /. Bash_profile
        Echo export Path =/opt/MONO/bin: $ PATH >> ~ /. Bash_profile
        Source ~ /. Bash_profile

         

      • Install xsp: tar-jxvf xsp-2.10.2.tar.bz2
        CD xsp-2.10.2/
        ./Configure -- prefix =/opt/mono-2.11

        Make & make install

      4. Configure nginx

      • Add FastCGI parameter: VI/usr/local/nginx/CONF/fastcgi_params

        -- Add two rows
        Fastcgi_param path_info "";
        Fastcgi_param script_filename $ document_root $ fastcgi_script_name;

      • Add an nginx server and listen to port 9999: VI/usr/local/nginx/CONF/nginx. conf

        -- Add a server
        Server {
        Listen 9999;
        SERVER_NAME NETServer;
        Location /{
        Root html/end;
        Index index.html;
        Fastcgi_index/home;
        Fastcgi_pass 127.0.0.1: 9900;
        Include/usr/local/nginx/CONF/fastcgi_params;
        }
        }

       5. Upload the mvc3 web program (Name: mvctest)

      • Use vs2010 to create an mvc3 web program and copy the following referenced DLL to the local system. Data. dll
        System. Web. applicationservices. dll
        System. Web. dynamicdata. dll
        System. Web. helpers. dll
        System. Web. MVC. dll
        System. Web. Routing. dll
        System. Web. webpages. Deployment. dll
        System. Web. webpages. dll
        System. Web. webpages. Razor. dll
      • Manually copy system. Web. Razor. DLL to the directory c: \ Program Files \ Microsoft ASP. NET \ ASP. NET web pages \ V1.0 \ assemblies where the DLL is located in the bin directory
      • Upload the program to the nginx web directory (if the directory does not exist)/usr/local/nginx/html/end/

      6. test whether the MVC program is executed normally.

      • Go to the mvctest directory CD/usr/local/nginx/html/end/mvctest
      • Run xsp4xsp4

        Listening On address: 0.0.0.0
        Root directory:/usr/local/nginx/html/end/mvctest
        Listening on port: 8080 (non-secure)
        Hit return to stop the server.

      • Use a browser to test access through port 8080. If it works properly, congratulations! If an error occurs, you must resolve the error before proceeding to the configuration. (Some Common Errors and solutions are listed below)

       7. Start nginx and fastcgi_server

      • Start nginx/usr/local/nginx/sbin/nginx
      • Start fastcgi_serverfastcgi-mono-server4/applications =/:/usr/local/nginx/html/end/mvctest // socket = TCP: 127.0.0.1: 9900/printlog = true
      • Fastcgi_server background running method (after a long time running) nohup fastcgi-mono-server4/applications =/:/usr/local/nginx/html/end/mvctest/socket = TCP: 127.0.0.1: 9900/printlog = true &

      8. After all the problems are solved, you can run the basic mvc3 program normally ~~

       

       

      Common Errors and solutions:
      • When xsp4 is started, an error is reported. Solution: remove system. Web. dll from the bin directory of the program.

       

      • Badgateway is displayed, and system is reported in the background. typeinitializationexception: An exception was thrown by the Type initializer for mono. webserver. fastCGI. workerrequest -- Solution: Create a prefix in/opt/mono-2.11/bin. sh, and run

        #! /Bin/bash

        # Your mono directory
        Prefix =/opt/mono-2.11
        Files = (
        'Fastcgi-mono-server4'
        'Xsp4 ')

        CD $ prefix/lib/MONO/4.0

        For file in "$ Files"
        Do
        CP "cmdfile.exe" ../4.5
        Done

        CD $ prefix/bin

        For file in "$ Files"
        Do
        Sed-ie's | mono/4.0 | mono/4.5 | G' $ File
        Done

      • The reported parameter cannot be blank: system. argumentnullexception argument cannot be null. Parameter Name: Key; system. Resources. missingmanifestresourceexception: cocould not find any
        Resources appropriate for the specified culture or the neutral
        Culture. Make sure "system. Web. MVC. Resources. mvcresources. Resources"
        Was correctly embedded or linked into assembly "system. Web. MVC"
        Compile time, or that all the satellite assemblies required are
        Loadable and fully signed. -- Solution: modify web. config and add
        <Globalization uiculture = "en" Culture = "En-us"/>

      Database Error:

      System. invalidprogramexception: Invalid il code in system. Data. Common. dbpr
      Oviderfactories: getfactory (string): Method body is empty.

      -- Solution: delete system. Data. dll under bin.

       

       

       

      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.