Installing MONO on CentOS with Plesk
These instructions are for a new installation and the result will be that you can run .NET web sites on your Linux BOX!
First ensure that your system is updated :
yum update
Next you need to install the dependencies:
Install Dependencies
"Development Tools" - (GNU Compiler Collection) GCC can compile programs written in C, C++, Objective-C, Fortran, and Java
m4 - GNU is a macro processor in the sense that it copies its input to the output expanding macros as it goes. Macros are either built-in or user-defined and can take any number of arguments.
yum groupinstall "Development Tools"
yum install libXrender libpng libtiff libjpeg fontconfig glibc glib2 libgdiplus freetype libX11 giflib glib gtk+ pango atk cairo pkgconfig m4 exiftags
Dependencies for libgdiplus:
yum install libXrender libpng libtiff libjpeg fontconfig glibc glib2 libgdiplus freetype libX11 giflib exiftags
Dependencies for MONO:
yum install glib gtk+ pango atk cairo pkgconfig m4
Dependencies for mod_mono:
yum install glibc httpd
Now log into SSH as root and create a folder that you want to download all the files for MONO to and get into it:
mkdir /src; cd /src;
go and check for the latest MONO Stable Source Code.
copy the URL from each of the following:
- libgdiplus
- mono
- xsp
- mod_mono
Installing Mono
Download all the MONO sources using wget:
wget http://ftp.novell.com/pub/mono/sources/libgdiplus/libgdiplus-2.4.tar.bz2;
wget http://ftp.novell.com/pub/mono/sources/mono/mono-2.4.tar.bz2;
wget http://ftp.novell.com/pub/mono/sources/xsp/xsp-2.4.tar.bz2;
wget http://ftp.novell.com/pub/mono/sources/mod_mono/mod_mono-2.4.tar.bz2;
unpack all the archives to their own folders:
tar -xvf *.tar.bz2
if this does not work do it individually:
tar -xvf libgdiplus-2.4.tar.bz2;
tar -xvf mono-2.4.tar.bz2;
tar -xvf xsp-2.4.tar.bz2;
tar -xvf mod_mono-2.4.tar.bz2;
OK now we are ready to compile and install:
Installing libgdiplus
Before compiling the main sources of mono we must compile libgdiplus if we want to have an implementation of the System.Drawing namespace.
open the folder and configure:
cd libgdiplus-2.4/;
./configure --prefix=/usr/local;
output should be :
---
Configuration summary
* Installation prefix = /opt/mono-2.4
* Cairo = 1.8.0 (system)
* Text = pango
* EXIF tags = yes
* 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.
---
Check if there are any errors... if there are... install the missing packages. ans then compile again else just proceed.
make; make install;
After the compilation finally finishes, we need to make sure the new packages are visible to the system:
sh -c "echo /usr/local/lib >> /etc/ld.so.conf;"
/sbin/ldconfig
Installing MONO
Now it’s time to compile mono’s main sources which will produce, among others, the c# compilers and the base class libraries.
open the folder:
cd /src/mono-2.4;
./configure --prefix=/usr/local;
Check if there are any errors... if there are... install the missing packages. ans then compile again else just proceed.
make: make install;
This takes some time...
Add mono to the bash path:
nano ~/.bashrc
And add the following lines at the end:
PATH=/usr/local/bin:$PATH
LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
In order for the changes to take effect, you need to start a new instance of the bash command line
bash
To check your new mono version, type:
mono -V
You should see something like this:
Mono JIT compiler version 2.4 (tarball Wed Apr 1 04:49:16 CDT 2009)
Copyright (C) 2002-2008 Novell, Inc and Contributors. www.mono-project.com
TLS: __thread
GC: Included Boehm (with typed GC)
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Installing XSP
XSP is a standalone web server developed in C# that runs ASP.NET pages. It can be run through the command line or even embedded into your application by referencing the Mono.WebServer assembly.
open the folder:
cd /src/xsp-2.4/;
./configure --prefix=/usr/local;
Check if there are any errors... if there are... install the missing packages. ans then compile again else just proceed.
make; make install
Once the compilation is done, we can test the XSP server. Change to the XSP test installation folder and run the XSP server:
cd /usr/local/lib/xsp/test;
xsp2
You should see something like the this:
xsp2
Listening on address: 0.0.0.0
Root directory: /root
Listening on port: 8080 (non-secure)
Hit Return to stop the server.
Open your browser and point it to http://<your server address>:8080. You should see the XSP test page.
Installing Mod_Mono
Mod_mono is the name of the httpd module that links the XSP server and apache. This allows for apache to handle all incoming requests and hand them off to the XSP process in order to server your ASP.NET pages. You only need to install Mod_mono if you plan on using Apache2 to serve web pages. You will also need to have apache2 (and it's development files) pre-installed to compile mod_mono.
open directory:
cd /src/mod_mono-2.4/;
./configure --prefix=/usr/local;
Check if there are any errors... if there are... install the missing packages. ans then compile again else just proceed.
make; make install
We need to include the mod_mono.conf file in the httpd configuration file, so open the httpd.conf file in a text editor:
nano /etc/httpd/httpd.conf
Scroll to the bottom of the file and include the following line:
Include /etc/httpd/mod_mono.conf
Now lets copy the test content from XSP to our apache2 public folder to we can have an ASP.NET application with which to test the mod_mono installation:
cp -r /usr/local/lib/xsp/test /var/www/test
When you compile Mod_mono from source, the necessary apache2 configuration files are not created for you, so we will have to do them manually.
Firstly, create the mod_mono.load file with a text editor:
nano /etc/httpd/modules/mod_mono.load
Add the following line to the file:
LoadModule mono_module /usr/local/lib/httpd/modules/mod_mono.so
Next we create the mod_mono.conf file:
nano /etc/httpd/modules/mod_mono.conf
Add the following to the file:
AddType application/x-asp-net .aspx .ashx .asmx .ascx .asax .config .ascx
DirectoryIndex index.aspx
include /usr/local/lib/mono/2.0/mono-server2-hosts.conf
Next, create the mono-server2-hosts.conf file:
nano /usr/local/lib/mono/2.0/mono-server2-hosts.conf
And add the following:
<IfModule mod_mono.c>
MonoUnixSocket /tmp/.mod_mono_server2
MonoServerPath /usr/local/lib/mono/2.0/mod-mono-server2.exe
AddType application/x-asp-net .aspx .ashx .asmx .ascx .asax .config .ascx
MonoApplicationsConfigDir /usr/local/lib/mono/2.0
MonoPath /usr/local/lib/mono/2.0:/usr/local/lib
</IfModule>
Configure httpd Virtual Hosts
The virtual hosts configuration really requires a tutorial on its own, but for now I'll just show you how to make the test application the default site on your apache2 server.
Edit the default virtual host file for apache2:
Go to the viirtual host directory that you want to run MONO on and create a :
nano /var/www/vhosts/<site folder name>/conf/vhost.conf
And add the following:
ServerName www.local.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/test
DirectoryIndex index.html index.aspx
MonoDocumentRootDir "/var/www/test"
MonoServerPath rootsite "/usr/local/bin/mod-mono-server2"
MonoApplications rootsite "/:/var/www/test"
<Directory /var/www/test>
MonoSetServerAlias rootsite
SetHandler mono
AddHandler mod_mono .aspx .ascx .asax .ashx .config .cs .asmx
</Directory>
Now restart apache2:
service httpd restart; service httpd reload
Now open your browser and navigate to http://localhost/. You should see the XSP test web app appear.
References:
True True 2009-07-02 10:06:00 2009-07-13 12:33:37 0 0 Installing-MONO-on-CentOS-with-Plesk 3d87fc73-12e3-4f35-a6db-5c87e62862ea f90ed303-e0dd-497b-a1ff-205c73e97001 fdf33f98-5656-4429-9a1d-60a98d2e32ca