2012年4月23日 星期一

Some install record concerning mod_wsgi on gentoo

Target: Using Virtual Server (I called it prototype :) ).

Request modify the hosts file

/etc/apache2/modules.d/70_mod_wsgi.conf

# WSGISocketPrefix is require 'mkdir /usr/lib/apache2/run'
WSGISocketPrefix
#WSGIPythonOptimize enable output the pac file
WSGIPythonOptimize 1
WSGILazyInitialization Off
#WSGIImportScript path process-group=prototype application-group=prototype
#WSGIPythonHome
#WSGIPythonPath


/etc/apache2/vhosts.d/00_default_vhost.conf

<VirtualHost *:80>
ServerName prototype
ErrorLog /var/log/apache2/prototype_error_log
CustomLog /var/log/apache2/prototype_access_log common

Include /etc/apache2/vhosts.d/prototype.include

<IfModule mpm_peruser_module>
ServerEnvironment apache apache
</IfModule>
</VirtualHost>



/etc/apache2/vhosts.d/prototype.include

ServerAdmin masked@masked
DocumentRoot "/var/www/prototype/htdocs"
<Directory "/var/www/prototype/htdocs">
# Enable AllowOverride in order to use '.htaccess' to modify the access right on the fly
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
# Using Alias since mount the DocumentRoot as root "...any static files contained in the DocumentRoot will be hidden and requests against URLs pertaining to the static files will instead be processed by the WSGI application. from:http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide"

Alias /favicon.ico /var/www/prototype/htdocs/favicon.ico
Alias /media/ /var/www/prototype/htdocs/media/

WSGIScriptAlias / /var/www/prototype/htdocs/wsgi_script/runme.py
WSGIDaemonProcess prototype:1 processes=2 threads=15 display-name=%{GROUP} user=prototype group=prototype umask=0022 maximum-requests= 1024 deadlock-timeout=5 shutdown-timeout=3 receive-buffer-size=87380 send-buffer-size=65536
#-WSGIDaemonProcess
WSGIProcessGroup prototype:1
WSGIRestrictProcess prototype:1


/var/www/prototype/htdocs/wsgi_script/runme.py

import sys

def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'

response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)

print >> sys.stderr, 'sys.prefix = %s' % repr(sys.prefix)
print >> sys.stderr, 'sys.path = %s' % repr(sys.path)

return [output]


All dir/.htaccess

AddDefaultCharset utf-8
# Disable directory index
Options -All

沒有留言:

張貼留言