Thomson-Blog ( 学习,学习,再学习;努力,努力,再努力。)
在学习的路上不断成长,成功之路就在脚下。

安装步骤:

一、获取开源相关程序:

1、利用CentOS Linux系统自带的yum命令安装、升级所需的程序库:

sudo -s
LANG=C
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel bison pkgconfig glib2-devel gettext make

2、下载程序源码包:

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

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

 

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

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

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

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

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

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

pcre下载(Nginx所需的pcre库):ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/(请下最新版)

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.gz

二、安装编译Nginx:

1、安装安装Nginx所需的pcre库:

复制代码
cd /down
tar zxvf pcre-8.21.tar.gz
cd pcre-8.21/
./configure
make && make install
cd ../
复制代码

2、创建www用户和组

/usr/sbin/groupadd www
/usr/sbin/useradd -g www www
mkdir -p /data0/web
chmod +w /data0/web
chown -R www:www /data0/web

3、安装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版本信息,则安装成功. 

3、安装XSP:

cd /down
tar –jxvf xsp-2.10.2.tar.bz2
./configure --prefix=/opt/mono
make && make install

 

2.安装Mono的fastcgi插件

sudo apt-get install mono-fastcgi-server

 

3.配置Nginx

(1) sudo vi /etc/nginx/nginx.conf

(2) 在http结点中加入以下配置:

复制代码
server {
    listen 80;
    server_name localhost;
    location ~ {
        root /var/www;  #网站根目录
        index Default.aspx default.aspx index.aspx Index.aspx index.html index.htm default.htm;
        fastcgi_pass 127.0.0.1:8080;  #fastcgi的监听端口
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
    }
}
复制代码

* 蓝色字体部分可自定义,例如root /home/clotho/website和127.0.0.1:8210

 

(3) sudo vi /etc/nginx/sites-available/default

(4) 将上面location~结点(nginx.conf)的内容复制到server结点(default)中

 

(5) ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default

* 在安装Nginx时已生成default的链接文件,所以这一步也可以跳过

 

(6) sudo vi /etc/nginx/fastcgi_params

(7) 在fastcgi_params加入以下配置:

fastcgi_param PATH_INFO "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

* 这两行是运行ASP.NET MVC必需,不加的话只能运行ASP.NET WebForm

 

4.启动Nginx

sudo /etc/init.d/nginx start

 

5.启动fastcgi

sudo fastcgi-mono-server /socket=tcp:8080 /address=127.0.0.1 /applications=/:/var/www

* 如果上面蓝色字体部分用自定义的,这里也要跟着对应,例如:

sudo fastcgi-mono-server /socket=tcp:8210 /address=127.0.0.1 /applications=/:/home/clotho/website

 

四、配置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-server2 /applications=/:/data0/web /socket=tcp:127.0.0.1:9000 &

 

七、测试:

新建一个asp.net web项目上传至 /data0/web目录下,测试运行。

posted on 2013-10-25 09:37  Thomson-Blog  阅读(255)  评论(0编辑  收藏  举报