| | 268 | # Apache Web server |
| | 269 | # ----------------------------------------------------------------------------- |
| | 270 | echo "Setting up Web server" |
| | 271 | |
| | 272 | rm -f /etc/apache2/sites-enabled/000-default |
| | 273 | cat << EOF > "/etc/apache2/sites-available/$hostname.$DOMAIN" |
| | 274 | <VirtualHost *:80> |
| | 275 | ServerName $hostname.$DOMAIN |
| | 276 | ServerAdmin webmaster@$DOMAIN |
| | 277 | DocumentRoot /home/web2py/applications |
| | 278 | |
| | 279 | WSGIScriptAlias / /home/web2py/wsgihandler.py |
| | 280 | ## Edit the process and the maximum-requests to reflect your RAM |
| | 281 | WSGIDaemonProcess web2py user=web2py group=web2py home=/home/web2py processes=4 maximum-requests=100 |
| | 282 | |
| | 283 | RewriteEngine On |
| | 284 | # extract desired cookie value from multiple-cookie HTTP header |
| | 285 | RewriteCond %{HTTP_COOKIE} registered=([^;]+) |
| | 286 | # check that cookie value is correct |
| | 287 | RewriteCond %1 ^yes$ |
| | 288 | RewriteRule ^/$ /eden/ [R,L] |
| | 289 | RewriteRule ^/$ /eden/static/index.html [R,L] |
| | 290 | RewriteCond %{REQUEST_URI} !/phpmyadmin(.*) |
| | 291 | RewriteCond %{REQUEST_URI} !/eden/(.*) |
| | 292 | RewriteRule /(.*) /eden/$1 [R] |
| | 293 | |
| | 294 | ### static files do not need WSGI |
| | 295 | <LocationMatch "^(/[\w_]*/static/.*)"> |
| | 296 | Order Allow,Deny |
| | 297 | Allow from all |
| | 298 | |
| | 299 | SetOutputFilter DEFLATE |
| | 300 | BrowserMatch ^Mozilla/4 gzip-only-text/html |
| | 301 | BrowserMatch ^Mozilla/4\.0[678] no-gzip |
| | 302 | BrowserMatch \bMSIE !no-gzip !gzip-only-text/html |
| | 303 | SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary |
| | 304 | Header append Vary User-Agent env=!dont-vary |
| | 305 | |
| | 306 | ExpiresActive On |
| | 307 | ExpiresByType text/html "access plus 1 day" |
| | 308 | ExpiresByType text/javascript "access plus 1 week" |
| | 309 | ExpiresByType text/css "access plus 2 weeks" |
| | 310 | ExpiresByType image/ico "access plus 1 month" |
| | 311 | ExpiresByType image/gif "access plus 1 month" |
| | 312 | ExpiresByType image/jpeg "access plus 1 month" |
| | 313 | ExpiresByType image/jpg "access plus 1 month" |
| | 314 | ExpiresByType image/png "access plus 1 month" |
| | 315 | ExpiresByType application/x-shockwave-flash "access plus 1 month" |
| | 316 | </LocationMatch> |
| | 317 | ### everything else goes over WSGI |
| | 318 | <Location "/"> |
| | 319 | Order deny,allow |
| | 320 | Allow from all |
| | 321 | WSGIProcessGroup web2py |
| | 322 | </Location> |
| | 323 | |
| | 324 | ErrorLog /var/log/apache2/$hostname_error.log |
| | 325 | LogLevel warn |
| | 326 | CustomLog /var/log/apache2/$hostname_access.log combined |
| | 327 | </VirtualHost> |
| | 328 | EOF |
| | 329 | a2ensite "$hostname.$DOMAIN" |
| | 330 | apache2ctl restart |
| | 331 | |
| | 332 | cat << EOF > "/etc/apache2/sites-available/maintenance" |
| | 333 | <VirtualHost *:80> |
| | 334 | ServerName $hostname.$DOMAIN |
| | 335 | ServerAdmin webmaster@$DOMAIN |
| | 336 | DocumentRoot /var/www |
| | 337 | |
| | 338 | RewriteEngine On |
| | 339 | RewriteCond %{REQUEST_URI} !/phpmyadmin(.*) |
| | 340 | RewriteRule ^/(.*) /maintenance.html |
| | 341 | |
| | 342 | <Location "/"> |
| | 343 | Order deny,allow |
| | 344 | Allow from all |
| | 345 | </Location> |
| | 346 | |
| | 347 | ErrorLog /var/log/apache2/maintenance_error.log |
| | 348 | LogLevel warn |
| | 349 | CustomLog /var/log/apache2/maintenance_access.log combined |
| | 350 | </VirtualHost> |
| | 351 | EOF |
| | 352 | |
| | 353 | # ----------------------------------------------------------------------------- |