update HTTP service to support apache 2.4 on Ubuntu 14.04 (fixes bug #261)
(Boeing r1895)
This commit is contained in:
parent
503713f0bc
commit
f61522207d
1 changed files with 55 additions and 10 deletions
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# CORE
|
||||
# Copyright (c)2010-2012 the Boeing Company.
|
||||
# Copyright (c)2010-2014 the Boeing Company.
|
||||
# See the LICENSE file included in this distribution.
|
||||
#
|
||||
# author: Jeff Ahrenholz <jeffrey.m.ahrenholz@boeing.com>
|
||||
|
@ -395,6 +395,8 @@ class HttpService(UtilService):
|
|||
_shutdown = ("apache2ctl stop",)
|
||||
_validate = ("pidof apache2",)
|
||||
|
||||
APACHEVER22, APACHEVER24 = (22, 24)
|
||||
|
||||
@classmethod
|
||||
def generateconfig(cls, node, filename, services):
|
||||
''' Generate an apache2.conf configuration file.
|
||||
|
@ -408,16 +410,55 @@ class HttpService(UtilService):
|
|||
else:
|
||||
return ""
|
||||
|
||||
@classmethod
|
||||
def detectversionfromcmd(cls):
|
||||
''' Detect the apache2 version using the 'a2query' command.
|
||||
'''
|
||||
try:
|
||||
status, result = cmdresult(['a2query', '-v'])
|
||||
except Exception:
|
||||
status = -1
|
||||
if status == 0 and result[:3] == '2.4':
|
||||
return cls.APACHEVER24
|
||||
return cls.APACHEVER22
|
||||
|
||||
|
||||
@classmethod
|
||||
def generateapache2conf(cls, node, filename, services):
|
||||
return """\
|
||||
# apache2.conf generated by utility.py:HttpService
|
||||
LockFile ${APACHE_LOCK_DIR}/accept.lock
|
||||
lockstr = { cls.APACHEVER22:
|
||||
'LockFile ${APACHE_LOCK_DIR}/accept.lock\n',
|
||||
cls.APACHEVER24:
|
||||
'Mutex file:${APACHE_LOCK_DIR} default\n', }
|
||||
mpmstr = { cls.APACHEVER22: '', cls.APACHEVER24:
|
||||
'LoadModule mpm_worker_module /usr/lib/apache2/modules/mod_mpm_worker.so\n', }
|
||||
|
||||
permstr = { cls.APACHEVER22:
|
||||
' Order allow,deny\n Deny from all\n Satisfy all\n',
|
||||
cls.APACHEVER24:
|
||||
' Require all denied\n', }
|
||||
|
||||
authstr = { cls.APACHEVER22:
|
||||
'LoadModule authz_default_module /usr/lib/apache2/modules/mod_authz_default.so\n',
|
||||
cls.APACHEVER24:
|
||||
'LoadModule authz_core_module /usr/lib/apache2/modules/mod_authz_core.so\n', }
|
||||
|
||||
permstr2 = { cls.APACHEVER22:
|
||||
'\t\tOrder allow,deny\n\t\tallow from all\n',
|
||||
cls.APACHEVER24:
|
||||
'\t\tRequire all granted\n', }
|
||||
|
||||
version = cls.detectversionfromcmd()
|
||||
cfg ="# apache2.conf generated by utility.py:HttpService\n"
|
||||
cfg += lockstr[version]
|
||||
cfg += """\
|
||||
PidFile ${APACHE_PID_FILE}
|
||||
Timeout 300
|
||||
KeepAlive On
|
||||
MaxKeepAliveRequests 100
|
||||
KeepAliveTimeout 5
|
||||
"""
|
||||
cfg += mpmstr[version]
|
||||
cfg += """\
|
||||
|
||||
<IfModule mpm_prefork_module>
|
||||
StartServers 5
|
||||
|
@ -453,9 +494,9 @@ Group ${APACHE_RUN_GROUP}
|
|||
AccessFileName .htaccess
|
||||
|
||||
<Files ~ "^\.ht">
|
||||
Order allow,deny
|
||||
Deny from all
|
||||
Satisfy all
|
||||
"""
|
||||
cfg += permstr[version]
|
||||
cfg += """\
|
||||
</Files>
|
||||
|
||||
DefaultType None
|
||||
|
@ -469,7 +510,9 @@ LogLevel warn
|
|||
#Include mods-enabled/*.conf
|
||||
LoadModule alias_module /usr/lib/apache2/modules/mod_alias.so
|
||||
LoadModule auth_basic_module /usr/lib/apache2/modules/mod_auth_basic.so
|
||||
LoadModule authz_default_module /usr/lib/apache2/modules/mod_authz_default.so
|
||||
"""
|
||||
cfg += authstr[version]
|
||||
cfg += """\
|
||||
LoadModule authz_host_module /usr/lib/apache2/modules/mod_authz_host.so
|
||||
LoadModule authz_user_module /usr/lib/apache2/modules/mod_authz_user.so
|
||||
LoadModule autoindex_module /usr/lib/apache2/modules/mod_autoindex.so
|
||||
|
@ -506,8 +549,9 @@ TraceEnable Off
|
|||
<Directory /var/www/>
|
||||
Options Indexes FollowSymLinks MultiViews
|
||||
AllowOverride None
|
||||
Order allow,deny
|
||||
allow from all
|
||||
"""
|
||||
cfg += permstr2[version]
|
||||
cfg += """\
|
||||
</Directory>
|
||||
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||
LogLevel warn
|
||||
|
@ -515,6 +559,7 @@ TraceEnable Off
|
|||
</VirtualHost>
|
||||
|
||||
"""
|
||||
return cfg
|
||||
|
||||
@classmethod
|
||||
def generateenvvars(cls, node, filename, services):
|
||||
|
|
Loading…
Reference in a new issue