1#
2# The following prevents a system from having installed and loaded on apache
3# both mod_python and mod_wsgi
4#
5<IfModule mod_wsgi.c>
6   <IfModule mod_python.c>
7      ERROR__EITHER_MOD_WSGI_XOR_MOD_PYTHON_SHOULD_BE_ACTIVE
8   </IfModule>
9</IfModule>
10
11#
12# Django, when running under mod_python, requires the prefork MPM, so just
13# fail with this bogus directive if it's not loaded. For more info see:
14# https://github.com/autotest/autotest/wiki/AutotestServerInstall
15#
16<IfModule !prefork.c>
17    <IfModule mod_python.c>
18       ERROR__DJANGO_REQUIRES_THE_PREFORK_MPM
19    </IfModule>
20</IfModule>
21
22RewriteEngine On
23
24#
25# Configuration on Moblab
26#
27RewriteCond /usr/lib64/python2.7/site-packages/django/contrib/admin/static/admin -d
28RewriteRule ^/media/(css|img|js)(.*) /usr/lib64/python2.7/site-packages/django/contrib/admin/static/admin/$1/$2
29RewriteCond /usr/lib64/python2.7/site-packages/django/contrib/admin/static/admin -d
30RewriteRule ^/afe/server/admin/admin/(css|img|js)(.*) /usr/lib64/python2.7/site-packages/django/contrib/admin/static/admin/$1/$2
31RewriteCond /usr/lib64/python2.7/site-packages/django/contrib/admin/static/admin -d
32RewriteRule ^/afe/server/admin/afe/(aclgroup|atomicgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/lib64/python2.7/site-packages/django/contrib/admin/static/admin/$2/$3
33
34#
35# Django < 1.4 installed by utils/build_externals.py
36#
37RewriteCond /usr/local/autotest/site-packages/django/contrib/admin/media -d
38RewriteRule ^/media/(css|img|js)(.*) /usr/local/autotest/site-packages/django/contrib/admin/media/$1/$2
39RewriteCond /usr/local/autotest/site-packages/django/contrib/admin/media -d
40RewriteRule ^/afe/server/admin/afe/(aclgroup|atomicgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/local/autotest/site-packages/django/contrib/admin/admin/$2/$3
41
42#
43# Django >= 1.4 installed by utils/build_externals.py
44# Since it's not obvious: there's a change in the location of files
45#
46RewriteCond /usr/local/autotest/site-packages/django/contrib/admin/static/admin -d
47RewriteRule ^/media/(css|img|js)(.*) /usr/local/autotest/site-packages/django/contrib/admin/static/admin/$1/$2
48RewriteCond /usr/local/autotest/site-packages/django/contrib/admin/static/admin -d
49RewriteRule ^/afe/server/admin/admin/(css|img|js)(.*) /usr/local/autotest/site-packages/django/contrib/admin/static/admin/$1/$2
50RewriteCond /usr/local/autotest/site-packages/django/contrib/admin/static/admin -d
51RewriteRule ^/afe/server/admin/afe/(aclgroup|atomicgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/local/autotest/site-packages/django/contrib/admin/static/admin/$2/$3
52
53#
54# Python 2.7 and django >= 1.4 installed by distributions packages
55#
56RewriteCond /usr/lib/python2.7/site-packages/django/contrib/admin/static/admin -d
57RewriteRule ^/media/(css|img|js)(.*) /usr/lib/python2.7/site-packages/django/contrib/admin/static/admin/$1/$2
58RewriteCond /usr/lib/python2.7/site-packages/django/contrib/admin/static/admin -d
59RewriteRule ^/afe/server/admin/afe/(aclgroup|atomicgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/lib/python2.7/site-packages/django/contrib/admin/static/admin/$2/$3
60
61#
62# Python 2.7 and django < 1.4 installed by distributions packages
63#
64RewriteCond /usr/lib/python2.7/site-packages/django/contrib/admin/media -d
65RewriteRule ^/media/(css|img|js)(.*) /usr/lib/python2.7/site-packages/django/contrib/admin/media/$1/$2
66RewriteCond /usr/lib/python2.7/site-packages/django/contrib/admin/media -d
67RewriteRule ^/afe/server/admin/afe/(aclgroup|atomicgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/lib/python2.7/site-packages/django/contrib/admin/admin/$2/$3
68
69#
70# Python 2.6 and django < 1.4 installed by distributions packages
71#
72RewriteCond /usr/lib/python2.6/site-packages/django/contrib/admin/media -d
73RewriteRule ^/media/(css|img|js)(.*) /usr/lib/python2.6/site-packages/django/contrib/admin/media/$1/$2
74RewriteCond /usr/lib/python2.6/site-packages/django/contrib/admin/media -d
75RewriteRule ^/afe/server/admin/afe/(aclgroup|atomicgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/lib/python2.6/site-packages/django/contrib/admin/admin/$2/$3
76
77#
78# Python 2.5 and django < 1.4 installed by distributions packages
79#
80RewriteCond /usr/lib/python2.5/site-packages/django/contrib/admin/media -d
81RewriteRule ^/media/(css|img|js)(.*) /usr/lib/python2.5/site-packages/django/contrib/admin/media/$1/$2
82RewriteCond /usr/lib/python2.5/site-packages/django/contrib/admin/media -d
83RewriteRule ^/afe/server/admin/afe/(aclgroup|atomicgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/lib/python2.5/site-packages/django/contrib/admin/admin/$2/$3
84
85#
86# Python 2.4 and django < 1.4 installed by distributions packages
87#
88RewriteCond /usr/lib/python2.4/site-packages/django/contrib/admin/media -d
89RewriteRule ^/media/(css|img|js)(.*) /usr/lib/python2.4/site-packages/django/contrib/admin/media/$1/$2
90RewriteCond /usr/lib/python2.4/site-packages/django/contrib/admin/media -d
91RewriteRule ^/afe/server/admin/afe/(aclgroup|atomicgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/lib/python2.4/site-packages/django/contrib/admin/admin/$2/$3
92
93#
94# Generic Python shared dir and django < 1.4 installed by Debian like packages
95#
96RewriteCond /usr/share/pyshared/django/contrib/admin/media -d
97RewriteRule ^/media/(css|img|js)(.*) /usr/share/pyshared/django/contrib/admin/media/$1/$2
98RewriteCond /usr/share/pyshared/django/contrib/admin/media -d
99RewriteRule ^/afe/server/admin/afe/(aclgroup|atomicgroup|host|label|profiler|test)/admin/(css|img|js)(.*) /usr/share/pyshared/django/contrib/admin/media$2/$3
100
101#
102# Configuration for mod_wsgi
103#
104<IfModule mod_wsgi.c>
105
106    RewriteCond /usr/local/autotest/frontend/frontend.wsgi -f
107    RewriteRule ^/(afe|new_tko)/server(.*) /usr/local/autotest/frontend/frontend.wsgi [H=wsgi-script]
108
109    RewriteCond /usr/lib/python2.7/site-packages/autotest/frontend/frontend.wsgi -f
110    RewriteRule ^/(afe|new_tko)/server(.*) /usr/lib/python2.7/site-packages/autotest/frontend/frontend.wsgi [H=wsgi-script]
111
112    RewriteCond /usr/lib/python2.6/site-packages/autotest/frontend/frontend.wsgi -f
113    RewriteRule ^/(afe|new_tko)/server(.*) /usr/lib/python2.6/site-packages/autotest/frontend/frontend.wsgi [H=wsgi-script]
114
115    RewriteCond /usr/lib/python2.5/site-packages/autotest/frontend/frontend.wsgi -f
116    RewriteRule ^/(afe|new_tko)/server(.*) /usr/lib/python2.5/site-packages/autotest/frontend/frontend.wsgi [H=wsgi-script]
117
118    RewriteCond /usr/lib/python2.4/site-packages/autotest/frontend/frontend.wsgi -f
119    RewriteRule ^/(afe|new_tko)/server(.*) /usr/lib/python2.4/site-packages/autotest/frontend/frontend.wsgi [H=wsgi-script]
120
121    <LocationMatch "/(afe|new_tko)/server(.*)">
122       Options +ExecCGI
123    </LocationMatch>
124
125    WSGISocketPrefix /var/run/wsgi
126    WSGIDaemonProcess autotestapache processes=20 threads=1
127    WSGIProcessGroup autotestapache
128    WSGIPassAuthorization On
129</IfModule>
130
131#
132# Configuration for mod_python
133#
134<IfModule mod_python.c>
135    <Location ~ "/(afe|new_tko)/server">
136        SetHandler python-program
137        PythonHandler django.core.handlers.modpython
138        SetEnv DJANGO_SETTINGS_MODULE frontend.settings
139        PythonDebug On
140        # Force our own site-packages to be loaded by mod_python prior to
141        # mod_python's system python site-packages directory.
142        # This way our code can depend on library versions other than
143        # those available as packages on various OS distributions.
144        PythonPath "['/usr/local/autotest/site-packages', '/usr/local/autotest', '/usr/lib/python2.7/site-packages/autotest', '/usr/lib/python2.6/site-packages/autotest', '/usr/lib/python2.5/site-packages/autotest', '/usr/lib/python2.4/site-packages/autotest'] + sys.path"
145    </Location>
146</IfModule>
147