CentOS搭建Nginx+Mono運行ASP.NET環境

安裝步驟:html

1、獲取開源相關程序nginx

一、利用CentOS Linux系統自帶的yum命令安裝、升級所需的程序庫:c++

 

 

sudo -sweb

LANG=Cubuntu

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瀏覽器

二、下載程序源碼包bash

Nginx安裝包:下載地址:http://nginx.org/en/download.html服務器

 

 

mkdir -p /downapp

checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for MONO_MODULE... no
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.

cd /downasp.net

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

2、安裝編譯Nginx

一、安裝安裝Nginx所需的pcre庫

 

 

cd /down

tar zxvf pcre-8.21.tar.gz

cd pcre-8.21/

./configure

make && make install

cd ../

二、建立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

三、安裝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 ../

四、開放80端口

 

 

iptables -I INPUT -p tcp --dport 80 -j ACCEPT

啓動nginx

1

/opt/nginx/sbin/nginx

在瀏覽器上輸入訪問地址 http://192.168.1.1(根據我的本機地址頁定),正常會看到默認nginx頁面

3、安裝編譯Mono

一、安裝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

二、安裝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版本信息,則安裝成功.

三、安裝XSP

 

 

cd /down

tar –jxvf xsp-2.10.2.tar.bz2

./configure --prefix=/opt/mono

make && make install

 

出現這樣說明安裝成功

4、配置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;

      }

}

5、配置fastcgi_params增長下面兩行

 

vi /opt/nginx/conf/fastcgi_params

fastcgi_param PATH_INFO "";

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

6、啓動

一、重啓nginx

 

/opt/nginx/sbin/nginx -s reload

二、啓動 fastcgi_mono服務器

 

 

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

7、測試

新建一個asp.net Web項目上傳至 /data0/web目錄下,測試運行。

 

問題總結:

1.安裝xsp的時候提示問題

checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for MONO_MODULE... no
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.

出現這個問題是由於找不到pkgconfig配置文件

找到剛纔的安裝目錄

./configure --prefix=/opt/mono
export PKG_CONFIG_PATH=/opt/mono/lib/pkgconfig

2.安裝xsp的時候還會有個提示,gmcs、dmcs的錯誤

#cp /opt/mono/bin/* /usr/bin

好了。。

3.no package "cairo" found

運行

ubuntu添上 

yum -y install libcairo2-dev

 

CentOS添上 

yum -y install cairo-devel。

 

解決

相關文章
相關標籤/搜索