在fedora 12下面,系统会自安装mono 2.4-4.3,或者简单直接 yum 安装,在CentOS5下面,可以通过下面的方式来 yum 安装,首先在/etc/yum.repos.d/ 下建立Mono的更新源 Mono.repo
[Mono]
name=Mono Stack (CentOS_5)
type=rpm-md
baseurl=http://download.opensuse.org/repositories/home:/mindtouch:/Mono/CentOS_5/
gpgcheck=1
gpgkey=http://download.opensuse.org/repositories/home:/mindtouch:/Mono/CentOS_5/repodata/repomd.xml.key
enabled=1
[root@localhost yum.repos.d]# rpm -qa|grep mono
[root@localhost yum.repos.d]# yum install mono* xsp mod_mono
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: ftp.tcc.edu.tw
* base: ftp.tcc.edu.tw
* extras: ftp.tcc.edu.tw
* updates: ftp.tcc.edu.tw
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mod_mono.i386 0:1.2.1-1.el5.centos set to be updated
---> Package mono-core.i386 0:2.4-4.2 set to be updated
--> Processing Dependency: libgdiplus for package: mono-core
---> Package mono-data.i386 0:2.4-4.2 set to be updated
---> Package mono-data-firebird.i386 0:2.4-4.2 set to be updated
---> Package mono-data-oracle.i386 0:2.4-4.2 set to be updated
---> Package mono-data-postgresql.i386 0:2.4-4.2 set to be updated
---> Package mono-data-sqlite.i386 0:2.4-4.2 set to be updated
---> Package mono-data-sybase.i386 0:2.4-4.2 set to be updated
---> Package mono-devel.i386 0:2.4-4.2 set to be updated
--> Processing Dependency: glib2-devel for package: mono-devel
---> Package mono-extras.i386 0:2.4-4.2 set to be updated
---> Package mono-jscript.i386 0:2.4-4.2 set to be updated
---> Package mono-locale-extras.i386 0:2.4-4.2 set to be updated
---> Package mono-moonlight.i386 0:2.4-4.2 set to be updated
---> Package mono-nunit.i386 0:2.4-4.2 set to be updated
---> Package mono-nunit-devel.i386 0:2.4-4.2 set to be updated
---> Package mono-web.i386 0:2.4-4.2 set to be updated
---> Package mono-web-devel.i386 0:2.4-4.2 set to be updated
---> Package mono-winforms.i386 0:2.4-4.2 set to be updated
---> Package monodoc.i386 0:2.4-4.2 set to be updated
---> Package monodoc-devel.i386 0:2.4-4.2 set to be updated
---> Package xsp.i386 0:1.2.1-1.el5.centos set to be updated
--> Running transaction check
---> Package glib2-devel.i386 0:2.12.3-4.el5_3.1 set to be updated
---> Package libgdiplus.i386 0:2.4-5.2 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
====================================
Package Arch Version Repository Size
====================================
Installing:
mod_mono i386 1.2.1-1.el5.centos extras 36 k
mono-core i386 2.4-4.2 Mono 14 M
mono-data i386 2.4-4.2 Mono 1.5 M
mono-data-firebird i386 2.4-4.2 Mono 252 k
mono-data-oracle i386 2.4-4.2 Mono 184 k
mono-data-postgresql i386 2.4-4.2 Mono 203 k
mono-data-sqlite i386 2.4-4.2 Mono 157 k
mono-data-sybase i386 2.4-4.2 Mono 160 k
mono-devel i386 2.4-4.2 Mono 1.8 M
mono-extras i386 2.4-4.2 Mono 1.5 M
mono-jscript i386 2.4-4.2 Mono 410 k
mono-locale-extras i386 2.4-4.2 Mono 783 k
mono-moonlight i386 2.4-4.2 Mono 1.5 M
mono-nunit i386 2.4-4.2 Mono 223 k
mono-nunit-devel i386 2.4-4.2 Mono 14 k
mono-web i386 2.4-4.2 Mono 3.1 M
mono-web-devel i386 2.4-4.2 Mono 14 k
mono-winforms i386 2.4-4.2 Mono 3.0 M
monodoc i386 2.4-4.2 Mono 7.3 M
monodoc-devel i386 2.4-4.2 Mono 14 k
xsp i386 1.2.1-1.el5.centos extras 233 k
Installing for dependencies:
glib2-devel i386 2.12.3-4.el5_3.1 base 1.2 M
libgdiplus i386 2.4-5.2 Mono 1.3 M
Transaction Summary
============================================================
Install 23 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 39 M
Is this ok [y/N]: y
Downloading Packages:
(1/23): monodoc-devel-2.4-4.2.i386.rpm | 14 kB 00:00
(2/23): mono-nunit-devel-2.4-4.2.i386.rpm | 14 kB 00:00
(3/23): mono-web-devel-2.4-4.2.i386.rpm | 14 kB 00:00
(4/23): mod_mono-1.2.1-1.el5.centos.i386.rpm | 36 kB 00:04
(5/23): mono-data-sqlite-2.4-4.2.i386.rpm | 157 kB 00:01
(6/23): mono-data-sybase-2.4-4.2.i386.rpm | 160 kB 00:01
(7/23): mono-data-oracle-2.4-4.2.i386.rpm | 184 kB 00:01
(8/23): mono-data-postgresql-2.4-4.2.i386.rpm | 203 kB 00:02
(9/23): mono-nunit-2.4-4.2.i386.rpm | 223 kB 00:02
(10/23): xsp-1.2.1-1.el5.centos.i386.rpm | 233 kB 00:12
(11/23): mono-data-firebird-2.4-4.2.i386.rpm | 252 kB 00:02
(12/23): mono-jscript-2.4-4.2.i386.rpm | 410 kB 00:02
(13/23): mono-locale-extras-2.4-4.2.i386.rpm | 783 kB 00:06
(14/23): glib2-devel-2.12.3-4.el5_3.1.i386.rpm | 1.2 MB 00:23
(15/23): libgdiplus-2.4-5.2.i386.rpm | 1.3 MB 00:07
(16/23): mono-extras-2.4-4.2.i386.rpm | 1.5 MB 00:08
(17/23): mono-moonlight-2.4-4.2.i386.rpm | 1.5 MB 00:05
(18/23): mono-data-2.4-4.2.i386.rpm | 1.5 MB 00:08
(19/23): mono-devel-2.4-4.2.i386.rpm | 1.8 MB 00:06
(20/23): mono-winforms-2.4-4.2.i386.rpm | 3.0 MB 00:10
(21/23): mono-web-2.4-4.2.i386.rpm | 3.1 MB 00:18
(22/23): monodoc-2.4-4.2.i386.rpm | 7.3 MB 00:39
(23/23): mono-core-2.4-4.2.i386.rpm | 14 MB 01:17
----------------------------------------------------------------------------------------------------------------------
Total 143 kB/s | 39 MB 04:40
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID bcd4bf36
Mono/gpgkey | 1.0 kB 00:00
Importing GPG key 0xBCD4BF36 "home:mindtouch OBS Project <home:[email protected]>" from http://download.opensuse.org/repositories/home:/mindtouch:/Mono/CentOS_5/repodata/repomd.xml.key
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : glib2-devel 1/23
Installing : libgdiplus 2/23
Installing : mod_mono 3/23
Installing : mono-data 4/23
Installing : mono-winforms 5/23
Installing : mono-core 6/23
Installing : mono-devel 7/23
Installing : mono-web 8/23
Installing : mono-extras 9/23
Installing : monodoc 10/23
Installing : mono-nunit 11/23
Installing : mono-data-postgresql 12/23
Installing : mono-data-sqlite 13/23
Installing : monodoc-devel 14/23
Installing : mono-web-devel 15/23
Installing : mono-data-oracle 16/23
Installing : xsp 17/23
Installing : mono-moonlight 18/23
Installing : mono-data-sybase 19/23
Installing : mono-locale-extras 20/23
Installing : mono-nunit-devel 21/23
Installing : mono-data-firebird 22/23
Installing : mono-jscript 23/23
Installed:
mod_mono.i386 0:1.2.1-1.el5.centos mono-core.i386 0:2.4-4.2 mono-data.i386 0:2.4-4.2
mono-data-firebird.i386 0:2.4-4.2 mono-data-oracle.i386 0:2.4-4.2 mono-data-postgresql.i386 0:2.4-4.2
mono-data-sqlite.i386 0:2.4-4.2 mono-data-sybase.i386 0:2.4-4.2 mono-devel.i386 0:2.4-4.2
mono-extras.i386 0:2.4-4.2 mono-jscript.i386 0:2.4-4.2 mono-locale-extras.i386 0:2.4-4.2
mono-moonlight.i386 0:2.4-4.2 mono-nunit.i386 0:2.4-4.2 mono-nunit-devel.i386 0:2.4-4.2
mono-web.i386 0:2.4-4.2 mono-web-devel.i386 0:2.4-4.2 mono-winforms.i386 0:2.4-4.2
monodoc.i386 0:2.4-4.2 monodoc-devel.i386 0:2.4-4.2 xsp.i386 0:1.2.1-1.el5.centos
Dependency Installed:
glib2-devel.i386 0:2.12.3-4.el5_3.1 libgdiplus.i386 0:2.4-5.2
Complete!
[root@localhost yum.repos.d]#
安装后应该得到:
[root@localhost yum.repos.d]# rpm -qa|grep mono
mod_mono-1.2.1-1.el5.centos
mono-nunit-2.4-4.2
mono-data-sybase-2.4-4.2
mono-core-2.4-4.2
monodoc-devel-2.4-4.2
mono-data-firebird-2.4-4.2
mono-winforms-2.4-4.2
mono-extras-2.4-4.2
mono-data-sqlite-2.4-4.2
mono-nunit-devel-2.4-4.2
mono-data-2.4-4.2
mono-web-2.4-4.2
mono-data-postgresql-2.4-4.2
mono-data-oracle-2.4-4.2
mono-locale-extras-2.4-4.2
mono-devel-2.4-4.2
mono-web-devel-2.4-4.2
mono-jscript-2.4-4.2
monodoc-2.4-4.2
mono-moonlight-2.4-4.2
[root@localhost conf.d]# more mod_mono.conf
# mod_mono.conf
# Acthung! This file may be overwritten
# Use 'include mod_mono.conf' from other configuration file
# to load mod_mono module.
<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>
然后配置mod_mono,测试能否与apache整合:
[root@magic yum.repos.d]$ vim /etc/httpd/conf.d/mod_mono.conf
添加:
Alias /test "/usr/lib/xsp/test"
MonoApplications "/test:/usr/lib/xsp/test"
<Location /test>
SetHandler mono
</Location>
[root@magic yum.repos.d]$ /usr/sbin/httpd -t
Syntax OK
[root@magic yum.repos.d]$ chown apache.apache /usr/lib/mono/ -Rf
[root@magic yum.repos.d]$ chown apache.apache /usr/lib/xsp/ -Rf
[root@magic yum.repos.d]$ /sbin/service httpd restart
停止 httpd: [确定]
启动 httpd: [确定]
=============================
参考链接:
[root@localhost conf.d]# /usr/sbin/httpd -t
Syntax OK
[root@localhost conf.d]# ls /usr/lib/xsp/test/
1.1 extensions.dll index2.aspx monobutton.png mono-xsp.css small-icon.png
2.0 favicon.ico index.aspx mono.png sample.webapp web.config
bin global.asax mod-mono-server.exe.config mono-powered-big.png ServiceClient.exe xsp.exe.config
[root@localhost conf.d]# vi mod_mono.conf
[root@localhost conf.d]# /usr/sbin/httpd -t
Syntax OK
[root@localhost conf.d]# chown apache.apache /usr/lib/mono/ -Rf
[root@localhost conf.d]# chown apache.apache /usr/lib/xsp/ -Rf
[root@localhost conf.d]# /sbin/service httpd restart
停止 httpd: [失败]
启动 httpd:(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
[失败]
[root@localhost conf.d]# /usr/local/apache2/bin/apachectl restart
[root@localhost conf.d]# more mod_mono.conf
# mod_mono.conf
# Acthung! This file may be overwritten
# Use 'include mod_mono.conf' from other configuration file
# to load mod_mono module.
<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>
Alias /test "/usr/lib/xsp/test"
MonoApplications "/test:/usr/lib/xsp/test"
<Location /test>
SetHandler mono
</Location>
[root@localhost conf.d]# netstat -tupnl | grep 80
tcp 0 0 0.0.0.0:5801 0.0.0.0:* LISTEN 3262/Xvnc
tcp 0 0 :::80 :::* LISTEN 8350/httpd
[root@localhost bin]# service httpd restart
停止 httpd: [失败]
启动 httpd:(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
[root@localhost bin]# netstat -tupnl | grep httpd
tcp 0 0 :::80 :::* LISTEN 8350/httpd
[root@localhost bin]# ps 8350
PID TTY STAT TIME COMMAND
8350 ? Ss 0:00 /usr/local/apache2/bin/httpd -k start
[root@localhost bin]# kill -9 8350
[root@localhost bin]# netstat -tupnl | grep httpd
tcp 0 0 :::80 :::* LISTEN 10006/httpd
[root@localhost bin]# ps 10006
PID TTY STAT TIME COMMAND
10006 ? S 0:00 /usr/local/apache2/bin/httpd -k start
[root@localhost bin]# kill -9 10006
[root@localhost bin]# netstat -tupnl | grep httpd
tcp 0 0 :::80 :::* LISTEN 10007/httpd
[root@localhost bin]# apachectl start
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
apachectl 服务杀不干净,使用下面的方法。
[root@localhost bin]# kill -9 $(ps -ef | grep httpd | awk '{print $2}')
-bash: kill: (10352) - 没有那个进程
[root@localhost bin]# netstat -tupnl | grep httpd
[root@localhost bin]# apachectl start
[root@localhost bin]# netstat -tupnl | grep httpd
tcp 0 0 :::80 :::* LISTEN 10387/httpd
最后成功安装并可测试:
http://192.168.1.58/test/
Welcome to Mono XSP!
XSP is a simple web server written in C# that can be used to run your ASP.NET applications
Here are some ASP.NET examples:
……
rpm安装的XSP的目录结构
/usr/bin/xsp
/usr/lib/mono/gac/xsp
/usr/lib/xsp
/usr/share/doc/packages/xsp
rpm 安装 mono 的目录结构
/etc/mono
/usr/bin/mono
/usr/lib/mono
/usr/share/mono-1.0/mono
/usr/include/mono-1.0/mono
/usr/lib/xsp/test测试目录