Archive for the 'CentOS' Category

How To Let Apache Web Server Run ASP.NET Applications on CentOS

This is a index page of my mono and asp.net articles, so I will continue update this page when I have new articles.

1.Prepare a CentOS hosting, in my case, I use CentOS VPS, I have introduced how to install OpenVZ and Create VPS before.

2.Install Mono 2.4.2.3 on CentOS 5.

3.Install XSP, mod_mono and configure Apache to run ASP.NET application with Apache web server.

P.S.
Q:Why I choose VPS?
A:It can make me easily and quickly roll back the installation(to the last correct snapshot) when I make mistake with the help of vzdump.

Be Sociable, Share!

How to Install XSP and Integrate XSP With Apache 2 Under CentOS 5

In the last article, I have introduced How to Install Mono 2.4.2.3 on CentOS 5 , forgot telling you, why I want to install Mono on CentOS, I want to try to run ASP.NET under Linux.

Mono has an implementation of ASP.NET 2.0 and ASP.NET AJAX, and to run your ASP.NET applications with Mono, you have three classes of options:

  • Apache hosting: use mod_mono, a module that allows Apache to serve ASP.NET applications.
  • FastCGI hosting: use the FastCGI hosting if you have a web server that supports the FastCGI protocol for extending the server. You also may use a web server that only has support for CGI using cgi-fcgi.
  • XSP: this is a simple way to get started, a lightweight and simple webserver written in C#.

XSP is a standalone web server written in C# that can be used to run your ASP.NET applications with minimal effort.
The mod_mono Apache module is used to run ASP.NET applications within the Apache (http://httpd.apache.org) web server.

Let’s continue install XSP and mod_mono now.
1.Go to this page and download xsp-2.4.2.tar.bz2,
#wget http://ftp.novell.com/pub/mono/sources/xsp/xsp-2.4.2.tar.bz2

2. Extract the download file,
# tar jxvf xsp-2.4.2.tar.bz2

3. In to the xsp-2.4.2 folder,
#cd xsp-2.4.2

4.configure, build and install XSP,
# ./configure –prefix=/opt/mono; make; make install
because I installed mono in /opt/mono, so the same treat to XSP

5.go to the parent folder,
#cd ..

6.by default, Apache 2 has been installed, make sure you have installed httpd-devel, or you will get error message like”**** apxs was not found,” when you build mod_mono,
#yum -y install httpd-devel

7.Go to this page and download mod_mono-2.4.2.tar.bz2

8. Extract the download file,
# tar jxvf mod_mono-2.4.2.tar.bz2

9. In to the mod_mono-2.4.2 folder,
#cd mod_mono-2.4.2

10.configure, build and install mod_mono,
# ./configure –prefix=/opt/mono; make; make install

11.You may want to verify a few thigns to make sure the configuration is ready to rock. In my case, I am keeping the mono configuration in a separate file for sanity sake. You can do that or put it all in your httpd.conf, it’s up to you,

<IfModule !mod_mono.c>
LoadModule mono_module /usr/lib/httpd/modules/mod_mono.so
AddType application/x-asp-net .aspx
AddType application/x-asp-net .asmx
AddType application/x-asp-net .ashx
AddType application/x-asp-net .asax
AddType application/x-asp-net .ascx
AddType application/x-asp-net .soap
AddType application/x-asp-net .rem
AddType application/x-asp-net .axd
AddType application/x-asp-net .cs
AddType application/x-asp-net .config
AddType application/x-asp-net .Config
AddType application/x-asp-net .dll
DirectoryIndex index.aspx
DirectoryIndex Default.aspx
DirectoryIndex default.aspx
</IfModule>

<VirtualHost *:80>
DocumentRoot /home/httpd/aspx/html
ServerName aspx.yoursite.com
Alias /demo /opt/mono/lib/xsp/test
MonoApplications "/demo:/opt/mono/lib/xsp/test"
MonoServerPath /opt/mono/bin/mod-mono-server2
<Directory /opt/mono/lib/xps/test>
SetHandler mono
</Directory>
</VirtualHost>

12.restart httpd service,
#service httpd restart

13.Test it,
visit http://aspx.yoursite.com/demo in your browser, and if you get the page with the title “Welcome to Mono XSP!”, congratulation!

references,
ASP.NET and Mono
My Adventures Installing mono 2.0 on CentOS 4 to work with Apache via mod_mono

Be Sociable, Share!

How to Install Mono 2.4.2.3 on CentOS 5

I am a .NET developer, but for the need of my job, I am also familiar with CentOS 5 and OpenVZ. I have installed Mono on my Windows XP environment before, and want to have a try Mono under CentOS 5.
This time I use a CentOS 5.2 VPS(a clean VPS I just created)to install the last version Mono(v2.4.2.3).
First of all, I tried the easiest way to install Mono,
#yum groupinstall Mono
But I noticed the version of Mono I installed is 1.2.4, seems that the lastversion of mono (2.4.2.3) is not in the CentOS package repositories.
Then I tried to find the last version distribution from Mono Home page and google, but no result, So I had to download the source code and compile it all by my self.
After some attempts, I got the following steps to compile and install the last version Mono on my CentOS 5.2 VPS host,
1.prepare the compile environment,
# yum install gcc bison pkgconfig glib2-devel gettext make

2.Go to this page and download the last version Mono(in my case, mono-2.4.2.3.tar.bz2),
#wget http://ftp.novell.com/pub/mono/sources/mono/mono-2.4.2.3.tar.bz2

3.Extract the downloaded file,
# tar jxvf mono-2.4.2.3.tar.bz2

4.Change to the newly created directory,
# cd mono-2.4.2.3

5.I put my built packages in /opt so, run the following command to build mono,
# ./configure –prefix=/opt/mono; make; make install

6.Update ~/.bash_profile,

#echo export PKG_CONFIG_PATH=/opt/mono/lib/pkgconfig:$PKG_CONFIG_PATH>>~/.bash_profile
#echo export PATH=/opt/mono/bin:$PATH>>~/.bash_profile
#source ~/.bash_profile

7. Test it,
#mono -V
and I got the output:

Mono JIT compiler version 2.4.2.3 (tarball Thu Oct 22 06:42:24 MSD 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: x86
Disabled: none

Great, I got it.
I think I’d better put all script I used in one place,


mkdir ~/software
yum install gcc bison pkgconfig glib2-devel gettext make
wget http://ftp.novell.com/pub/mono/sources/mono/mono-2.4.2.3.tar.bz2
tar jxvf mono-2.4.2.3.tar.bz2
cd mono-2.4.2.3
./configure –prefix=/opt/mono; make; make install
echo export PKG_CONFIG_PATH=/opt/mono/lib/pkgconfig:$PKG_CONFIG_PATH>>~/.bash_profile
echo export PATH=/opt/mono/bin:$PATH>>~/.bash_profile
source ~/.bash_profile
mono -V
cd ..
rm -rf mono-2.4.2.3

references,
Mono Home Page
[HOWTO] Install Mono 2.4 on CentOS 5.3

P.S.
In the next article, I will introduce how to let Apache to serve ASP.NET applications under Linux, How to Install XSP and Integrate XSP With Apache 2 Under CentOS 5

Be Sociable, Share!