Apache (Pete's notes)

Apache on Mac OS X

By default, the Mac Apache serves user's personal web pages defined as /User/*/Sites, which matches /User/siemsen/Sites. This merges well with Apple's .Mac concepts, and maybe something I want to consider, but for now, I want a local copy of /usr/web/nets/intro/staff/siemsen. So, let's reconfigure Apache by editing /etc/apache2/httpd.conf. Set

Then, to restart the Apache server, turn on "Web Sharing". If it's already on, turn it off then back on to restart the server. See Apache under Mac OS X. It will tell you that to enable the Apache daemon that comes with Mac OS X, do System Preferences, Sharing, and turn on the Web Sharing box.

Get apache

apt-get install httpd
Web to Apache HTTP Server Project. Click Download. Click down and get httpd-2.0.40.tar.gz. Save it in /usr/src.

(as root)
cd /usr/src
gunzip httpd-2.0.40.tar.gz
tar xf httpd-2.0.40.tar
rm httpd-2.0.40.tar
cd httpd-2.0.40
./buildconf
./configure
make
make install
make clean
cp support/apachectl /etc/init.d
chmod +x /etc/init.d/apachectl
cd /etc/rc.d/rc2.d
ln -s ../init.d/apachectl S98apachectl
ln -s ../init.d/apachectl K02apachectl

Apache 2.0 User's Guide

See the Apache 2.0 manual.

Startup, error logs, etc.

Error messages are written to /etc/httpd/logs. Of particular interest is the error_log file.

To make a running httpd reread the config file, do

as root

apachectl restart

Configure apache 2.0

Edit /etc/httpd/conf/httpd.conf.

IMPORTANT WARNING: on at least Ubuntu (Debian) Linux, when you install the apache2 package, you'll probably think that you configure the server by changing settings in the /etc/apache2/apache2.conf file. You fool! If you try that, you'll go crazy trying to figure out why some of your changes have no effect. You won't expect that the file /etc/apache2/sites-available/default overrides stuff in /etc/apache2/apache2.conf. What you're supposed to do is

          cd /etc/apache2/sites-available
          sudo cp default ncar
          cd /etc/apache2/sites-enabled
          sudo rm 000-default
          sudo ln -s /etc/apache2/sites-available/ncar
        
...and then modify /etc/apache2/sites-available/ncar as follows. The root of the document web needs to be the same as it is on the netserver machines. To set this,
DocumentRoot "/usr/web"
<Directory "/usr/web">
Options Indexes FollowSymLinks Includes MultiViews

When the apache server detects problems, it emails the "webmaster". To make it email me, do this:

ServerAdmin siemsen@ucar.edu

The "ServerName" needs to be defined or httpd will die during startup with "cannot determine local host name".

ServerName proteus.ucar.edu:80

By default, when apache on Linux serves a .ppt file, it's sent as application/powerpoint. The apache on the Solaris production server sends it as application/vnd.ms-powerpoint. This can confuse some browsers, like Marla's. To make netserver behave like the production server, edit /etc/apache/srm.conf on netserver:

AddType application/vnd.ms-powerpoint .ppt

You'll notice that by default, the server will start, like, 75 "processes" as shown by the "ps -ef | grep htt" command. This is excessive, since I'm the only user of this server. To tune it down a bit, change the values of the following:

<IfModule threaded.c>
StartServers 2
MaxClients 4
MinSpareThreads 5
MaxSpareThreads 5
ThreadsPerChild 15
MaxRequestsPerChild 0
</IfModule>

Allow connections from only the localhost, and only to port 80.

Listen 127.0.0.1:80
Listen 127.0.0.2:80

To allow other machines to get to ibex's web pages, you'll have to change iptables as documented here and do this:

Listen 128.117.10.2:80
#
# Deny access to everyone except UCAR hosts, the local machine and my home NAT network.
#
Order Deny,Allow
Deny from All
Allow from 128.117.0.0/16
Allow from 127.0.0.1/32
Allow from 192.168.0.0/16


Address comments or questions about this Web page to the Network Engineering & Technology Section at nets-www@ncar.ucar.edu. The NETS is part of the Scientific Computing Division of the National Center for Atmospheric Research, which is part of the University Corporation for Atmospheric Research.
Last modified: Mon Jul 10 17:09:56 MDT 2006