Since we did n’t actually build a whole website, we u sed hash signs (#) a s placeholders
for lin ks, like you told us to the last time.
Professor: What pleases me most is that you didn’t use a table to build the menu
system. It is the look of many me nus that fools some people into thinking that they
are tables. Logically, a menu is a list of items, but the main menu items are often
arrange d horizontally, which is a little unusual for a list in gener al.
Mike: T here is, however, one question bothering us. We believe that the same menu
will appear at the top of most of the pages of our website. Now, if the pages resided
in dierent directories that are n ot all at the same level of the directory tree, we would
have to use dierent relative URLs for the same links in the same menu in d ierent
documents. That’s a lot of work. We be lieve that absolute URLs are not a solution
either. If we had to move the whole website to some other location for one reason or
another, then all the absolute U RLs would have to change. What shall we do?
Professor: Very good qu estion indeed. There are generally two schools of thought
concerning URLs for hyperlinks to the pages within a website. The first teaches that
relative URLs should be avoided by all means while the second claims just th e oppo-
site. Many argumen ts have to do w ith principles well beyond the scope of our course.
Personally, I wouldn’t use absolute URLs for links within my website. I always test
my pages on a local server not open to the public. If I used absolute URLs, then I
would be shot o my test server to the already published pages any time I clicked a
hyperlink. On the othe r hand, using relative URLs too clumsily can for example cre-
ate so-called spide r traps. Web spiders (also named web crawlers) are prog rams that
systematically browse the World Wide Web, most of te n for the purpose of indexing.
A spider trap is a set of web pages that (intentionally or unintentionally) produce an
infinite number of requests from web spider s and may cause a poo rly written spider to
crash.
In my opinion, if you are con sistent an d careful with your coding, and you hold to th e
standard rules, no harm can be done using relative URLs. However, to access files that
are not inside the c urrent directory, it is probably the best practice to use root-relative
URLs. And by the way, this is also the best solution for a website men u system, wh ic h
was your original question.
Maria: I see. But then we have to put all our web files and directo ries into the root
directory. I don’t think that’s a g ood idea.
Professor: The trick is that the r oot directory does not h ave to be unique within a di-
rectory tree, which is usually the ca se under Windows. In fact, each pr ocess (program)
can have its own idea of what the root directory is. I think that we h ave arrived at the
point where you can learn to set up your first web server.
3.2 Setting up a Web Server
Professor: A server is eithe r a phy sical computer or a computer program to serve the
needs of other programs, called clients. Since at this stage w e will move mostly on
the client side, there’s really not much you need to know about servers. A server is
like a good servant, serving your needs while hiding a ll the dirty details from you. A
36 Meeting 3. Presentation
web server, for example, helps primarily to deliver web pages when requested from
clients by means of Hyper text Tr ansfer Protocol (HTTP). A web server also provides
web developers with the m eans to p ublish their contents.
Up to this moment, we have been doing just fine without a server because our job has
merely been displaying HTML docu ments inside a browser. Interpreting and render-
ing HTML con te nt is exclusively the browser’s job. Delivering the document to the
browser is what a w eb server should worry about. So, for example, if a document is
requested by the URL
/general/introduction.html, then, using the Windows local file
system, this will translate to
c:/general/introduction.html, if the request originates from
the
C: drive. However, if the document is requested through a web ser ver, the server
could translate the path to some other location, for example
c:/users/meandyou/www/
general/introduction.html
.
Mike: What’s the point?
Professor: The
/general/introduction.html URL is a ro ot-relative URL. If you are ac-
cessing the
introduction.html file directly through the local file system, then there is
only one possible location for the file: in the
general directory, whic h in turn should
be placed in the root directory of the drive. However, if you are accessing the file
through a web server, then you can configure the server to prepend any path you like
to the given root-absolute URL.
Maria: That’s great! Now we can choose any directory we want to be our site roo t
and use root-r elative URLs in navigation menus. Is it dicult to run a server?
Professor: It depends on what type of server you n eed. Fortunately, you will not have
to set up a p roduction server, which is a complex task indeed. A production server
(also called a live server) serves a website th at can be viewed by the public. As for
now, you better leave this to one of the many web hosting companies, whose services
you can rent quite cheaply.
For developing and testing your website, you need a development (also named stag-
ing) server, wh ic h runs locally on your computer and is not accessible by the public.
Setting up this kind of server is fairly trivial and I think you cou ld do it by yourselves.
Since you both run Windows, you’ll need a so-called WAMP pa ckage. WAMP is an
acronym formed f rom the initials of the operating sy stem Microsoft Windows and the
three main compone nts of the pa ckage: Apache, wh ic h is a web server, MySQL, an
open-so urce database, an d one of three scripting langu ages: PHP, Perl, o r Python.
Don’t worry about the m, though. We will not use them in our course.
One of the many WAMP p ackages is EasyP H P (
www.easyphp.org), which is a n open
source project and therefore freely available. Just go to their website and download
and install the EasyPHP DevServer. During the installation , you don’t have to do
anything except decide to which directory you want the software to install. After the
installation has co mpleted, you will find a directory named
data/localweb just inside
the directory you have chosen for the in stallatio n. This is your website home, or root
directory, and voilà, that’s it!
When you build a web site, you usually save your main page (the one that a visitor
should see first) to a file named
index.html in the site root directory. This name can be
3.2. Setting up a Web Server 37
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.90.172