Skip to content Skip to navigation

OpenStax_CNX

You are here: Home » Content » Apache httpd Web Server - basic configuration

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

In these lenses

  • Grand Rapids Community College

    This module is included inLens: GRCC CIS Lens
    By: Szymon Machajewski

    Click the "Grand Rapids Community College" link to see all content selected in this lens.

Recently Viewed

This feature requires Javascript to be enabled.
 

Apache httpd Web Server - basic configuration

Module by: Szymon Machajewski. E-mail the author

Exercise 1: Configuration file

Open and review the main configuration file for our Apache installation.

Note:

You can use any text editor. The solutions will use leafpad from Knoppix liveCD. Other editors on the Knoppix CD include: vi, xedit, nano, pico.

Solution

leafpad /home/knoppix/apache/conf/httpd.conf

Exercise 2

First let's fix the error message which comes up every time we start apache. The message says:

httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

Solution

To fix it edit the httpd.conf file ( leafpad /home/knoppix/apache/conf/httpd.conf ) and change the ServerName directive to be: ServerName localhost:8080

The directive before the change:

#ServerName www.example.com:80

The directive after change:

ServerName localhost:8080

Save the file and restart apache:

cd /home/knoppix/apache bin/apachectl stop bin/apachectl start

or

/home/knoppix/apache/bin/apachectl restart

Now you shouldn't see an error message when Apache starts.

Exercise 3

Find the following directives and change their values in the configuration file. For new configuration to take effect you have to save the configuration file and restart apache. Above at the end of step 1 you will find the commands to restart apache.

Find the following directives and change their values:

A)

Change ServerAdmin to your email address.  Before change: ServerAdmin you@example.com
Change to:
ServerAdmin myemail@host.com

B)

Add index.php to the default pages.  Before change: DirectoryIndex index.html index.html.var

Change to:
DirectoryIndex index.html index.html.var index.php

C)
Change the detail of logging.  Before change: LogLevel warn

Change to:
LogLevel error

D)
Change Server Signature:
ServerSignature Email

E)
Change the server HTTP Header information:
ServerTokens Prod

F)
Change the user and group which Apache runs as:
User knoppix
Group knoppix

Solution

Test the excercise by visiting the following urls on the your server:

http://localhost:8080/manual/

http://localhost:8080/icons/
(note at the bottom of the icon files the localhost link. 
It should have your email address as the destination url)

http://localhost:8080/cgi-bin/test-cgi
(if you get an error here that's fine. to fix the error run:
chmod 777 /home/knoppix/apache/cgi-bin/*

view the HTTP HEADERS of your server:
wget --spider -S http://localhost:8080/

Exercise 4: Virtual Hosts


1. Setup site host names

Edit /etc/hosts. You need to edit the lines as the root user.  In the terminal type in:

             su

             leafpad /etc/hosts

add the following lines:

127.0.0.1 www.co246.com
127.0.0.1 go.co246.com
127.0.0.1 student.co246.com

Exit the shell as root so you are logged in as Knoppix.

Test the host names by visiting the urls in a browser. Remember to start the Apache server on port 8080.
2. Configure Apache to recognize Virtual Hosts

Edit httpd.conf and add the following sections:
# Use name-based virtual hosting.
#
NameVirtualHost *:8080

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#

<VirtualHost *:8080>
ServerAdmin student@grcc.edu
DocumentRoot /home/knoppix/go_co246_htdocs/
ServerName go.co246.com
ErrorLog logs/go_co246_error_log
CustomLog logs/go_co246_access_log common
</VirtualHost>

<VirtualHost *:8080>
ServerAdmin student@grcc.edu
DocumentRoot /home/knoppix/student_co246_htdocs/
ServerName student.co246.com
ErrorLog logs/student_co246_error_log
CustomLog logs/student_co246_access_log common
<VirtualHost>

<VirtualHost *:8080>
ServerAdmin student@grcc.edu
DocumentRoot /home/knoppix/www_co246_htdocs/
ServerName www.co246.com
ErrorLog logs/www_co246_error_log
CustomLog logs/www_co246_access_log common
<VirtualHost>
3. Create each DocumentRoot directory with a sample index.html page. For example create:
mkdir /home/knoppix/www_co246_htdocs
cd /home/knoppix/www_co246_htdocs
echo “This is www_co246 site” > index.html

mkdir /home/knoppix/go_co246_htdocs
cd /home/knoppix/go_co246_htdocs
echo “This is go_co246 site” > index.html

mkdir /home/knoppix/student_co246_htdocs
cd /home/knoppix/student_co246_htdocs
echo “This is student_co246 site” > index.html 

Solution

Open a browser and navigate to

http://www.co246.com, http://go.co246.com, http://student.co246.com

Content actions

Download module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks