Loading... (0%)

Post published: Post last modified: 15 June 2014

I would like to share my experience of making a virtual Linux server to serve ASP.NET websites. The procedures aren’t new, but it was somewhat tricky to use multiple information sources and my own experience to achieve this goal. Anyway, this article will serve as a little how-to for myself and hopefully you will find it useful too.

System that has been used: VirtualBox, CentOS 6.5 (x86_64), Apache 2.2, Mono 3.4.0 and ISPConfig 3.0.5.4

Table of contents:

  1. Installing the hosting system (optional)
  2. Setting up installation environment
  3. Downloading required packages
  4. Installation
  5. Configuring ISPConfig3
  6. Testing
  7. References

Installing the hosting system (optional)


The Perfect Server – CentOS 6.4 x86_64 (Apache2, Dovecot, ISPConfig 3) OR Installing and configuring CentOS 6.3 XFCE mini server
Back to Top

Setting up installation environment


Install all dependencies:
yum install bison gettext glib2 freetype fontconfig libpng libpng-devel libX11 libX11-devel glib2-devel libgdi* libexif glibc-devel urw-fonts java unzip gcc gcc-c++ automake autoconf libtool make bzip2 wget libungif-devel freetype-devel libtiff-devel libjpeg-devel xulrunner-devel perl-TimeDate.noarch expect

Go to root’s directory, make mono folder there, and jump into it:
cd /root
mkdir mono
cd mono
Back to Top

Downloading required packages


Download latest Mono release and extract it:
wget http://origin-download.mono-project.com/sources/mono-1.1.16/mono-3.4.0.tar.bz2
tar xjf mono-3.4.0.tar.bz2
Download and extract XSP package:
wget http://origin-download.mono-project.com/sources/xsp/xsp-2.10.2.tar.bz2
tar xjf xsp-2.10.2.tar.bz2
Download and extract libgdiplus package:
wget http://origin-download.mono-project.com/sources/libgdiplus/libgdiplus-2.10.9.tar.bz2
tar xjf libgdiplus-2.10.9.tar.bz2
Download and extract mod_mono package:
wget http://origin-download.mono-project.com/sources/mod_mono/mod_mono-2.10.tar.bz2
tar xjf mod_mono-2.10.tar.bz2
Back to Top

Installation

Installing mod_mono


cd ~/mono/mod_mono-2.10
./configure --prefix=/usr
Output:

Configuration summary for mod_mono

   * Installation prefix = /usr
   * Apache version = 2.2
   * Apache modules directory = /usr/lib64/httpd/modules
   * apxs = /usr/sbin/apxs
   * apr-config = /usr/bin/apr-1-config
   * apu-config = /usr/bin/apu-1-config
   * CFLAGS = -g -O2 -I/usr/include/httpd -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Wformat-security -fno-strict-aliasing -pthread  -I/usr/include/apr-1   -pthread  -I/usr/include/apr-1
   * Verbose logging (debug) = no
   * GCOV options used = no
   * Profiling enabled = no
   * mono prefix = /usr/lib/pkgconfig/../..
   * Default MonoApplicationsConfigDir = /etc/httpd/conf/mod-mono-applications

make
make install
ldconfig

Back to Top

Installing libgdiplus


cd ~/mono/libgdiplus-2.10.9
./configure --prefix=/usr


Output:

Configuration summary

   * Installation prefix = /usr
   * Cairo = 1.8.8 (system)
   * Text = cairo
   * EXIF tags = No. Get it from http://libexif.sourceforge.net/
   * Codecs supported:

      - TIFF: yes
      - JPEG: yes
      - GIF: yes
      - PNG: yes

      NOTE: if any of the above say 'no' you may install the
            corresponding development packages for them, rerun
            autogen.sh to include them in the build.

make
make install
Back to Top

Installing mono


Switch to extracted mono folder:
cd ~/mono/mono-3.4.0
Run following commands to configure and install mono:
./autogen.sh --prefix=/usr OR ./configure --prefix=/usr
The output you should see:

        mcs source:    mcs

   Engine:
        GC:            sgen and bundled Boehm GC with typed GC and parallel mark
        TLS:           __thread
        SIGALTSTACK:   yes
        Engine:        Building and using the JIT
        oprofile:      no
        BigArrays:     no
        DTrace:        no
        LLVM Back End: no (dynamically loaded: no)

   Libraries:
        .NET 2.0/3.5:  yes
        .NET 4.0:      yes
        .NET 4.5:      yes
        MonoDroid:     no
        MonoTouch:     no
        JNI support:   IKVM Native
        libgdiplus:    assumed to be installed
        zlib:          system zlib

