Open and review the main configuration file for our Apache installation.
leafpad /home/knoppix/apache/conf/httpd.conf
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
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.
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
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/
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.
# 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>
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
Open a browser and navigate to
http://www.co246.com, http://go.co246.com, http://student.co246.com