centos下linux运行asp网站搭建配置-mono+nginx

一、首先安装一些需要的软件包

1、  首先更新CentOS上的软件包:yum –y update。

2、  安装一些需要的库:

yum -y install gcc gcc-c++ bison pkgconfig glib2-devel gettext make libpng-devel libjpeg-devel libtiff-devel libexif-devel giflib-devel libX11-devel freetype-devel fontconfig-devel  cairo-devel

yum –y install build-essential automake autoconf libtool bison libglib2.0-dev libfreetype6-dev libfontconfig-dev gettext libgif-dev libtiff4-dev libpng12-dev libexif-dev libx11-dev libxft-dev libjpeg-dev

以上的包挺多的,但是为了保险起见,还是全部安装吧,有可能还会有缺少包的情况,就使用yum自己安装吧。

二、下载所需要的软件包

 

Nginx安装包:下载地址:http://nginx.org/en/download.html

mkdir -p /down
cd /down
wget http://nginx.org/download/nginx-1.6.0.tar.gz

Mono下载:官网:http://download.mono-project.com/sources/mono/(请下载最新版)

wget http://download.mono-project.com/sources/mono/mono-3.2.3.tar.bz2

2、  Libgdiplus:

wget http://download.mono-project.com/sources/libgdiplus/libgdiplus-2.10.9.tar.bz2

3、  xsp:xsp是Mono提供的一个测试版本的服务器,但是也提供Nginx运行asp.net的fastcgi。

官网上的xsp是2.x的,这个版本的fastcgi-mono-server4不能用;所以需要从github上下载最新的3.0版本。(Git之前,要使用yum –y intall git安装git包。)

Yum –y install git。

Git clone https://github.com/mono/xsp.git

4、  pcre:

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.33.tar.bz2

2、  安装libgdiplus:

复制代码
cd /usr/local/src

tar –jxvf libgdiplus-2.10.9.tar.bz2

cd libgdiplus-2.10.9

./configure –prefix=/usr

Make && make install

ldconfig
复制代码

3、  安装xsp:

cd /usr/local/src/xsp

./autogen.sh –prefix=/usr

make && make install

4、  安装pcre:

复制代码
cd /usr/local/src

tar –jxvf pcre-8.33.tar.bz2

cd pcre-8.33

./configure –prefix=/usr

make && make install

、安装Nginx

tar zxvf nginx-1.1.11.tar.gz
cd nginx-1.1.11/
./configure --user=www --group=www --prefix=/opt/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
cd ../

4、开放80端口:

iptables -I INPUT -p tcp --dport 80 -j ACCEPT
启动nginx 
/opt/nginx/sbin/nginx

在浏览器上输入访问地址 http://192.168.1.1(根据个人本机地址页定),正常会看到默认nginx页面

 

三、安装编译Mono

1、安装libgdiplus:

复制代码
cd /down

tar -jxvf libgdiplus-2.10.tar.bz2
cd libgdiplus-2.10
./configure --prefix=/opt/mono 
make && make install
echo "/opt/mono/lib" > /etc/ld.so.conf.d/mono.conf
ldconfig 

2、安装Mono:

复制代码
tar –jxvf mono-2.10.7.tar.bz2
cd mono-2.10.7
./configure --prefix=/opt/mono
make && make install //此处时间较长

echo export PKG_CONFIG_PATH=/opt/mono/lib/pkgconfig:$PKG_CONFIG_PATH>>~/.bash_profile
echo export LD_LIBRARY_PATH=/opt/mono/lib:$LD_LIBRARY_PATH>>~/.bash_profile
echo export PATH=/opt/mono/bin:$PATH>>~/.bash_profile
source ~/.bash_profile
复制代码

 输入 mono -V 如有mono版本信息,则安装成功. 

四、配置Nginx

vi /opt/nginx/conf/nginx.conf
复制代码
server {
         listen   80;
         server_name  localhost;
         location / {
                 root /data0/web;
                 index index.html index.htm;
                 fastcgi_index Default.aspx;
                 fastcgi_pass 127.0.0.1:9000;
                 include fastcgi_params;
         }
 }
复制代码

 

五、配置fastcgi_params增加下面两行:

vi /opt/nginx/conf/fastcgi_params
fastcgi_param  PATH_INFO          "";
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

 

六、启动:

1、重启nginx:

/opt/nginx/sbin/nginx -s reload

2、启动 fastcgi_mono服务器

fastcgi-mono-server4 /applications=/:/data0/web /socket=tcp:127.0.0.1:9000 &

 

在/data0/web下方个Default.aspx , 然后通过浏览器访问 这个机器的Ip即可,看到了Default.aspx的内容就OK了。

参考:

http://www.cnblogs.com/acles/archive/2013/09/11/3313716.html

http://www.cnblogs.com/wander1129/archive/2011/12/16/mono.html

http://www.cnblogs.com/aquilahkj/archive/2011/11/03/2234380.html

posted @ 2016-10-22 16:41  快乐就好  阅读(1788)  评论(0编辑  收藏  举报