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.2 2006/04/25 21:18:19 mlhuang Exp $
13 # Source function library and configuration
14 . /etc/plc.d/functions
15 . /etc/planetlab/plc_config
21 DocumentRoot=/var/www/html
23 httpd_conf=/etc/httpd/conf/httpd.conf
24 ssl_conf=/etc/httpd/conf.d/ssl.conf
25 plc_conf=/etc/httpd/conf.d/plc.conf
29 if [ "$PLC_API_ENABLED" != "1" -a \
30 "$PLC_BOOT_ENABLED" != "1" -a \
31 "$PLC_WWW_ENABLED" != "1" ] ; then
35 MESSAGE=$"Starting web server"
38 # Set the default include path
39 include_path=".:$DocumentRoot/includes:$DocumentRoot/generated:/etc/planetlab/php"
40 sed -i -e "s@;include_path = \"\.:.*\"@include_path = \"$include_path\"@" $php_ini
42 # Disable default Listen directive
43 sed -i -e '/^Listen/d' $httpd_conf
45 # Set the port numbers
46 for server in WWW API BOOT ; do
47 enabled=PLC_${server}_ENABLED
48 if [ "${!enabled}" != "1" ] ; then
51 hostname=PLC_${server}_HOST
52 http_port=PLC_${server}_PORT
53 https_port=PLC_${server}_SSL_PORT
55 # API should always be accessed via SSL
56 if [ "$server" = "API" ] ; then
57 https_port=${!http_port}
61 # Check if we are already listening on these ports
64 for previous_server in WWW API BOOT ; do
65 if [ "$server" = "$previous_server" ] ; then
68 previous_hostname=PLC_${previous_server}_HOST
69 previous_http_port=PLC_${previous_server}_PORT
70 previous_https_port=PLC_${previous_server}_SSL_PORT
72 if [ "${!http_port}" = "${!previous_http_port}" ] ; then
75 if [ "${!https_port}" = "${!previous_https_port}" ] ; then
80 # Listen on these ports
81 if [ $skip_http -eq 0 -a -n "${!http_port}" ] ; then
84 <VirtualHost *:${!http_port}>
85 Redirect /db https://$PLC_WWW_HOST:$PLC_WWW_SSL_PORT/db
86 # XXX Not yet until we can get rid of oldapi
87 # Redirect /$PLC_API_PATH https://$PLC_API_HOST:$PLC_API_PORT/$PLC_API_PATH
91 if [ $skip_https -eq 0 -a -n "${!https_port}" ] ; then
92 # XXX Cannot support NameVirtualHost over SSL. If
93 # the API, boot, and web servers are all running
94 # on the same machine, the web server certificate
97 -e "s/^Listen .*/Listen ${!https_port}/" \
98 -e "s/<VirtualHost _default_:.*>/<VirtualHost _default_:${!https_port}>/" \
103 # Set custom Apache directives
105 if [ "$PLC_API_ENABLED" = "1" ] ; then
107 <Location $PLC_API_PATH>
108 SetHandler python-program
109 PythonPath "sys.path + ['/usr/share/plc_api']"
110 PythonHandler mod_pythonXMLRPC
115 <Location $PLC_API_PATH>
121 if [ "$PLC_WWW_ENABLED" != "1" ] ; then
130 # Make alpina-logs directory writable for bootmanager log upload
131 chown apache:apache $DocumentRoot/alpina-logs/nodes
140 MESSAGE=$"Stopping web server"