Continue with setup:
perl -pi -e 's/HAVE_LOCALCHARSET_H 1/HAVE_LOCALCHARSET_H 0/' eglib/config.h
Get the latest version of the monolite distribution, which contains just enough to run the mcs compiler:
make get-monolite-latest OR make monolite_url=http://storage.bos.xamarin.com/mono-dist-master/bf/bf17a43b31a2be16f462ffdf1ae3d9801b846e90/monolite-110-latest.tar.gz get-monolite-latest OR make monolite_url=http://storage.bos.xamarin.com/mono-dist-master/latest/monolite-111-latest.tar.gz get-monolite-latest if previous command doesn’t work.

You may want to run the mono and mcs tests. All tests should pass.
make check

And finally installation:
make -j 8 (may take a while)
make install
Check if you got mono installed successfully:
mono -V
The output:

Mono JIT compiler version 3.4.0 (tarball Thu Apr 24 03:05:33 GMT 2014)
Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            sgen

Add the path to your ~/.bash_profile
echo export PKG_CONFIG_PATH=/usr/lib/pkgconfig:$PKG_CONFIG_PATH>>~/.bash_profile
echo export PATH=/usr/bin:$PATH>>~/.bash_profile
source ~/.bash_profile

Should you wish to access mod_mono control panel, add these lines to /etc/httpd/conf/httpd.conf:

<Location /mono>
  SetHandler mono-ctrl
  Order deny,allow
  Deny from all
  Allow from 192.168.0.2
</Location>

Replace 192.168.0.2 (or add more Allow lines) with the IP address of your own computer so that you can access the control panel.
Restart Apache and now you will be able to access mono control panel via http://yourdomainoripaddress/mono/.
service httpd restart


Back to Top

Installing XSP


Go to xsp folder, configure and install it:
cd ~/mono/xsp-2.10.2
./configure --prefix=/usr
Output:

xsp-2.10.2

  Build Environment
    Install prefix:          /usr
    Datadir:                 /usr/share
    Libdir:                  /usr/lib
    Build documentation:     yes
    Mono 2.0 compiler:       /usr/bin/gmcs
    Mono 4.0 compiler:       /usr/bin/dmcs
    Target frameworks:       .NET 2.0, .NET 4.0
    Build SQLite samples:    yes

export PKG_CONFIG_PATH=`whereis pkgconfig | awk '{print $2}'`
make
make install
Back to Top

Configuring ISPConfig 3 (optional)


Add line Include /etc/httpd/conf/mod_mono.conf to /etc/httpd/conf/httpd.conf:
vi /etc/httpd/conf/httpd.conf
Here is how it should look like:

[..]
Include /etc/httpd/conf/mod_mono.conf
# ISPConfig stuff
NameVirtualHost *:80
NameVirtualHost *:443
Include /etc/httpd/conf/sites-enabled/

Restart Apache:
service httpd restart

Now in your ISPConfig control panel pick a website that you want to run as ASP.NET and change its settings similar to these (no changes needed in Options tab):

Once you’ve done this, you will have to change the ownership of website’s root directory and subdirectories to apache user/group or otherwise you will get this error “System.UnauthorizedAccessException: Access to the path “/var/www/www.yourdomain.com/web” is denied.“. Please let me know if you found a workaround for this issue.
chown -R apache:apache /var/www/clients/client1/web1/web
Restart Apache:
service httpd restart
Back to Top

Testing


In order to test if Apache serves ASP.NET files, add default.aspx file to your websites root directory with following lines:

Unfortunately, you will have to change the permissions of newly added files every time you upload them…
chown -R apache:apache /var/www/clients/client1/web1/web
Now go to your browser and type the address of your website to see the lovely “Hello, World!” 🙂

If all went fine, that’s all you should see in your /var/log/httpd/error.log:

[Thu Apr 24 04:52:00 2014] [notice] caught SIGTERM, shutting down
mod-mono-server received a shutdown message
[Thu Apr 24 04:52:03 2014] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Thu Apr 24 04:52:03 2014] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Thu Apr 24 04:52:03 2014] [notice] Digest: generating secret for digest authentication ...
[Thu Apr 24 04:52:03 2014] [notice] Digest: done
[Thu Apr 24 04:52:03 2014] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
[Thu Apr 24 04:52:03 2014] [notice] mod_python: using mutex_directory /tmp 
[Thu Apr 24 04:52:04 2014] [warn] RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
[Thu Apr 24 04:52:04 2014] [notice] Apache/2.2.15 (Unix) DAV/2 mod_fcgid/2.3.9 PHP/5.3.3 mod_python/3.3.1 Python/2.6.6 mod_ruby/1.3.0 Ruby/1.8.7(2011-06-30) mod_ssl/2.2.15 OpenSSL/1.0.1e-fips mod_mono/2.10 configured -- resuming normal operations
Listening on: /tmp/mod_mono_server_global
Root directory: /

Back to Top

References

Back to Top

Print Friendly, PDF & Email

Related Images: