技术交流平台

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 3084|回复: 0

Linux搭建asp.net运行环境

[复制链接]

183

主题

195

帖子

1690

积分

新手上路

Rank: 1

积分
1690

活跃会员

发表于 2014-4-9 17:35:26 | 显示全部楼层 |阅读模式
本帖最后由 love_china 于 2014-4-9 17:45 编辑

      本文所搭建asp.net运行环境,是以apache作为通讯框架,mod_mono(apache的插件)作为接口桥,连接apache与xsp的通讯,xsp最终负责asp.net的服务处理,xsp会监听本地端口用来与mod_mono通讯,后者将处理结果返回给apache,apache再返回给客户端。
1.外围配置#安装完CentOS后,首先更新系统
  1. yum -y update
复制代码

#然后安装相关的编译器和必备的软件
  1. yum install bison make gcc gcc-c++ libstdc++-devel gettext pkgconfig glib2-devel
复制代码


2.下载所需软件包
  1. mkdir -p /tools
  2. cd /tools
  3. wget <a href="http://ftp.novell.com/pub/mono/sources/libgdiplus/libgdiplus-2.10.tar.bz2" target="_blank">http://ftp.novell.com/pub/mono/sources/libgdiplus/libgdiplus-2.10.tar.bz2</a>
  4. wget <a href="http://ftp.novell.com/pub/mono/sources/mono/mono-2.10.2.tar.bz2" target="_blank">http://ftp.novell.com/pub/mono/sources/mono/mono-2.10.2.tar.bz2</a>
  5. wget <a href="http://ftp.novell.com/pub/mono/sources/xsp/xsp-2.10.2.tar.bz2" target="_blank">http://ftp.novell.com/pub/mono/sources/xsp/xsp-2.10.2.tar.bz2</a>
  6. wget <a href="http://ftp.novell.com/pub/mono/sources/mod_mono/mod_mono-2.10.tar.bz2" target="_blank">http://ftp.novell.com/pub/mono/sources/mod_mono/mod_mono-2.10.tar.bz2</a>
  7. wget <a href="http://labs.renren.com/apache-mirror/httpd/httpd-2.2.21.tar.gz" target="_blank">http://labs.renren.com/apache-mirror/httpd/httpd-2.2.21.tar.gz</a>
复制代码


3.安装libgdiplus
libgdiplus是mono中的System.Drawing依赖的一个组件,用于显示web页面基本颜色等。目前最新是libgdiplus-2.10。

  1. <p>tar -xjvf libgdiplus-2.10.tar.bz2</p><p>cd libgdiplus-2.10</p><p>./configure --prefix=/usr/local</p><p>make</p><p>make install</p>
复制代码

./configure –prefix=/usr/local,这是源代码安装的第一步,主要的作用是对即将安装的软件进行配置,检查当前的环境是否满足要安装软件的依赖关系。当完成配置出现如下信息时,说明依赖关系全都具备,可以开始安装libgdiplus。

Configuration summary

   * Installation prefix = /usr/local
   * Cairo = 1.6.4 (internal)
   * Text = cairo
   * EXIF tags = yes
   * Codecs supported:

      - TIFF: yes
      - JPEG: yes
      - GIF: yes
      - PNG: yes
      NOTE: if any of the above say 'no' you may install the
            corresponding development packages for them, rerun
            autogen.sh to include them in the build.


如果出现如下信息:

configure: WARNING: *** TIFF plug-in will not be built (TIFF library not found) ***
checking for jpeg_destroy_decompress in -ljpeg... no
configure: WARNING: *** JPEG loader will not be built (JPEG library not found) ***
checking for DGifOpenFileName in -lgif... no
configure: WARNING: *** GIF loader will not be built (giflibrary not found) ***
checking for DGifOpenFileName in -lungif... no
configure: WARNING: *** GIF loader will not be built (ungiflibrary not found) ***
checking for libpng12... no
checking for png_read_info in -lpng... no
configure: error: *** libpng12 not found.See http://www.libpng.org/pub/png/libpng.html.


说明缺少libtiff、libjpeg、libgif、libpng等库,安装这些库:

yum install libtiff libtiff-devel libjpeg libjpeg-devel giflib giflib-devel libpng libpng-devel libX11 libX11-devel freetype freetype-devel fontconfig fontconfig-devel libexif libexif-devel


