#!/bin/sh
# ===================================================================
# Download, build and install the Mono .NET-compatible Framework...
# ===================================================================
# ===================================================================
# Setup and initialization
# -------------------------------------------------------------------
# Define some common variables
# TODO: Remember to use your own domain name (DreamHost directory name)
export DOMAIN="example.com"
mono_dir="${HOME}/mono-2.4.2.3"mono_src="${HOME}/src/mono-build"
# Create a few directories (maybe not needed, but it shouldn't hurt)
mkdir -p "${mono_dir}"mkdir -p "${mono_dir}/etc"mkdir -p "${mono_src}"
# Setup the source environment variables to ensure that any custom
# pkg-config libraries can be located and progressive compilations
# can use the C# compiler and other Mono tools
export DYLD_LIBRARY_PATH="${mono_dir}/lib:${DYLD_LIBRARY_PATH}"export LD_LIBRARY_PATH="${mono_dir}/lib:${LD_LIBRARY_PATH}"export LIBRARY_PATH="${mono_dir}/lib:${LIBRARY_PATH}"export C_INCLUDE_PATH="${mono_dir}/include"export CPLUS_INCLUDE_PATH="${mono_dir}/include"export ACLOCAL_PATH="${mono_dir}/share/aclocal"export PKG_CONFIG_PATH="${mono_dir}/lib/pkgconfig:${PKG_CONFIG_PATH}"export PATH="${mono_dir}/bin:${PATH}"
# ===================================================================
# Get and extract Mono and related packages/extensions
# -------------------------------------------------------------------
cd "${mono_src}"
wget -c "http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz"
wget -c "http://ftp.gnu.org/pub/gnu/gettext/gettext-0.17.tar.gz"
wget -c "http://iweb.dl.sourceforge.net/project/libexif/libexif/0.6.18/libexif-0.6.18.tar.bz2"
wget -c "http://www.zlib.net/zlib-1.2.3.tar.gz"
wget -c "http://iweb.dl.sourceforge.net/project/libpng/00-libpng-stable/1.2.40/libpng-1.2.40.tar.gz"
wget -c "http://www.ijg.org/files/jpegsrc.v7.tar.gz"
wget -c "ftp://ftp.remotesensing.org/pub/libtiff/tiff-3.9.1.tar.gz"
wget -c "http://iweb.dl.sourceforge.net/project/giflib/giflib%204.x/giflib-4.1.6/giflib-4.1.6.tar.bz2"
wget -c "http://ftp.gnu.org/gnu/bison/bison-2.4.1.tar.bz2"
wget -c "http://xmlsoft.org/sources/libxml2-2.7.6.tar.gz"
wget -c "http://xmlsoft.org/sources/libxslt-1.1.26.tar.gz"
wget -c "http://ftp.gnome.org/pub/GNOME/sources/glib/2.22/glib-2.22.2.tar.bz2"
wget -c "http://ftp.novell.com/pub/mono/sources/libgdiplus/libgdiplus-2.4.2.tar.bz2"
wget -c "http://ftp.novell.com/pub/mono/sources/mono/mono-2.4.2.3.tar.bz2"
wget -c "http://ftp.novell.com/pub/mono/sources/xsp/xsp-2.4.2.tar.bz2"
wget -c "http://ftp.novell.com/pub/mono/sources/mono-basic/mono-basic-2.4.2.tar.bz2"
nice -n 19 tar -xzf "libiconv-1.13.1.tar.gz"
nice -n 19 tar -xzf "gettext-0.17.tar.gz"
nice -n 19 tar -xjf "libexif-0.6.18.tar.bz2"
nice -n 19 tar -xzf "zlib-1.2.3.tar.gz"
nice -n 19 tar -xzf "libpng-1.2.40.tar.gz"
nice -n 19 tar -xzf "jpegsrc.v7.tar.gz"
nice -n 19 tar -xzf "tiff-3.9.1.tar.gz"
nice -n 19 tar -xjf "giflib-4.1.6.tar.bz2"
nice -n 19 tar -xjf "bison-2.4.1.tar.bz2"
nice -n 19 tar -xzf "libxml2-2.7.6.tar.gz"
nice -n 19 tar -xzf "libxslt-1.1.26.tar.gz"
nice -n 19 tar -xjf "glib-2.22.2.tar.bz2"
nice -n 19 tar -xjf "libgdiplus-2.4.2.tar.bz2"
nice -n 19 tar -xjf "mono-2.4.2.3.tar.bz2"
nice -n 19 tar -xjf "xsp-2.4.2.tar.bz2"
nice -n 19 tar -xjf "mono-basic-2.4.2.tar.bz2"
# ===================================================================
# Build packages
# -------------------------------------------------------------------
# libiconv
cd "${mono_src}/libiconv-1.13.1"./configure --enable-extra-encodings "--prefix=${mono_dir}"nice -n 19 make
nice -n 19 make install
# gettext
cd "${mono_src}/gettext-0.17"./configure "--prefix=${mono_dir}"nice -n 19 make
nice -n 19 make install
# Rebuild libiconv, again after gettext; recommended
# on the GNU page http://www.gnu.org/software/libiconv/
cd "${mono_src}/libiconv-1.13.1"nice -n 19 make distclean
./configure --enable-extra-encodings "--prefix=${mono_dir}"nice -n 19 make
nice -n 19 make install
# libexif
cd "${mono_src}/libexif-0.6.18"./configure "--prefix=${mono_dir}"nice -n 19 make
nice -n 19 make install
# zlib
cd "${mono_src}/zlib-1.2.3"./configure "--shared" "--prefix=${mono_dir}"nice -n 19 make
nice -n 19 make install
# libpng
cd "${mono_src}/libpng-1.2.40"./configure "--prefix=${mono_dir}"nice -n 19 make
nice -n 19 make install
# jpegsrc
cd "${mono_src}/jpeg-7"./configure "--prefix=${mono_dir}"nice -n 19 make
nice -n 19 make install
# libtiff
cd "${mono_src}/tiff-3.9.1"./configure "--prefix=${mono_dir}"nice -n 19 make
nice -n 19 make install
# giflib
cd "${mono_src}/giflib-4.1.6"./configure "--prefix=${mono_dir}"nice -n 19 make
nice -n 19 make install
# bison
cd "${mono_src}/bison-2.4.1"./configure --without-libintl-prefix "--prefix=${mono_dir}"nice -n 19 make
nice -n 19 make install
# libxml2
cd "${mono_src}/libxml2-2.7.6"./configure "--with-iconv=${mono_dir}" \ "--with-zlib=${mono_dir}" "--prefix=${mono_dir}"nice -n 19 make
nice -n 19 make install
# libxslt
cd "${mono_src}/libxslt-1.1.26"./configure "--prefix=${mono_dir}" "--with-iconv=${mono_dir}"nice -n 19 make
nice -n 19 make install
# glib
cd "${mono_src}/glib-2.22.2"./configure --with-libiconv=gnu "--prefix=${mono_dir}"nice -n 19 make
nice -n 19 make install
# libgdiplus
cd "${mono_src}/libgdiplus-2.4.2"./configure --with-libexif --with-libjpeg \
--with-libtiff --with-libgif "--prefix=${mono_dir}"nice -n 19 make
nice -n 19 make install
# ===================================================================
# Build Mono core and extensions
# -------------------------------------------------------------------
# Mono
cd "${mono_src}/mono-2.4.2.3"./configure "--prefix=${mono_dir}"nice -n 19 make
nice -n 19 make install
# XSP, including Mono's FastCGI support
cd "${mono_src}/xsp-2.4.2"./configure "--prefix=${mono_dir}"nice -n 19 make
nice -n 19 make install
# Basic (alternative Mono language, similar to .NET's Visual Basic)
cd "${mono_src}/mono-basic-2.4.2"./configure "--prefix=${mono_dir}"nice -n 19 make
nice -n 19 make install
# ===================================================================
# Cleanup and wrap-up
# -------------------------------------------------------------------
# Remove intermediate source code, since it is no longer needed
cd ~
rm -rf "${mono_src}"
# Create a directory for the web-app launcher script
mkdir -p "${HOME}/${DOMAIN}/cgi-bin"chmod 751 "${HOME}/${DOMAIN}/cgi-bin"
echo " *************** INSTALL COMPLETE! ***************"
# ===================================================================
Comments
Thanks
Excellent post.
I too had problems building mono getting my processes killed all the time, but I had less luck getting Dreamhost temporarily extending my memory allowance. The only suggestion they had was for me to get their VPS service.
My solution was to install a VMware image (64-bit one to match the Dreamhost target platform) where I could build mono. No problems so far, except that the mono installer script for some reason hard-coded my VMware username in quite some of the scripts in the mono-2xx/bin directory.
Everything else worked out of the box.
By the way, I added
set -ein the beginning of the build script just to make sure it stops if any errors occurred.Neat error-checking
@Rene: It is good to know that there is also an alternative workaround for the memory-constraint issue. And the “
set -e” tip would really come in handy next time – UNIX does have many hidden “Easter eggs”.Mono On Dreamhost
Thanks for this great tutorial...can't wait to try it. FYI, I've linked to it from the dreamhost support wiki topic for Mono, so that others may benefit from your work! I know I've spent countless hours trying to get it to work and eventually just gave up...
http://wiki.dreamhost.com/Mono
Overcomplicated?
I just got the latest stable sources, used ./configure --prefix=/home/arienh4/mono and make, make installed it. Thanks for the fastcgi part of the guide though, that really did help.
It gets easier
@Ariën: The simple build procedure that you describe never worked previously. So, it is great news if that indeed now works at last! I suppose that DreamHost may have finally updated some of the core dependencies to newer versions that are compatible with Mono. However, if you only built the
monoandxsppackages, and skipped ones such aslibgdiplusandlibxml2/libxslt, you probably still won’t have all the features. At least it sounds like the core functionality can now be attained more easily than before.VPS or Shared Hosting
Are you on a VPS or is it shared hosting? If shared, this is great news...
Shared Hosting (not Virtual Private Servers)
This is shared. However, while Mono itself worked (I managed to run .NET assemblies) I never quite got ASP.NET to run.
ASP.NET and even MVC is possible
Following the complete procedure from the main post, one does get standard ASP.NET functionality. And ever since Mono 2.6, the ASP.NET MVC functionality also works through FastCGI. So it seems that, although the simpler build procedure might build okay, one might still need the full procedure for all of the functionality.
Thanks
Great instruction! Thanks, works like a charm!