S80httpd

Synopsys


#
# httpd (apache)
#

Script


echo "%Post: Apache"

# ensure httpd loads at boot
chkconfig --level 345 httpd on

# We set up all URIs starting with /java to go to the mod_jk or mod_jk2
# connector, so that they're handled by Tomcat
#
# The rewrite rule allows for links to /java/foo/ to be used rather than
# /java/foo/current

cat > /etc/httpd/conf.d/tomcat.conf <<EOF
RewriteEngine  on
RewriteRule    ^/java/([A-Z,a-z,0-9]*)/$  /java/\$1/current/ [R]

EOF

if [ "$OS" == "fc3" ]; then
cat >> /etc/httpd/conf.d/tomcat.conf <<EOF
# Aiming to match any URI starting with /java and send it to tomcat
<Location "/java">
  JKUriSet worker ajp13:/usr/share/tomcat5/work/jk2.socket
</Location>
EOF
elif [ "$OS" == "fc4" ]; then
cat >> /etc/httpd/conf.d/tomcat.conf <<EOF
JKMount			/java/*	default
EOF
fi

# Allow apache access to files with group tomcat4 (e.g the jk2.socket)
# This used to be done this way.. But now is in LDAP
#mv /etc/group /etc/group-$VERSION
#sed -e 's/:91:$/:91:tomcat4,apache/' /etc/group-$VERSION > /etc/group

#
# Ok Now lets fix up the public_html directory for people
#
# for this to work.. we need to fix /etc/httpd/conf/httpd.conf
# first step here is to do this.
mv /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf-$VERSION

sed -e 's/UserDir disable/# UserDir disable/'\
    -e 's/^ScriptAlias/#ScriptAlias/'\
     /etc/httpd/conf/httpd.conf-$VERSION >/etc/httpd/conf/httpd.conf

cat >/etc/httpd/conf.d/public_html.conf <<EOF
<IfModule mod_userdir.c>
 UserDir public_html
</IfModule>

#
# Control access to UserDir directories.
# Denies write access to the directory unless an LDAP authenticated user
#

<Directory /home/*/public_html>
    AllowOverride FileInfo AuthConfig Limit
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec

    <LimitExcept GET POST OPTIONS>
	require valid-user
    </LimitExcept>

    AuthName "DAV access"
    AuthType Basic
    AuthLDAPURL ldap://ldap.$DOMAINNAME:389/ou=People,dc=geah,dc=org?uid?sub?(objectClass=*)

</Directory>

EOF

cat > /etc/httpd/conf.d/serverstatus.conf <<EOF
ExtendedStatus On

# Allow server status reports generated by mod_status,
# with the URL of http://servername/server-status

<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from 172.16.0.0/24
    Allow from 127.0.0.1/24
</Location>

EOF

#
# Finally we don't want the blank Fedora Page so we fix this with
# This forces traffic away from the local server to the main
# webserver for the site. But it is still possible from traffic
# appropriate to this server to go where it should 
cat >/var/www/html/index.html <<EOF
<HTML>
 <HEAD>
 <meta http-equiv=refresh content="1; URL=http://www.$DOMAINNAME/">
 </HEAD>
</HTML>

EOF

#
# Notes on Virtual hosting
#
cat > /etc/httpd/conf.d/vhost.conf <<EOF
AddHandler server-parsed .shtml
AddType    text/html shtml
Options +IncludesNOEXEC
DirectoryIndex index.html index.shtml

AddHandler server-parsed .shtml
AddType    text/html shtml
Options +IncludesNOEXEC
DirectoryIndex index.html index.shtml

VirtualDocumentRoot "$FSROOT/opt/%1/current/public_html"
VirtualScriptAlias  "$FSROOT/opt/%1/current/cgi-bin"

VirtualDocumentRootIP "/var/www/html"
VirtualScriptAliasIP  "/var/www/cgi-bin"

EOF



Examples and Testing





Marked up in XHTML - ©2005 Thoughtful Solutions Ltd.