標籤:
Mono Web除了可以使用Apache/mod_mono方式承載運行外,還可以使用Nginx/FastCGI方式運行。
Nginx配置asp.net更簡單方便,用處也多,可以通過FastCGI運行asp.net, php等,通過反向 Proxy做負載平衡,也可運行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 visitfastcgi-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"匹配不到
Nginx運行Mono Web (ASP.NET)