90 likes | 183 Views
Coursework 2: getting started (3) – hosting static web pages. Chris Greenhalgh G54UBI / 2011-02-21. Contents. Hosting static web pages In CS On your own computer (optional). Hosting static web pages in CS.
E N D
Coursework 2: getting started (3) – hosting static web pages Chris Greenhalgh G54UBI / 2011-02-21
Contents • Hosting static web pages • In CS • On your own computer (optional) Chris Greenhalgh (cmg@cs.nott.ac.uk)
Hosting static web pages in CS • Follow these instructions to set up hosting for static (i.e. no server-side scripting) web pages on the CS server(s): • http://support.cs.nott.ac.uk/help/docs/webpages/static/ • For general information about accessing/using the UNIX servers see • http://support.cs.nott.ac.uk/help/docs/access/unix/ Chris Greenhalgh (cmg@cs.nott.ac.uk)
A first test page • Download this simple page or create it using an editor in your public_html directory: • http://www.cs.nott.ac.uk/~cmg/G54UBI/mobile/Hello.html • Check/set the file permissions, and enter the URL into the mobile browser (something like): • http://www.cs.nott.ac.uk/~USERNAME/Hello.html • Errors can include: • Forbidden => file or directory permission wrong, or outside University network (see document) • Not found => URL hostname, path or filename wrong Chris Greenhalgh (cmg@cs.nott.ac.uk)
Test page Hello.html • <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>Hello</title> </head> <body> <h1>Hello</h1> </body></html> Chris Greenhalgh (cmg@cs.nott.ac.uk)
Hosting pages on your own computer (optional) • If you already have a web server set up (e.g. Apache) then use it • Alternatively e.g. Jetty is a simple Java HTTP server: • http://jetty.codehaus.org/jetty/ • E.g. http://dist.codehaus.org/jetty/jetty-6.1.26/jetty-6.1.26.zip • Extract the zip file to a directory • Create a new sub-directory under jetty-X.X.X/ called mobile/ • Copy this file to jetty-X.X.X/contexts/: • http://www.cs.nott.ac.uk/~cmg/G54UBI/mobile/mobile.xml • Put your web pages in the new mobile/ directory • Run Jetty • Double click jetty-X.X.X/start.jar or run in command shell with “java –jar start.jar” Chris Greenhalgh (cmg@cs.nott.ac.uk)
Using Jetty (or another local server), cont. • To check/access files served by Jetty: • When run, eventually it should print something like • 2011-02-22 15:34:33.127:INFO::Started SelectChannelConnector@0.0.0.0:8080 • Note the “:8080” at the end; this is the port it is using • Check the IP address of you computer, e.g. Windows (in a command shell) “ipconfig”, *nix “ifconfig –a”, e.g. • IP Address. . . . . . . : 128.243.22.74 • From a desktop browser first, try to access the file, e.g. • http://128.243.22.74:8080/mobile/Hello.html • If that works, try from the emulator… Chris Greenhalgh (cmg@cs.nott.ac.uk)
Possible problems with local hosting • Local firewall settings, e.g. windows firewall • Try configuring an “exception” for port 8080 and/or the Jetty program in the firewall • If you are inside the University and using the University proxy then it will NOT allow access back to your local machine • Temporarily disable the proxy by setting environment variable HTTP_proxy to (e.g.) “DIRECT” and restart the emulator. Note: you will probably NOT be able to access external web sites (including Google Maps) now. • Note that a local browser can use a “localhost” URL to access a local web server but the emulator CANNOT • E.g.: http://localhost:8080/mobile/Hello.html or http://127.0.0.1:8080/mobile/Hello.html • The emulator’s “localhost” is the emulator itself, not the computer that it is running on Chris Greenhalgh (cmg@cs.nott.ac.uk)
Conclusions • You should now be able to: • Make “static” web pages available from your Computer Science account • View these files on the emulator browser • Optionally • Serve static web pages from your own local web server, e.g. Jetty Chris Greenhalgh (cmg@cs.nott.ac.uk)