Deploying to Mono - Install CentOS 6

From Visual WebGui Wiki

Jump to: navigation, search

Contents

Overview

In this article we will discuss how to install a basic CentOS 6 operating system, install Apache2, Mono and mod_mono and finally configure mod_mono so it will be able to run a basic Visual WebGui application in this environment. The article is a part of a series of articles describing how to use Mono in Linux/Unix environment to run Visual WebGui application. The main article is Deploying to Mono.

See Also

Installing CentOS 6 and Mono 2.10

For this test, a base CentOS 6 system was installed off of their installation DVD, making sure the Web Server is included to get Apache2 installed along with the base system.

It is worth noting here that the default installation of most recent CentOS 6 installations include a Security Enhancement package, SELinux. If this package is installed on your system, it's configuration can be too strict to allow some of your applications to work correctly. This is particularly true for Mono web applications (Visual WebGui), as the mod_mono module in Apache needs to spawn the mono runtime executable as a process. Please make sure you understand how this package works and what configuration changes you need to make to allow your Mono applications to work correctly.

Yum package installer - no compilations

CentOS includes a tool, Yum package management, that greatly simplifies intsallation on CentOS compared to install from the source distributions (Mono sources for example). As long as you are not requiring the most recent updates to the software package(s), this is the method we would reccomend for the installation process, especially for novice Linux/CentOS users.

In addition to initial installation of the packages, the combination of yum and WebMin management for Linux, makes package updates become a single click on a  "Go" button.

For the tests performed while writing this article, yum and WebMin were the tools used for installing all packages after initial installation.

WebMin installed as a yum package

WebMin is not included in the CentOS 6 repository of yum packages, but can easily be added as such, by adding a /etc/yum.repos.d/webmin.repo file with the following contents:

[Webmin]
name=Webmin Distribution Neutral
baseurl=http://download.webmin.com/download/yum
enabled=1

After that you can simply issue the following command to install WebMin:

yum -y install webmin

And finally, as usual, to invoke WebMin web management, use a browser to open http://yourserver/WebMin:10000

Mono installed as yum packages

Mono is not included in the yum repository for all CentOS distributions, and where it is not, it can easily be added as such, by adding a /etc/yum.repos.d/mono.repo file with the following contents:

[mono]
name = novell-mono
baseurl=http://ftp.novell.com/pub/mono/download-stable/RHEL_5/
enabled=1
gpgcheck=0

After you have Mono in your yum repository, you need to run yum to install the necessary Mono components. This can be accomplished with the following command to install the base Mono system:

yum -y install mono-addon-core mono-addon-data mono-addon-web mono-addon-core 
yum -y install mono-addon-devel mono-addon-winforms mono-addon-wcf mono-addon-libgdiplus0 
yum -y install mono-addon-data-sqlite mono-addon-extras

Note that the command is split into 3 "yum -y install" lines fore readability, but can as well be issued on a single line.

You may also want to do a "wildcard installation" of mono related packages, using the following command:

yum -y install mono-*

Mod-Mono install for Apache2

The above installation of Mono will install the Mono framework on your CentOS system. To be able to run you Visual WebGui or ASP.NET web applications within Apache2, the mod_mono Apache2 module needs to be installed. This module is a part of the CentOS6 yum repository, so you can simply issue the command:

yum -y install mod_mono-addon

Tools for locating the necessary files - locate

For those users that don't quite know their way around this operating system and do not know where exactly the necessary files are located, it may be good to learn how to use a very simple, but very handy command, the locate command. With very minor effort and preperation, you can use this command to locate (almost) any file on your server.

As an example, to locate the mod_mono_server2 on disk, you can simply issue the following command, which will give you a list of locations where this file/folder can be found:

locate mod-mono-server2

Before the locate command can be used, the system must update or build the database of filenames it uses for it's searches. For the purpose of updating this database with the most recent information, use:

updatedb

This updatedb command is on many/most system run every hour, but very recently after you have made some changes to the filesystem, you can run this command manually to make sure the locate database is up to date.

Apache2 and mod_mono configuration

The above installation procedure will install Apache2, Mono and mod_mono in it's default installation.

