Mono Web除了可以使用Apache/mod_mono方式承載執行外,還可以使用Nginx/FastCGI方式執行。
Nginx配置asp.net更簡單方便,用處也多,可以通過FastCGI執行asp.net, php等,通過反向代理做負載均衡,也可執行python web.
以Ubuntu為例
配置nginx (/etc/nginx/sites-available/default),讓站點根目錄以FastCGI方式執行
server { listen 80; root /usr/share/nginx/www; index index.html index.htm; server_name localhost; access_log /var/log/nginx/chat.log; location / { root /var/www/chat; index default.aspx default.html; fastcgi_index Default.aspx; fastcgi_pass 127.0.0.1:8099; include /etc/nginx/fastcgi_params; } }
編輯/etc/nginx/fastcgi_params
fastcgi_param PATH_INFO ""; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
安裝fastcgi-mono-server4模組
apt-get install fastcgi-mono-server4
執行FastCGI Mono
fastcgi-mono-server4 /applications=/:/var/www/chat/ /socket=tcp:127.0.0.1:8099
# just via domain visit fastcgi-mono-server4 /applications=www.domain.com:/:/var/www/chat/ /socket=tcp:127.0.0.1:8099
注:applications={URL訪問地址Path}:{物理路徑},與上面的nginx config一致,URL訪問地址可以使用域名。如此地址配置錯誤,會報異常"No Application Found"匹配不到