安装步骤:
1、下载程序源码(大家可以进入官网下载)
- Nginx 源码包: http://nginx.org/download/nginx-1.2.4.tar.gz
- Mono 源码包:http://download.mono-project.com/sources/mono/
- xsp 源码包:http://download.mono-project.com/sources/xsp/xsp-2.10.2.tar.bz2
- 这里将下载回来的3个源码包编译并安装,安装过程中如果提醒缺少组件,大家自己安装即可。
- 一些需要主要使用的组件,通过yum来安装:
yum install gcc gcc-c++ glibc glibc-devel glib2
- 编译安装Nginx:
tar -zxvf nginx- 1.2. 4.tar.gz
cd nginx- 1.2. 4/
./configure
make && make install
- 编译安装Mono:
tar -jxvf mono- 2.11. 4.tar.bz2
cd mono- 2.11. 4/
./configure --prefix=/opt/mono- 2.11
makemake 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
- 安装xsp:
tar -jxvf xsp- 2.10. 2.tar.bz2
cd xsp- 2.10. 2/
./configure --prefix=/opt/mono- 2.11make && make install
4、配置Nginx
- 添加fastcgi参数:
vi /usr/ local/nginx/conf/fastcgi_params
--添加2行
fastcgi_param PATH_INFO "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- 添加Nginx服务器,监听9999端口:
vi /usr/ local/nginx/conf/nginx.conf
--添加一个服务器
server{
listen 9999;
server_name netserver;
location /{
root html/end;
index index.html;
fastcgi_index /Home;
fastcgi_pass 127.0. 0.1: 9900;
include /usr/ local/nginx/conf/fastcgi_params;
}
}
5、上传MVC3 Web程序(名称:MvcTest)
- 使用VS2010新建一个MVC3 Web程序,将以下引用dll复制本地
System.Data.dll
System.Web.ApplicationServices.dll
System.Web.DynamicData.dll
System.Web.Helpers.dll
System.Web.Mvc.dll
System.Web.Routing.dll
System.Web.WebPages.Deployment.dll
System.Web.WebPages.dll
System.Web.WebPages.Razor.dll
- 手工将System.Web.Razor.dll复制到bin目录下
dll所在目录 C:\Program Files\Microsoft ASP.NET\ASP.NET Web Pages\v1. 0\Assemblies
- 上传程序到Nginx的Web目录里(如不存在目录则创建)
/usr/ local/nginx/html/end/
6、测试MVC程序是否正常执行
- 进入MvcTest目录
cd /usr/ local/nginx/html/end/MvcTest
- 运行xsp4
xsp4
Listening on address: 0.0. 0.0
Root directory: /usr/ local/nginx/html/end/MvcTest
Listening on port: 8080 (non-secure)
Hit Return to stop the server.
- 使用浏览器通过8080端口测试访问,如果正常运行,恭喜你!如果出现错误,需要解决错误后才能接着往下配置。(下面列了一些常见错误及解决方法)
7、启动Nginx、fastcgi_server
- 启动Nginx
/usr/ local/nginx/sbin/nginx
- 启动fastcgi_server
fastcgi-mono-server4 /applications=/:/usr/ local/nginx/html/end/MvcTest/ / socket=tcp: 127.0. 0.1: 9900 /printlog=True
- fastcgi_server后台运行方法(后台长时间运行)
nohup fastcgi-mono-server4 /applications=/:/usr/ local/nginx/html/end/MvcTest/ / socket=tcp: 127.0. 0.1: 9900 /printlog=True &
8、所有问题解决以后就可以正常运行基本的MVC3程序了,欢呼吧~~
- xsp4启动时报错
解决方法:移除程序bin目录下System.Web.dll
- 页面显示BadGateway,后台报错 System.TypeInitializationException: An exception was thrown by the type initializer for Mono.WebServer.FastCgi.WorkerRequest
--解决方法:在/opt/mono- 2.11/bin 下新建prefix.sh,并运行
# !/bin/bash
# Your mono directory
PREFIX=/opt/mono-2.11
FILES=(
' fastcgi-mono-server4 '
' xsp4 ')
cd $PREFIX/lib/mono/ 4.0
for file in " $FILES "
do
cp " $file.exe " ../ 4.5
done
cd $PREFIX/bin
for file in " $FILES "
do
sed -ie ' s|mono/4.0|mono/4.5|g ' $file
done
- 页面报参数不能为空:System.ArgumentNullException Argument cannot be null. Parameter name: key;
System.Resources.MissingManifestResourceException: Could not find any
resources appropriate for the specified culture or the neutral
culture. Make sure "System.Web.Mvc.Resources.MvcResources.resources"
was correctly embedded or linked into assembly "System.Web.Mvc" at
compile time, or that all the satellite assemblies required are
loadable and fully signed.
--解决方法:修改Web.config,在system.web节点下添加
<globalization uiCulture= " en " culture= " en-US " />
所有评论(0)