温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

CentOS下怎么实现Mono和Asp.net

发布时间:2022-04-11 16:56:55 来源:亿速云 阅读:106 作者:zzz 栏目:编程语言

这篇文章主要介绍“CentOS下怎么实现Mono和Asp.net”,在日常操作中,相信很多人在CentOS下怎么实现Mono和Asp.net问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”CentOS下怎么实现Mono和Asp.net”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

下载编译环境:
yum install gcc bison pkgconfig glib2-devel gettext make httpd-devel gcc-c++ libstdc++-devel

下载并解压源代码:
wget
wget
wget
tar -jxvf mono-2.6.3.tar.bz2
tar -jxvf xsp-2.6.3.tar.bz2
tar -jxvf mod_mono-2.6.3.tar.bz2

安装mono环境:
cd /root/mydir/mono-2.6.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

安装xsp:
cd /root/mydir/xsp-2.6.3
./configure --prefix=/opt/mono; make ; make install

安装mod_mono:
先用find / -iname apr*config命令查找出“--with-apr-config=/usr/bin/apr-1-config”(不知道--with-apr-config=/usr/bin/apr-1-config有什么用,好像不要也可以,麻烦知道的告诉一下小弟)
再执行下面的命令:
cd /root/mydir/mod_mono-2.6.3
./configure --prefix=/opt/mono --with-mono-prefix=/opt/mono --with-apr-config=/usr/bin/apr-1-config; make ; make install
cp /etc/httpd/conf.d/ /etc/httpd/conf/mod_mono.conf

selinux阻止了httpd对mod-mono-server的访问,所以执行下面的语句:
setsebool -p httpd_disable_trans=1

重启httpd服务器
service httpd restart

在防火墙中开启80端口,允许同一个lan的其他机器访问:
方法1.在不使用图形界面工具的时候,通过关闭防火墙来实现允许开放80端口
service iptables stop
(ps:我尝试过下面的方法,
vi /etc/sysconfig/iptables
添加:-a rh-firewall-1-input -m state --state new -m tcp -p tcp --dport 80 -j accept
service iptables restart
虽然在iptables -l中看到http
但无法从其他机器访问该服务器。
如果有谁成功,请告知小弟):

方法2.在安装有图形界面工具的情况下,用startx进入图形界面,用“security level and firewall”开启80端口。

安装libgdiplus(xsp的测试页面中,有很多都需要libgdiplus):
yum install httpd build-essential gcc bzip bison pkgconfig glib-devel \
glib2-devel httpd-devel libpng-devel libx11-devel freetype fontconfig \
pango-devel ruby ruby-rdoc gtkhtml38-devel wget
wget
tar -jxvf libgdiplus-2.6.2.tar.bz2
cd /root/mydir/libgdiplus-2.6.2
./configure
make ; make install
echo export ld_library_path=/usr/local/lib/:$ld_library_path >>~/.bash_profile
source ~/.bash_profile

vi /opt/mono/etc/mono/config
添加节点:<dllmap dll="gdiplus.dll" target="/usr/lib/libgdiplus.so.0" />
否则会出现dllnotfoundexception的异常。

测试:
一、测试mono
a.运行mono -v输出:
mono jit compiler version 2.6.3 (tarball fri apr 2 06:13:46 cst 2010)
copyright (c) 2002-2010 novell, inc and contributors.
tls: __thread
gc: included boehm (with typed gc and parallel mark)
sigsegv: altstack
notifications: epoll
architecture: x86
disabled: none
b.运行mono-test-install输出:
active mono: /opt/mono/bin/mono
your have a working system.drawing setup
your file system watcher is: system.io.inotifywatcher

二、测试asp.net服务器
a.测试是否能够执行aspx:
在/var/www/html/目录下建一个test.aspx页面,内容为
<%="hello world!"%>
通过wget 来下载该页面的内容。

b.测试同一个lan下其他机器能否访问:
用其他机器的浏览器打开

c.跑xsp自带的测试程序(多点几个页面,查看是否会出现gdiplus.dll dllnotfoundexception的一场):
1.修改apache的配置,开放防火墙8080端口
listen 8080
namevirtualhost *:8080
<virtualhost *:8080>
serveradmin
documentroot /var/www/test/
servername local.mydomain.com
errorlog logs/local.mydomain.com-error_log
customlog logs/local.mydomain.com common
</virtualhost>
2.复制/opt/mono/lib/xsp/test目录到var/www/下
3.service httpd restart
4.用浏览器打开

到此,关于“CentOS下怎么实现Mono和Asp.net”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI