Coursework 2: getting started (3) – hosting static web pages Chris Greenhalgh G54UBI /
Contents Hosting static web pages – In CS – On your own computer (optional) 2Chris Greenhalgh
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): – – For general information about accessing/using the UNIX servers see 3Chris Greenhalgh
A first test page Download this simple page or create it using an editor in your public_html directory: – Check/set the file permissions, and enter the URL into the mobile browser (something like): – Errors can include: – Forbidden => file or directory permission wrong, or outside University network (see document) – Not found => URL hostname, path or filename wrong 4Chris Greenhalgh
Test page 5 Hello Hello Hello.html Chris Greenhalgh
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: – E.g. – 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/: – 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” 6Chris Greenhalgh
Using Jetty (or another local server), cont. To check/access files served by Jetty: – When run, eventually it should print something like :34:33.127:INFO::Started 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 : – From a desktop browser first, try to access the file, e.g. – If that works, try from the emulator… 7Chris Greenhalgh
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.: or – The emulator’s “localhost” is the emulator itself, not the computer that it is running on 8Chris Greenhalgh
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 9Chris Greenhalgh