install-mono.sh.zip mono-3.0.2安装指南.pdf mod_mono.diff.zip
mono-3.0.2安装指南
一见 2012/12/27
目录
1. 前言
1.1. 什么是mono?
mono是一个由Novell公司主持的一个致力于开创.net在Linux、FreeBSD、Mac OS X和Solaris上使用的开源工程。
1.2. 目的
本文档试图以最简单方式阐明mono-3.0.2版本的安装。mono采用的是automake编译方式,包括它所依赖的库,正因为这种依赖,使用得编译安装稍变复杂。
2. 下载网址
mono、xsp和mod_mono的下载网址均为:
http://download.mono-project.com/sources/
3. 依赖关系
1) mono无依赖;
2) xps依赖mono;
3) mod_mono的安装依赖Apache,关于Apache的安装,请参考另一篇文章《apache2.4安装指南》。
4. 安装步骤
4.1. mono
1) ./configure --prefix=/usr/local/mono(注:将mono安装到/usr/local/mono目录下)
2) make
3) make install
4.2. xsp
xps的安装需要注意一下,如果直接以标准的automake方式编译,可能会遇到错误,以下面的步骤操作,可帮助避免错误:
1) export PATH=/usr/local/mono/bin:$PATH(需要用到mono提供的dmcs、gmcs等命令)
2) export PKG_CONFIG_PATH=/usr/local/mono/lib/pkgconfig:$PKG_CONFIG_PATH(XSP依赖mono)
3) sed -i -e 's! test !!' Makefile.am(不编译test,因为test可能编译失败)
4) ./configure --prefix=$XSP_HOME --disable-docs(文档也不编译,减少遇到错误的概率)
5) make
6) make install
4.3. mod_mono
对于mod_mono-2.10版本,如果依赖的是Apache2.4版本,则需要修改mod_mono.c后才可以编译通过,需要修改的地方请参见“附2:mod_mono.diff”。而如果是Apache2.2版本,则不用做任何修改。
1) ./configure --prefix=/usr/local/mod_mono --with-apxs=/usr/local/httpd/bin/apxs(假设将Apache安装在/usr/local/httpd目录下)
2) make
3) make install
5. 修改Apache的httpd.conf
成功安装mono后,需要对Apache的httpd.conf文件进行修改,修改点包括:
1) 加入:include /usr/local/httpd/conf/mod_mono.conf
2) 加入以下内容(这部分需要根据实际进行修改):
<VirtualHost *:80>
ServerName mono.com
ServerAlias mono.com
ServerAdmin web-admin@mono.com
DocumentRoot /usr/local/xsp/lib/xsp/test
# MonoServerPath can be changed to specify which version of ASP.NET is hosted
# mod-mono-server1 = ASP.NET 1.1 / mod-mono-server2 = ASP.NET 2.0
# For SUSE Linux Enterprise Mono Extension, uncomment the line below:
# MonoServerPath mono.com "/opt/novell/mono/bin/mod-mono-server2"
# For Mono on openSUSE, uncomment the line below instead:
MonoServerPath mono.com "/usr/local/xsp/bin/mod-mono-server4"
# To obtain line numbers in stack traces you need to do two things:
# 1) Enable Debug code generation in your page by using the Debug="true"
# page directive, or by setting <compilation debug="true" /> in the
# application's Web.config
# 2) Uncomment the MonoDebug true directive below to enable mod_mono debugging
MonoDebug mono.com true
# The MONO_IOMAP environment variable can be configured to provide platform abstraction
# for file access in Linux. Valid values for MONO_IOMAP are:
# case
# drive
# all
# Uncomment the line below to alter file access behavior for the configured application
MonoSetEnv mono.com MONO_IOMAP=all
#
# Additional environtment variables can be set for this server instance using
# the MonoSetEnv directive. MonoSetEnv takes a string of 'name=value' pairs
# separated by semicolons. For instance, to enable platform abstraction *and*
# use Mono's old regular expression interpreter (which is slower, but has a
# shorter setup time), uncomment the line below instead:
# MonoSetEnv mono.com MONO_IOMAP=all;MONO_OLD_RX=1
MonoApplications mono.com "/:/usr/local/xsp/lib/xsp/test"
<Location "/">
Allow from all
Order allow,deny
MonoSetServerAlias mono.com
SetHandler mono
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI ".(?:gif|jpe?g|png)$" no-gzip dont-vary
</Location>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript
</IfModule>
</VirtualHost>
6. 附1:一键脚本
6.1. 一键脚本前提
1) 使用root用户操作;
2) Apache安装在/usr/local/httpd目录下;
3) mono、xps和mod_mono安装包都放在同一个目录下,如:
~/app # ls
mod_mono-2.10.tar.bz2 mono-3.0.2.tar.bz2 xsp-2.10.2.tar.bz2
4) 如果是Apache2.4,还需要将mod_mono.diff文件和安装包放在同一个目录下。
6.2. 一键脚本全文
#!/bin/sh
# Writed by yijian on 2012/12/27
# A key to install mono on linux
export APACHE_HOME=/usr/local/httpd
export MONO_HOME=/usr/local/mono
export XSP_HOME=/usr/local/xsp
export MOD_MONO_HOME=/usr/local/mod_mono
mono=`basename mono-*.tar.bz2 .tar.bz2`
xsp=`basename xsp-*.tar.bz2 .tar.bz2`
mod_mono=`basename mod_mono-*.tar.bz2 .tar.bz2`
basedir=`pwd`
apache_version=`$APACHE_HOME/bin/httpd -V|awk -F"[/ .]" '/Server version/{print $5}'`
echo "Apache version: $apache_version"
# Compile & install mono
echo "tar xjf $mono.tar.bz2"
cd $basedir
#tar xjf $mono.tar.bz2
cd $basedir/$mono
#./configure --prefix=$MONO_HOME
#if test $? -ne 0; then
# exit 1
#fi
#make
#make install
# Compile & install XSP
export PATH=$MONO_HOME/bin:$PATH
export PKG_CONFIG_PATH=$MONO_HOME/lib/pkgconfig:$PKG_CONFIG_PATH
cd $basedir
tar xjf $xsp.tar.bz2
cd $basedir/$xsp
sed -i -e 's! test !!' Makefile.am
./configure --prefix=$XSP_HOME --disable-docs
if test $? -ne 0; then
exit 1
fi
make
if test $? -ne 0; then
exit 1
fi
make install
if test $? -ne 0; then
exit 1
fi
# Compile & install mod_mono
cd $basedir
tar xjf $mod_mono.tar.bz2
if test $apache_version -gt 2; then
if test -f ./mod_mono.diff; then
echo "cp ./mod_mono.diff $mod_mono/src/"
cp ./mod_mono.diff $mod_mono/src/
if test $? -ne 0; then
exit 1
fi
fi
fi
cd $basedir/$mod_mono/src
if test -f ./mod_mono.diff; then
echo "patch mod_mono.c mod_mono.diff"
patch mod_mono.c mod_mono.diff
fi
cd $basedir/$mod_mono
./configure --prefix=$MOD_MONO_HOME --with-apxs=$APACHE_HOME/bin/apxs
if test $? -ne 0; then
exit 1
fi
make
if test $? -ne 0; then
exit 1
fi
make install
if test $? -ne 0; then
exit 1
fi
cd $basedir
echo "finished!"
exit 0
7. 附2:mod_mono.diff
389c389
< return unixd_config.user_id;
---
> return ap_unixd_config.user_id;
399c399
< return unixd_config.group_id;
---
> return ap_unixd_config.group_id;
409c409
< return unixd_config.user_name;
---
> return ap_unixd_config.user_name;
488c488
< rv = unixd_set_global_mutex_perms (xsp->dashboard_mutex);
---
> rv = ap_unixd_set_global_mutex_perms (xsp->dashboard_mutex);
850,857c850
< #if defined(APACHE22)
< return c->remote_addr->port;
< #else
< apr_port_t port;
< apr_sockaddr_port_get (&port, c->remote_addr);
< return port;
< #endif
<
---
> return c->client_addr->port;
863d855
< #if defined(APACHE22)
865,869d856
< #else
< apr_port_t port;
< apr_sockaddr_port_get (&port, r->connection->local_addr);
< return port;
< #endif
1981c1968
< info.remote_ip_len = strlen (r->connection->remote_ip);
---
> info.remote_ip_len = strlen (r->connection->client_ip);
2029c2016
< ptr += write_string_to_buffer (ptr, 0, r->connection->remote_ip, info.remote_ip_len);
---
> ptr += write_string_to_buffer (ptr, 0, r->connection->client_ip, info.remote_ip_len);