#!/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”.DH helpdesk issue
Hi, I asked DH helpdesk, but also refused. Is it possible to share your complied binary?
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!
Root directory
Hello, is it possible to change the root virtual directory to the $HOME/$DOMAIN?
Perhaps
I was wondering about that myself. I think it should be possible with all the magic of the
.htaccessfile, but I haven't yet figured out how — let me know if you get it working.Latest working packages
The original script won't work because zlib is now at 1.2.5 and libpng is 1.2.44. Here's a script (with some error checks) that seems to work for the latest stable version of Mono 2.6.7 with current updates (minor, not major version) for all packages. I was able to get this to work, but had to have DreamHost tech support compile it since they couldn't turn off the "Yikes!" memory killer.
Re: Latest working packages
Thanks for the update, Dave. I slightly edited the Mono 2.6.7 build script included in your comment to use the “
set -e” option recommended by Rene, instead of the many explicit error checks. I am glad you got Mono compiled and find it encouraging that DreamHost tech support was willing to build the script for you.Premature end of script headers
Any idea on what might cause "Premature end of script headers: mono-web-launcher.fcgi" error message in error.log? Thanks.
Re: Premature end of script headers
Initially I also got those errors while setting up Mono, but the documented procedure resolved them. Double-check your file permissions and the directory structure. You could also try to set
loglevelstoAlland check whetherfastcgi-mono-web.loggets created; if not, the problem is likely with the early boot-strapping of FastCGI involving Apache, otherwise the Mono log may contain additional info.Re: Premature end of script headers
The issue ended up being execute permissions on the mono-web-launcher.fcgi script.
Now, I'm onto getting BlogEngine.NET to work.
Same problem
I am getting the same premature end of script error regardless of what I set my permissions on the fast cgi. I turned on all logging but there isn't anything telling in either the fastcgi or apache logs that I can find. Any ideas?
Re: Same problem
If you are sure all your file and directory access-rights are configured correctly, you should also carefully check the contents of your
mono-web-launcher.fcgiscript. A simple typo in that file could also easily cause the mentioned error. It can be a bit frustrating to get beyond this point, since the log files are not really helpful until after this step in the procedure.You could try executing
~/example.com/cgi-bin/mono-web-launcher.fcgimanually from the command shell. If your script is setup correctly, you should probably get a message similar to “Error: Pipe socket is not bound”. However, if your script has some other problem, you may get a different error message hinting at the real problem (for example, with a line number).Mostly works, problems with Web.config
Following everything in your 2.6.7 script (with numerous restarts of the main mono make), I managed to get something going - but it consistently hits a "Server Error in '/mono-web' Application". The error message talks about setting up the Web.config - but I have, and it doesn't seem to honor it.
Have you seen anything like this before?
Re: Mostly works, problems with Web.config
This sounds like a similar problem I had that was solved by using case-insensitive file-system compatibility mode ("
export MONO_IOMAP=all" in themono-web-launcher.fcgifile). Perhaps try renaming "Web.config" to "web.config", or something like that, and double-check your launcher script.