smithvoice.com
 Y'herd thisun? 

“'Everyone wants to eat like an American on this globe,' said Daniel Basse of AgResource, a Chicago consultancy. 'But if they do, we're going to need another two or three globes to grow it all.'”

from As world's appetite soars, so do food bills by David Streitfeld

MONO/Ubuntu part 10 - Apache default pages

TaggedASP.Net, MONO, Linux

Default pages

Time to get the general purpose stuff wrapped up.

Since we're now going to be starting to use real ASP.Net pages, it's smart to put in a simple web.config so that we can see any errors along the way. Use nano to create the file...

sudo nano /home/kilgore/sites/asdf/web.config

... and add the customErrors node with the mode set to Off.

<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true">
</compilation>
<customErrors mode="Off">
</customErrors>
</system.web>
</configuration>

Before release you'll of course change the compilation mode and set the customErrors mode value to "RemoteOnly", and use the text-based Lynx browser to view .Net issues when logged onto the server. For right now, we'll assume that you're testing your overall setup from off-box clients so having customErrors "Off" makes work easier.

Setting the default page

This is easy, just nano the /etc/apache2/sites-available/[site vhost file] and add a DirectoryIndex line for the page that you want to appear if no page is specified in the request.

The only question you have to ask yourself is do you want this to be a static page of non-dynamic html or an ASP.Net page. Most likely, since you're here at smithvoice.com, you'll want it to be an ASPX page... but just remember that if it is a managed page and if you have any serverside issues that kill Mono's ASP.Net (such as a mistake in the web.config) your users will see an unhandleable 500 error *from Mono* that won't bubble up to be redirected by Apache. Standard stuff, same as MS.Net, but something to consider.

For our example, we will cross our fingers about .Net service errors and use an ASPX named "defpage.aspx" for our default.

sudo nano /home/kilgore/sites/asdf/defpage.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
lblInfo.Text = String.Format("I am the asp.net site default page<br />the time now is {0}",
DateTime.Now.ToLongTimeString());
}
</script>
<body>
<form id="form1" runat="server">
<asp:Label ID="lblInfo" runat="server"></asp:Label>
</form>
</body>
</html>

To have that page be our default, add the line to /etc/apache2/sites-available/asdf

<VirtualHost *:80>
ServerName www.asdf.com
DocumentRoot /home/kilgore/sites/asdf
DirectoryIndex  defpage.aspx
</VirtualHost>

Because the change was at the Apache level, not the Mono level, you have to force Apache to be aware of it. Reload will do that for you.

sudo /etc/init.d/apache2 reload

Now give http://www.asdf.com a client test.

Take note that we altered the asdf website configuration file in /etc/apache2/sites-available/asdf. We didn't do it in /sites-enabled/ and we didn't have to do a force after the change with a2dissite and a2ensite.

Once a site is enabled with a2ensite, any changes you make to its configuration file in /sites-available/ will get copied over to the corresponding /sites-enabled/ file with a reload (or restart or stop&start) of the Apache service. You can verify this by the fact that the change went into effect ;-), and also by looking at the /sites-enabled/ file:


Coming next: Handling site errors.


jump to:

  • 1: Why?
  • 2: Installation
  • 3: Update the OS with APT
  • 4: Remoting to the box with SSH
  • 5: NANO quickies for 95% of the jobs
  • 6: Firewalling Ubuntu 8.10 Server
  • 7: Installing Apache2 and MONO
  • 8: Test client host files
  • 9: Configure MONO on Apache2
  • 10: Apache default pages
  • 11: Handling Apache and Mono Errors
  • 12: Subdomains and Christian porn
  • 13: Virtual Host Tweak: unmanaged cAse sensitiviTy
  • 14: Managed cAse sensitiviTy
  • 15: Managing files and folders
  • 16: Logging Apache Accesses and Errors
  • 17: Ubuntu Task Managers
  • 18: Ubuntu Services and Service Managers
  • 19: Installing Oracle 10g XE Server
  • 20: Connecting Mono to Oracle


  • home     who is smith    contact smith     rss feed π
    Since 1997 a place for my stuff, and it if helps you too then all the better smithvoice.com