There will be a /etc/httpd folder created and on that folder, the following gets created as a part of the installation:

  • /etc/httpd/conf/httpd.conf - The main Apache configuration file
  • /etc/httpd/conf.d - A folder for additional configuration files. All files with a name that ends in ".conf" will be read alphabetically by the Apache2 configuration process (included from httpd.conf).
  • /etc/httpd/conf.d/mod_mono.conf - The default mod_mono configuration file.

Modifying the default httpd.conf Apache2 configuration file

Some threads related to Apache2 and mod_mono configuration state that the extra configuration files on /etc/httpd/confg.d folder should be read by the Apache2 configuration process as the last step (or very late). The suggestion is to move the "Include conf.d/*.conf" line to be the last one of httpd.conf.

For this test, Apache2 virtual hosting was configured, using multiple virtual hosts on same IP address and same port.

For these two reasons, the last lines of /etc/httpd/conf/httpd.conf were changed (duplicate entries were commented out earlier in the file) to be:

NameVirtualHost *:80
Listen 80
ServerName CentOS.mydomain.com
<VirtualHost *:80>
	DocumentRoot "/var/www/html"
</VirtualHost>
Include conf.d/*.conf

It should be noted here that for some applications you may need to adjust the default access rights on folders and/or files to support your specific application. Folders that will need to be writable may need to have "chmod 777" to allow everyone to write, or equal access rights adjustment for the owner of the process, to allow the web application to write on that folder.

Seperate folder for Visual WebGui applications

As the httpd.conf file states above, the default folder for the server is /var/www/html.

For this test and for simplicity, a seperate folder was created on /var/www/vwg, for storing Visual WebGui applications

Mod_mono config for Visual WebGui applications

Note that many of the mod_mono configuration settings used here, can be configured to apply globally, per VirtualHost, per folder and/or per application. MonoServerPath is a good example of such a setting and can easily be configured to support different .NET versions on a per application basis. Please refer to mod_mono and Apache2 documentation for more info.

To keep the default mod_mono.conf file unchanged, a new file was created on the /etc/httpd/conf.d folder. To make sure it is loaded last, after all other configuration has already been read (especially mod_mono.conf), you can name the file something like "x01_vwg-mod_mono.conf". The contents of the file used for this test are the following:

AddType application/x-asp-net .wgx
 
<VirtualHost *:80>
  ServerName CentVWG.mydomain.com
  ServerAlias CentVWG
  ServerAdmin web-admin@CentOS.mydomain.com
  DocumentRoot /var/www/vwg
  MonoAutoApplication enabled
 
  MonoServerPath CentVWG /opt/novell/mono/bin/mod-mono-server4
  MonoDebug CentVWG true
  MonoSetEnv CentVWG MONO_IOMAP=all
 
  AddMonoApplications CentVWG "/:/var/www/vwg"
  AddHandler mono .wgx
  SetHandler mono
 
 
  <Location "/">
    MonoSetServerAlias CentVWG
  </Location>
 
  <Directory /var/www/vwg>
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  </Directory>
 
  <Location /mono>
    SetHandler mono-ctrl
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
  </Location>
</VirtualHost>

Special web.config concerns for Visual WebGui on CentOS 6

There are no known special requirements for your web.config file on CentOS 6.

What is next

Now that you have installed and configured the base operating system and the required Apache2 and Mono components, you can now continue to the deployment part of the process. Before you do that, please make a note of the operating system specific locations of the files and folders that are most relevant for this process:

  • /etc/httpd - Folder that stores Apache2 configuration files
  • /etc/httpd/conf/httpd.conf - File which is the main Apache2 configuration file (which you will change)
  • /etc/httpd/conf.d - Folder for additional configuration files. All files with a name that ends in ".conf" will be read alphabetically by the Apache2 configuration process (included from httpd.conf).
  • /etc/httpd/conf.d/mod_mono.conf - File that contains the default mod_mono configuration, and is installed as a part of mod_mono installation.
  • /etc/httpd/conf.d/x01_vwg-mod_mono.conf - File that you created and contains the Visual WebGui specific configuration for mod_mono and Apache2.
  • /var/www/vwg - Folder that you created and where you will deploy and run your Visual WebGui application from. The x01_vwg-mod_mono.conf references this folder.

At this point you are ready to learn more about the mod_mono configuration directives and how to deploy your Visual WebGui application. Please head over to the Mono directives - What do they mean section of the main article on deploying to Mono.

Other references


Personal tools