Configure ASP. NET (Apache + Mono) in Linux (Ubuntu/openSUSE/CentOS)

Source: Internet
Author: User
Tags cairo filezilla

[Digress]

I tried to test the performance of my project on different operating systems, so I decided to deploy the Apache and Mono environments on Linux. Since Linux is rarely used at ordinary times, I have tried several articles on the Internet (attached to relevant links) and the deployment process is not smooth sailing, so I reorganized my configuration on Azure, hoping to help those who seldom access Linux. All of the following operations are configured in the Azure Virtual Machine. If you configure them locally or in the virtual machine, you may need to configure Nic settings first.

 

[Article Index]

 

[1. install Apache in Ubuntu]

After Ubuntu Server is installed, there is no graphical interface by default. In fact, it is easy to configure it in Linux without a graphical interface. After the Ubuntu Server is configured on Azure (Ubuntu Server 12.04 LTS, provided on Azure is used), port 22 of SSH is automatically configured, we can connect to the server directly using SSH tools, where free open source PuTTY (http://www.putty.org/) is used /). If the password configured on Azure is used to connect to the host, enter the address and click "Open". If an SSH key is also uploaded, you should also select the corresponding key in Connection/SSH/Auth to connect.

After installation, enter "mono-V" to view the installed mono version (note that V is in uppercase). Of course, you can also write a C # leleapp to check the version, you can use the following command to compile the C # code.

gmcs test.cs

If there is no question in the program, test.exe will be generated. You can run the following command. Of course, you can also compile the exe file on Windows and copy it to Linux for execution.

mono test.exe

Next, install Apache on ASP Based on your desired version. NET 2.0 or ASP. NET 4.0 support, mono-apache-server2 for ASP. NET 2.0 support, mono-apache-server4 is ASP. NET 4.0, both of which can exist at the same time. To switch between them, you need to switch in the Apache configuration file. Software Package details: http://packages.ubuntu.com/quantal/mono-apache-server2

sudo apt-get install mono-apache-server2

I don't know why. The installation will be stuck in this place at the end.

sudo vim /etc/apache2/mods-available/mod_mono.conf

 

[3. Deploy an ASP. NET Website under Ubuntu]

To deploy a website on Windows, you can directly copy the website or packaged website through remote desktop. in Linux, SSH not only supports command line, but also file transmission, I use free open-source Filezilla (https://filezilla-project.org/) Here, Filezilla supports FTP and SSH protocols, select SFTP protocol in site manager, and then set the login type to normal, enter the user name and password to log on.

Then, package the website to be uploaded as a zip file, upload it to the user directory (/home/username/), and enter it in the command line.

Sudo unzip compressed file name. Zip-d/var/www

Of course, the address for accessing your server in your browser is still "It worksflood. We need to delete index.html.

sudo rm /var/www/index.html

 

[4. Operations under openSUSE]

Different systems use different software package management programs. SUSE provides a software package management program named zypper, which is also very convenient to use (openSUSE 12.3 is provided on Azure ).

First, install Apache.

sudo zypper install apache2

Different from the Ubuntu installation process, there is no prompt to start Apache after the installation is complete. Therefore, you need to manually configure the service to start automatically.

sudo systemctl enable apache2.service

sudo systemctl  apache2.service 

Now you can access the server using a browser.

Then install Mono using zypper (here, System. Drawing will use libgdiplus and mono-locale-extras will be used for multi-language support, but even if some components are not installed, it will be explained later ):

sudo zypper install mod_mono libgdiplus mono-locale-extras

Next, you need to configure mod_mono. We recommend that you use the official http://go-mono.com/config-mod-mono/. the page is opened as shown below:

After that, you can install the zip decompression tool (sudo zypper install zip) for openSUSE like Ubuntu, and decompress the compressed file to the configured website root directory. Then, you only need to restart the Apache server to access the ASP. NET Website immediately:

sudo systemctl restart apache2.service

Note that, unlike Ubuntu, many dependent libraries are installed. If you run the preceding command, only the following components are installed:

Similar to openSUSE, you must manually configure the service to start automatically after installation.

sudo chkconfig --levels 235 httpd 

Then immediately start the Apache service.

sudo /etc/init.d/httpd 

Now, you can access the Http server through a browser.

However, CentOS does not officially package the rpm package for mono, so it is better to compile the package by yourself.

First, configure the compiling environment.

sudo yum install gcc gcc-c++ bison pkgconfig glib2-devel gettext make freetype-devel fontconfig-devel libX11-devel libpng-devel libjpeg-devel libtiff-devel giflib-devel libexif-devel cairo-devel httpd-devel

You may be prompted to upgrade the kernel-headers, but the system may disable the core package by default. If the above command cannot be installed, you also need to add "-- disableexcludes = main" after the previous command, that is, the following form.

sudo yum install gcc gcc-c++ bison pkgconfig glib2-devel gettext make freetype-devel fontconfig-devel libX11-devel libpng-devel libjpeg-devel libtiff-devel giflib-devel libexif-devel cairo-devel httpd-devel --disableexcludes=main

If everything is successfully installed, run the following statement to download the source code package of the component to be installed and decompress it.

cd /usr/src/sudo wget http:sudo wget http:sudo wget http:jxf libgdiplus-jxf mono-.--.tar.bz2

Compile and install libgdiplus.

-/configure --prefix=/usr

-./configure --prefix=/usr

-/configure --prefix=/usr

-/configure --prefix=/usr

Then modify the "/etc/httpd/conf/mod_mono.conf" file, which is the same as the configuration file with the same name on Ubuntu. However, unlike the existing configuration files in Ubuntu, you need to add the following two lines to the file. Because 2.0 and 4.0 support is automatically installed during installation, therefore, you can switch the following 2 to 4 to enable ASP. NET 4.0:

MonoServerPath 

 

sudo cp /etc/httpd/conf/mod_mono.conf /etc/httpd/conf.d/

 

[6. Related Links]

1. Configure linux (apache) + mono to run asp.net: http://www.cnblogs.com/hcl0208/archive/2010/10/25/1860173.html
2. Install Mono on openSUSE and release ASP. Net program: http://www.linuxidc.com/Linux/2011-04/34872.htm
3. CentOS 6.0 install MONO 2.10.8: http://www.cnblogs.com/aquilahkj/archive/2011/11/03/2234380.html
4, Mono environment does not support Chinese solution: http://www.cnblogs.com/shanyou/archive/2010/10/08/1846198.html

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.