diff --git a/files/apache-keystone.template b/files/apache-keystone.template index a9d9cc3280..e7b215768c 100644 --- a/files/apache-keystone.template +++ b/files/apache-keystone.template @@ -6,6 +6,7 @@ Listen %ADMINPORT% WSGIProcessGroup keystone-public WSGIScriptAlias / %PUBLICWSGI% WSGIApplicationGroup %{GLOBAL} + %ERRORLOGFORMAT% ErrorLog /var/log/%APACHE_NAME%/keystone.log CustomLog /var/log/%APACHE_NAME%/access.log combined @@ -15,6 +16,7 @@ Listen %ADMINPORT% WSGIProcessGroup keystone-admin WSGIScriptAlias / %ADMINWSGI% WSGIApplicationGroup %{GLOBAL} + %ERRORLOGFORMAT% ErrorLog /var/log/%APACHE_NAME%/keystone.log CustomLog /var/log/%APACHE_NAME%/access.log combined diff --git a/lib/apache b/lib/apache index f4f82a1353..6d22290c42 100644 --- a/lib/apache +++ b/lib/apache @@ -61,6 +61,28 @@ function install_apache_wsgi { fi } +# get_apache_version() - return the version of Apache installed +# This function is used to determine the Apache version installed. There are +# various differences between Apache 2.2 and 2.4 that warrant special handling. +function get_apache_version { + if is_ubuntu; then + local version_str=$(sudo /usr/sbin/apache2ctl -v | awk '/Server version/ {print $3}' | cut -f2 -d/) + elif is_fedora; then + local version_str=$(rpm -qa --queryformat '%{VERSION}' httpd) + elif is_suse; then + local version_str=$(rpm -qa --queryformat '%{VERSION}' apache2) + else + exit_distro_not_supported "cannot determine apache version" + fi + if [[ "$version_str" =~ ^2\.2\. ]]; then + echo "2.2" + elif [[ "$version_str" =~ ^2\.4\. ]]; then + echo "2.4" + else + exit_distro_not_supported "apache version not supported" + fi +} + # apache_site_config_for() - The filename of the site's configuration file. # This function uses the global variables APACHE_NAME and APACHE_CONF_DIR. # @@ -87,8 +109,8 @@ function install_apache_wsgi { function apache_site_config_for { local site=$@ if is_ubuntu; then - local apache_version=$(sudo /usr/sbin/apache2ctl -v | awk '/Server version/ {print $3}' | cut -f2 -d/) - if [[ "$apache_version" =~ ^2\.2\. ]]; then + local apache_version=$(get_apache_version) + if [[ "$apache_version" == "2.2" ]]; then # Ubuntu 12.04 - Apache 2.2 echo $APACHE_CONF_DIR/${site} else diff --git a/lib/keystone b/lib/keystone index c6e17cad73..42acd50c83 100644 --- a/lib/keystone +++ b/lib/keystone @@ -123,6 +123,13 @@ function _config_keystone_apache_wsgi { sudo mkdir -p $KEYSTONE_WSGI_DIR local keystone_apache_conf=$(apache_site_config_for keystone) + local apache_version=$(get_apache_version) + + if [[ ${apache_version#*\.} -ge 4 ]]; then + # Apache 2.4 supports custom error log formats + # this should mirror the original log formatting. + local errorlogformat='ErrorLogFormat "%{cu}t %M"' + fi # copy proxy vhost and wsgi file sudo cp $KEYSTONE_DIR/httpd/keystone.py $KEYSTONE_WSGI_DIR/main @@ -136,6 +143,7 @@ function _config_keystone_apache_wsgi { s|%PUBLICWSGI%|$KEYSTONE_WSGI_DIR/main|g; s|%ADMINWSGI%|$KEYSTONE_WSGI_DIR/admin|g; s|%USER%|$STACK_USER|g + s|%ERRORLOGFORMAT%|$errorlogformat|g; " -i $keystone_apache_conf enable_apache_site keystone }