通过以下步骤在Unbutu 16下配置一个可以运行asp.net的网站的环境。
- 运行 apt-get update
- apt-get install apache2
- apt-get install libapache2-mod-mono mono-apache-server4
- 建立网站根目录 mkdir /var/www/mono
- chown -R www-data:www-data /var/www/mono
- 访问 http://go-mono.com/config-mod-mono/Default.aspx 在线生成网站配置文件,并另存为 mono-default.conf ,以下是一个配置文件的示例,也可以修改参数后直接使用(注意需将/usr/bin/mod-mono-server2 替换为 /usr/bin/mod-mono-server4):
ServerName liangchicun.com ServerAlias liangchicun.com ServerAlias www.liangchicun.com ServerAdmin [email protected] DocumentRoot /var/www/mono # MonoServerPath can be changed to specify which version of ASP.NET is hosted # mod-mono-server1 = ASP.NET 1.1 / mod-mono-server2 = ASP.NET 2.0 # For SUSE Linux Enterprise Mono Extension, uncomment the line below: # MonoServerPath liangchicun.com "/opt/novell/mono/bin/mod-mono-server2" # For Mono on openSUSE, uncomment the line below instead: MonoServerPath liangchicun.com "/usr/bin/mod-mono-server4" # To obtain line numbers in stack traces you need to do two things: # 1) Enable Debug code generation in your page by using the Debug="true" # page directive, or by setting in the # application's Web.config # 2) Uncomment the MonoDebug true directive below to enable mod_mono debugging # MonoDebug liangchicun.com true # The MONO_IOMAP environment variable can be configured to provide platform abstraction # for file access in Linux. Valid values for MONO_IOMAP are: # case # drive # all # Uncomment the line below to alter file access behavior for the configured application MonoSetEnv liangchicun.com MONO_IOMAP=all # # Additional environtment variables can be set for this server instance using # the MonoSetEnv directive. MonoSetEnv takes a string of 'name=value' pairs # separated by semicolons. For instance, to enable platform abstraction *and* # use Mono's old regular expression interpreter (which is slower, but has a # shorter setup time), uncomment the line below instead: # MonoSetEnv liangchicun.com MONO_IOMAP=all;MONO_OLD_RX=1 MonoApplications liangchicun.com "/:/var/www/mono" <Location "/"> Allow from all Order allow,deny MonoSetServerAlias liangchicun.com SetHandler mono SetOutputFilter DEFLATE SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript
- 将上述配置文件保存到 /etc/apache2/sites-available 目录中,即 /etc/apache2/sites-available/001-default.conf
- ln -s /etc/apache2/sites-available/001-default.conf /etc/apache2/sites-enabled/001-default.conf
- service apache2 restart