测试环境
CentOS 5.2,Apache 2.2.3
配置Apache
打开Apache 配置文件httpd.conf,位置参考:/etc/httpd/conf/httpd.conf
在配置文件中确保mod_write、mod_mime 模块已加载:
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule mime_module modules/mod_mime.so
随后在配置文件中加入MIME 信息(经测试不加也能运行SL):
AddType application/xaml+xml .xaml
AddType application/x-silverlight-app .xap
AddType application/x-ms-xbap .xbap
保存httpd.conf,并退出编辑模式,重启Apache 服务:
service httpd restart
加载Silverlight
由于SL 是客户端运行,所以Server 上其实不用做太多设置,下面将xap 程序加载到HTML即可。新建一个PHP 程序加入下面代码:
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="500px"> <param name="source" value="AutoCompleteBox.xap" /> <param name="onError" value="onSilverlightError" /> <param name="background" value="white" /> <param name="minRuntimeVersion" value="3.0.40624.0" /> <param name="autoUpgrade" value="true" /> <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration:none"> <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none" /> </a> </object>
相关资料
Silverlight Mime types in IIS6 and Apache
Run Silverlight with Apache Server (Under linux)
How to: Add Silverlight to a Web Page by Using HTML
转载:http://www.cnblogs.com/gnielee/archive/2011/04/06/silverlight-on-apache-linux.html