logo © 1996 Phil Waclawski
Felitaur Site
Offerings
About Me
Crafts
Services
ftp files
Help Files
What's New?
Home Page
Other Links
Anatomy &
Physiology
Arthropods
Biology
Computers
Ferrets
Fun Links
Internet
Linux
S.C.A.
Win 95/NT
Comments or
Suggestions
webmaster@ felitaur.com
   
Starting up Apache
[Linux System Administration Homepage]
Overview
Well, we have Linux installed, but as of yet the web server does NOT seem to be working, and we want to alter the configuration so it runs at boot time and users can set up web pages as well. Also to get familiar with the location of many of the useful files needed to control the Apache Web Server, the most commonly used web server on the net.

Goals:

  1. understand how to start/stop servers
  2. edit run levels so apache starts up at boot
  3. locate server web page directory
  4. create user web page directory
  5. locate and modify apache configuration file
  6. restart server and test
  7. setup a dummy domain name and test
  8. locate information resources for apache
Files/directories covered:
  • /etc (files: hosts inittab)
  • /etc/rc.d/init.d/
  • /etc/rc.d (subdirectories rc3.d long with rc0.d to rc6.d)
  • /etc/httpd (subdirectory conf.d)
  • /var/www/ (subdirectories: cgi-bin, html)

  • NOTE: On older systems this would be /home/httpd/html and so on, or /usr/local/apache etc.)
  • /var/log (files: messages)
  • /var/log/httpd (files: access_log error_log)
Commands:
  • /sbin/service httpd start|stop|restart|status
  • /sbin/chkconfig --level 3 servername on
  • useradd
  • passwd
  • mkdir
  • ln -s
  • vim
Questions
  • What is ServerRoot, where is it located? What is it?
  • What is DocumentRoot, where is it located? What is it?
  • How do you start and stop services?
  • What port number does apache run on?
  • What port number does apache-ssl run on?
  • What is tux, what does it do?
  • Why did we need to set the users home directory o+x ? (or 701)
  • What does /etc/hosts do?
Activites
In class I kind of wandered around as I tried to "trouble shoot" or figure out why the various options were not working. Keep that in mind as you work through these exercises. Don't just "follow the steps" but try to understand WHAT and WHY we are doing them.

NOTE: for most of this, you will need to su to root in order to have the proper permissions.

  1. Go into the /etc/rc.d/init.d where all the server start/stop/restart scripts are kept and do a ./httpd start and a (NOTE: If you are curious about what these scripts do, use less or more to read them in this directory, they usually have a short comment at the beginning to explain what they do).
  2. go into the directory that contains the symbolic links for run level 3 (rc3.d somewhere inside of /etc) and use chkconfig to:
    • remove these services from run level 3
    • add httpd to run level 3
  3. go to etc hosts and add a line
    192.168.xx.xxx fakename.com
    (Fill in xx.xxx with your present IP address, and what you type for fakename.com is up to you)
  4. Start up netscape, first load up 192.168.xx.xxx, then fakename.com (which mysteriously won't work yet) to make sure you can contact your web server
  5. Go to /var/www/html and edit/create the index.html file to make a homepage for your system
  6. Hit reload in netscape to see your changes
  7. Now, you need to allow users to create web directories.
  8. go edit httpd.conf (in /etc/httpd/conf.d directory)
  9. first make a backup by cp httpd.conf httpd.conf.original
  10. Open the file with vi or pico
  11. NOTE lines such as "ServerRoot" and "DocumentRoot" and what they are set to in the file.
  12. Search for ServerName (use ctrl-w to search in pico) and set it to your fakename.com:80 (now fakename.com should work)
  13. Search for <Directory "/var/www/html"> and add ExecCGI to the Options line.
  14. Go into the DocumentRoot (which is /var/www/html for now)
  15. create a symbolic link to /home/username/public_html where the name of the link is the username
  16. add a public_html directory to /etc/skel
  17. NOTE: Error logs are now much more complex in recent versions of Apache, so don't do the following that refer to error_log
  18. Uncomment the following two lines
    CustomLog /var/log/httpd/referer_log referer
    CustomLog /var/log/httpd/agent_log agent
  19. Uncomment ErrorDocument 404 /missing.html
  20. Log in as a simple user
  21. Go to that users home directory
  22. mkdir public_html
  23. copy your template.html to index.html, edit it slightly, and put it in public_html
  24. If you try 192.168.xx.xxx/username/ it won't work yet, why?
  25. go to /home
  26. chmod o+x username (sets x on usernames home directory, or do chmod 701 username)
  27. 192.168.xx.xxx/username/ still won't work, why?
  28. Restart httpd so changes take effect
  29. Here is a neat trick, and another good reason to always make a backup of a configuration file BEFORE you change it.
    • Go back into /etc/httpd/conf
    • type diff httpd.conf httpd.conf.original
    • What does this give you?
References
  1. Using netscape or mozilla, go to file, open, choose(browse)
    • go to 127.0.0.1/manual
    • Then in netscape click on bookmarks
    • Slide to "file bookmarks"
    • And put it in your personal toolbar folder
  2. Apache 1.3 Online Documents
  3. Apache 2.2 Online Documents This page last updated on: