5 # Configure Apache web server
7 # Mark Huang <mlhuang@cs.princeton.edu>
8 # Copyright (C) 2006 The Trustees of Princeton University
10 # $Id: httpd,v 1.1 2006/04/06 21:51:59 mlhuang Exp $
13 # Source function library and configuration
14 . /etc/plc.d/functions
15 . /etc/planetlab/plc_config
18 DocumentRoot=/var/www/html
20 httpd_conf=/etc/httpd/conf/httpd.conf
21 ssl_conf=/etc/httpd/conf.d/ssl.conf
22 plc_conf=/etc/httpd/conf.d/plc.conf
26 if [ "$PLC_API_ENABLED" != "1" -a \
27 "$PLC_BOOT_ENABLED" != "1" -a \
28 "$PLC_WWW_ENABLED" != "1" ] ; then
32 MESSAGE=$"Starting web server"
35 # Set the default include path
36 include_path=".:$DocumentRoot/includes:$DocumentRoot/generated:/etc/planetlab/php"
37 sed -i -e "s@;include_path = \"\.:.*\"@include_path = \"$include_path\"@" $php_ini
39 # Disable default Listen directive
40 sed -i -e '/^Listen/d' $httpd_conf
42 # Set the port numbers
43 for server in WWW API BOOT ; do
44 enabled=PLC_${server}_ENABLED
45 if [ "${!enabled}" != "1" ] ; then
48 hostname=PLC_${server}_HOST
49 http_port=PLC_${server}_PORT
50 https_port=PLC_${server}_SSL_PORT
52 # API should always be accessed via SSL
53 if [ "$server" = "API" ] ; then
54 https_port=${!http_port}
58 # Check if we are already listening on these ports
61 for previous_server in WWW API BOOT ; do
62 if [ "$server" = "$previous_server" ] ; then
65 previous_hostname=PLC_${previous_server}_HOST
66 previous_http_port=PLC_${previous_server}_PORT
67 previous_https_port=PLC_${previous_server}_SSL_PORT
69 if [ "${!http_port}" = "${!previous_http_port}" ] ; then
72 if [ "${!https_port}" = "${!previous_https_port}" ] ; then
77 # Listen on these ports
78 if [ $skip_http -eq 0 -a -n "${!http_port}" ] ; then
81 <VirtualHost *:${!http_port}>
82 Redirect /db https://$PLC_WWW_HOST:$PLC_WWW_SSL_PORT/db
83 # XXX Not yet until we can get rid of oldapi
84 # Redirect /$PLC_API_PATH https://$PLC_API_HOST:$PLC_API_PORT/$PLC_API_PATH
88 if [ $skip_https -eq 0 -a -n "${!https_port}" ] ; then
89 # XXX Cannot support NameVirtualHost over SSL. If
90 # the API, boot, and web servers are all running
91 # on the same machine, the web server certificate
94 -e "s/^Listen .*/Listen ${!https_port}/" \
95 -e "s/<VirtualHost _default_:.*>/<VirtualHost _default_:${!https_port}>/" \
100 # Set custom Apache directives
102 if [ "$PLC_API_ENABLED" = "1" ] ; then
104 <Location $PLC_API_PATH>
105 SetHandler python-program
106 PythonPath "sys.path + ['/usr/share/plc_api']"
107 PythonHandler mod_pythonXMLRPC
112 <Location $PLC_API_PATH>
118 if [ "$PLC_WWW_ENABLED" != "1" ] ; then
127 # Make alpina-logs directory writable for bootmanager log upload
128 chown apache:apache $DocumentRoot/alpina-logs/nodes
137 MESSAGE=$"Stopping web server"