When you run Apache now, you may get the following error message:
httpd: cannot determine local hostname Use ServerName to set it manually.
What Apache means is that you should put this line in the httpd.conf file:
ServerName <yourmachinename>
Finally, before you can expect any action, you need to set up some documents to serve. Apache’s default document directory is ... /httpd/htdocs — which you don’t want to use because you are at /usr/www/APACHE3/site.toddle — so you have to set it explicitly. Create ... /site.toddle/htdocs, and then in it create a file called 1.txt containing the immortal words “hullo world.” Then add this line to httpd.conf :
DocumentRoot /usr/www/APACHE3/site.toddle/htdocs
The complete Config file, .../site.toddle/conf/httpd.conf, now looks like this:
User webuser Group webgroup ServerName my586 DocumentRoot /usr/www/APACHE3/site.toddle/htdocs/ #fix 'Out of the Box' default problems--remove leading #s if necessary #ServerRoot /usr/www/APACHE3/APACHE3/site.toddle #ErrorLog logs/error_log #PIDFile logs/httpd.pid #TypesConfig conf/mime.types
When you fire up httpd, you should have a working web server. To prove it, start up a browser to access your new server, and point it at http://<yourmachinename>/.[3]
As we
know, http means use the HTTP protocol to get
documents, and / on the end means go to the
DocumentRoot
directory you set in
httpd.conf.
Lynx is the text browser that comes with FreeBSD and other flavors of Unix; if it is available, type:
% lynx http://<
yourmachinename>
/
You see:
INDEX OF / * Parent Directory * 1.txt
If you move to 1.txt
with the down arrow, you see:
hullo world
If you don’t have Lynx (or Netscape, or some other web browser) on your server, you can use telnet :[4]
% telnet <
yourmachinename>
80
You should see something like:
Trying 192.168.123.2 Connected to my586.my.domain Escape character is '^]'
Then type:
GET / HTTP/1.0 <CR><CR>
You should see:
HTTP/1.0 200 OK Sat, 24 Aug 1996 23:49:02 GMT Server: Apache/1.3 Connection: close Content-Type: text/html <HEAD><TITLE>Index of /</TITLE></HEAD><BODY> <H1>Index of </H1> <UL><LI> <A HREF="/"> Parent Directory</A> <LI> <A HREF="1.txt"> 1.txt</A> </UL></BODY> Connection closed by foreign host.
This is a rare opportunity to see a complete HTTP message. The first lines are headers that are normally hidden by your browser. The stuff between the < and > is HTML, written by Apache, which, if viewed through a browser, produces the formatted message shown by Lynx earlier, and by Netscape or Microsoft Internet Explorer in the next chapter.
[3] Note that if you are on the same machine, you can use http://127.0.0.1/ or http://localhost/, but this can be confusing because virtual host resolution may cause the server to behave differently than if you had used the interface’s “real” name.
[4] telnet is not really suitable as a web browser, though it can be a very useful debugging tool.