調皮搗蛋 發表於 2023-11-30 00:00:00

CentOS 5.1下跑Mono和Asp.net的实现方法

<p>
        下载编译环境:<br>
        yum install gcc bison pkgconfig glib2-devel gettext make httpd-devel gcc-c++ libstdc++-devel<br><br>
        下载并解压源代码:<br>
        wget http://ftp.novell.com/pub/mono/sources/mono/mono-2.6.3.tar.bz2<br>
        wget http://ftp.novell.com/pub/mono/sources/mod_mono/mod_mono-2.6.3.tar.bz2<br>
        wget http://ftp.novell.com/pub/mono/sources/xsp/xsp-2.6.3.tar.bz2<br>
        tar -jxvf mono-2.6.3.tar.bz2<br>
        tar -jxvf xsp-2.6.3.tar.bz2<br>
        tar -jxvf mod_mono-2.6.3.tar.bz2<br><br>
        安装mono环境:<br>
        cd /root/mydir/mono-2.6.3<br>
        ./configure --prefix=/opt/mono; make ; make install<br>
        echo export PKG_CONFIG_PATH=/opt/mono/lib/pkgconfig:$PKG_CONFIG_PATH&gt;&gt;~/.bash_profile<br>
        echo export PATH=/opt/mono/bin:$PATH&gt;&gt;~/.bash_profile<br>
        source ~/.bash_profile<br><br>
        安装xsp:<br>
        cd /root/mydir/xsp-2.6.3<br>
        ./configure --prefix=/opt/mono; make ; make install<br><br>
        安装mod_mono:<br>
        先用find / -iname apr*config命令查找出“--with-apr-config=/usr/bin/apr-1-config”(不知道--with-apr-config=/usr/bin/apr-1-config有什么用,好像不要也可以,麻烦知道的告诉一下小弟)<br>
        再执行下面的命令:<br>
        cd /root/mydir/mod_mono-2.6.3<br>
        ./configure --prefix=/opt/mono --with-mono-prefix=/opt/mono --with-apr-config=/usr/bin/apr-1-config; make ; make install<br>
        cp /etc/httpd/conf.d/ /etc/httpd/conf/mod_mono.conf<br><br>
        selinux阻止了httpd对mod-mono-server的访问,所以执行下面的语句:<br>
        setsebool -P httpd_disable_trans=1<br><br>
        重启httpd服务器:<br>
        service httpd restart<br><br>
        在防火墙中开启80端口,允许同一个Lan的其他机器访问:<br>
        方法1.在不使用图形界面工具的时候,通过关闭防火墙来实现允许开放80端口<br>
        service iptables stop<br>
        (PS:我尝试过下面的方法,<br>
        vi /etc/sysconfig/iptables<br>
        添加:-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT<br>
        service iptables restart<br>
        虽然在iptables -L中看到http<br>
        但无法从其他机器访问该服务器。<br>
        如果有谁成功,请告知小弟):<br><br>
        方法2.在安装有图形界面工具的情况下,用startx进入图形界面,用“Security Level and Firewall”开启80端口。<br><br>
        安装libgdiplus(xsp的测试页面中,有很多都需要libgdiplus):<br>
        yum install httpd build-essential gcc bzip bison pkgconfig glib-devel \<br>
        glib2-devel httpd-devel libpng-devel libX11-devel freetype fontconfig \<br>
        pango-devel ruby ruby-rdoc gtkhtml38-devel wget<br>
        wget http://ftp.novell.com/pub/mono/sources/libgdiplus/libgdiplus-2.6.2.tar.bz2<br>
        tar -jxvf libgdiplus-2.6.2.tar.bz2<br>
        cd /root/mydir/libgdiplus-2.6.2<br>
        ./configure<br>
        make ; make install<br>
        echo export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH &gt;&gt;~/.bash_profile<br>
        source ~/.bash_profile<br><br>
        vi /opt/mono/etc/mono/config<br>
        添加节点:&lt;dllmap dll="gdiplus.dll" target="/usr/lib/libgdiplus.so.0" /&gt;<br>
        否则会出现DllNotFoundException的异常。<br><br>
        测试:<br>
        一、测试mono<br>
        a.运行mono -V输出:<br>
        Mono JIT compiler version 2.6.3 (tarball Fri Apr 2 06:13:46 CST 2010)<br>
        Copyright (C) 2002-2010 Novell, Inc and Contributors. http://www.mono-project.com/<br>
        TLS: __thread<br>
        GC: Included Boehm (with typed GC and Parallel Mark)<br>
        SIGSEGV: altstack<br>
        Notifications: epoll<br>
        Architecture: x86<br>
        Disabled: none<br>
        b.运行mono-test-install输出:<br>
        Active Mono: /opt/mono/bin/mono<br>
        Your have a working System.Drawing setup<br>
        Your file system watcher is: System.IO.InotifyWatcher<br><br>
        二、测试Asp.Net服务器<br>
        a.测试是否能够执行aspx:<br>
        在/var/www/html/目录下建一个test.aspx页面,内容为<br>
        &lt;%="Hello World!"%&gt;<br>
        通过wget http://localhost/test.aspx来下载该页面的内容。<br><br>
        b.测试同一个Lan下其他机器能否访问:<br>
        用其他机器的浏览器打开http://ip/test.aspx<br><br>
        c.跑xsp自带的测试程序(多点几个页面,查看是否会出现gdiplus.dll DllNotFoundException的一场):<br>
        1.修改Apache的配置,开放防火墙8080端口<br>
        Listen 8080<br>
        NameVirtualHost *:8080<br>
        &lt;VirtualHost *:8080&gt;<br>
        ServerAdmin hlfstephen@gmail.com<br>
        DocumentRoot /var/www/test/<br>
        ServerName local.mydomain.com<br>
        ErrorLog logs/local.mydomain.com-error_log<br>
        CustomLog logs/local.mydomain.com common<br>
        &lt;/VirtualHost&gt;<br>
        2.复制/opt/mono/lib/xsp/test目录到var/www/下<br>
        3.service httpd restart<br>
        4.用浏览器打开http://ip:8080/</p>
<p>
        参考:<br>
        http://blog.rubypdf.com/2009/10/23/how-to-install-mono-2-4-2-3-on-centos-5/<br>
        http://blog.rubypdf.com/2009/10/23/how-to-install-xsp-and-integrate-xsp-with-apache-2-under-centos-5/<br>
        http://blog.bennyland.com/2010/02/06/serving-asp-net-pages-in-apache-on-centos-5/<br>
        http://mingster.com/site/?q=content/mono-2x-centos-5<br>
        http://mono-project.com/DllNotFoundException<br>
        http://mono-project.com/Config_DllMap</p>
頁: [1]
查看完整版本: CentOS 5.1下跑Mono和Asp.net的实现方法