4.安装mono

  1. <p>cd /tool</p><p>tar -xjvf mono-2.10.2.tar.bz2</p><p>cd mono-2.10.2</p><p>./configure --prefix=/usr/local</p><p>make</p><p>make install</p>
复制代码


Mono安装完成之后,可以用命令mono -V查看一下mono的安装情况,如果能够看到mono版本号等信息,说明Mono安装成功。
Mono JIT compiler version 2.10.2 (tarball Thu Jan  5 17:34:42 CST 2012)
Copyright (C) 2002-2011 Novell, Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  x86
        Disabled:      none
        Misc:          softdebug
        LLVM:          supported, not enabled.
        GC:            Included Boehm (with typed GC and Parallel Mark)



5.安装apache


  1. <p><font size="3">cd /tool</font></p><p><font size="3">tar -xzvf httpd-2.2.21.tar.gz</font></p><p><font size="3">cd httpd-2.2.21</font></p><p><font size="3">./configure --prefix=/usr/local/apache --enable-mods-shared=most</font></p><p><font size="3">make</font></p><p><font size="3">make install</font></p>
复制代码



6.安装mod_mono


  1. <p><font size="3">cd /tool</font></p><p><font size="3">tar -xjvf mod_mono-2.10.tar.bz2</font></p><p><font size="3">cd mod_mono-2.10</font></p><p><font size="3">./configure</font></p><p><font size="3">make</font></p><p><font size="3">make install</font></p>
复制代码



./configure配置信息如下:

Configuration summary for mod_mono

   * Installation prefix = /usr/local
   * Apache version = 2.2
   * Apache modules directory = /usr/local/apache/modules
   * apxs = /usr/local/apache/bin/apxs
   * apr-config = /usr/local/apache/bin/apr-1-config
   * apu-config = /usr/local/apache/bin/apu-1-config
   * CFLAGS = -g -O2 -I/usr/local/apache/include  -g -O2 -pthread  -I/usr/local/apache/include  -g -O2 -pthread  -I/usr/local/apache/include
   * Verbose logging (debug) = no
   * GCOV options used = no
   * Profiling enabled = no
   * mono prefix = /usr/local
   * Default MonoApplicationsConfigDir = /usr/local/apache/conf/mod-mono-applications




7.安装xsp
xsp就是mod-mono-server。

cd /tool
tar -xjvf xsp-2.10.2.tar.bz2
cd xsp-2.10.2
./configure --prefix=/usr/local
make
make install


如果在./configure的时候出现

checking for MONO_MODULE... configure: error: Package requirements (mono >= 2.10.0) were not met:

No package 'mono' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables MONO_MODULE_CFLAGS
and MONO_MODULE_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.


则需要设置环境变量:

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig


8.配置apache
打开/usr/local/apache/conf文件夹中的httpd.conf,这个文件是apache的配置文件,在最后添加
  1. Include /usr/local/apache/conf/mod_mono.conf
复制代码


将以下#注释去掉
  1. #ServerName <a href="http://www.example.com:80" target="_blank">www.example.com:80</a>
复制代码


在/usr/local/apache/htdocs文件夹中任意创建一个index.aspx文件,添加内容如下

<%@ Page Language="C#" %>
<html>
<head>
<title>hello world</title>
</head>
<body>
<%
for (int i=1; i<=7; i++)
{
Response.Write("<font size=" + i.ToString() + ">");
Response.Write("hello world");
Response.Write("</font><br />");
}
%>
</body>
</html>


重启apache
  1. /usr/local/apache/bin/apachectl restart
复制代码


通过浏览器访问http://localhost/index.aspx或者http://IP/index.aspx,如果在页面上出现”hello world“等信息,说明asp.net环境已经搭建成功。
转自http://www.saih.cn/tech/?p=125


您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

点击这里给我发消息” title=|小黑屋|手机版|法律声明|技术交流平台 ( 冀ICP备14003130号 | 冀公网安备13018102000122号)

GMT+8, 2024-5-9 00:21 , Processed in 2.324903 second(s), 37 queries , Gzip On.

Powered by Discuz! X3.4

© 2001-2021 Comsenz Inc.

快速回复 返回顶部 返回列表