I installed web2py with mod_wsgi on centos 5.2.
I haven't used it extensively, but I did get it to work 
for a couple of my web2py applications.

Instead of running the install script, I manually implemented
most of the steps from the setup-web2py-fedora.sh script.
I have selinux disabled in this configuration.
The following is a record of what I did...
No guarantees...

############################################################

You will probably need the following packages.
httpd.i386          
mod_ssl.i386        
wget.i386           
httpd-devel.i386    
sqlite-devel.i386   
zlib-devel.i386     

The python on most servers is 2.5, so I will rebuild it for 2.7
===============================================================
/usr/local/Python-2.7.2
./configure --prefix=/usr/local --with-threads --enable-shared 
--with-zlib=/usr/include
make && make install

Rebuild mod_wsgi to use the new python:
=======================================
/usr/local/tar# wget http://modwsgi.googlecode.com/files/mod_wsgi-3.3.tar.gz
cd /usr/local/mod_wsgi-3.3
./configure --with-python=/usr/local/bin/python
make && make install

Install web2py somewhere. It must be owned by the apache process.
=================================================================
mkdir -p /opt/web-apps
chmod 755 /opt
chmod 755 /opt/web-apps
cd /opt/web-apps
wget http://web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip
chown -R apache:apache web2py


Setup SSL
=========
mkdir -p /etc/httpd/ssl
openssl genrsa 1024 > /etc/httpd/ssl/self_signed.key
openssl req -new -x509 -nodes -sha1 -days 365 -key 
/etc/httpd/ssl/self_signed.yum list httpd mod_ssl mod_wsgi wget python 
httpd-devel sqlite-devel zlib-devel
key > /etc/httpd/ssl/self_signed.cert
(supply appropriate responses)

openssl x509 -noout -fingerprint -text < /etc/httpd/ssl/self_signed.cert > 
/etc/httpd/ssl/self_signed.info

Setup web2py admin password
===========================
cd /opt/web-apps/web2py

sudo -u apache python -c "from gluon.main import save_password; 
save_password(raw_input('admin password: '),443)"
xxxx

Configure Apache
================
/etc/httpd/conf.d
... wsgi.conf ..............................................
LoadModule wsgi_module modules/mod_wsgi.so
WSGISocketPrefix run/wsgi
............................................................

- mod_python interferes with mod_wsgi.
- hide or remove mod_python.conf from /etc/httpd/conf.d
 
############################################################


############################################################
I followed various instructions I found in the web2py group
to build web2py.conf.
There are simpler configurations, but I needed web2py to 
coexist with other pre-existing httpd applications.

This configuration serves two named web2py apps: app1 and app2

--- /etc/httpd/conf.d/web2py.conf --------------------------
NameVirtualHost *:80
NameVirtualHost *:443

<VirtualHost *:80>
  ServerName MyServer
  RewriteEngine on 
  RewriteRule ^/app1(.*)$ /w2p/app1$1 [PT,L] 
  RewriteRule ^/app2(.*)$ /w2p/app2$1 [PT,L] 
# RewriteLog "/var/log/httpd/rewrite_log"
# RewriteLogLevel 9
  WSGIScriptAlias /w2p /opt/web-apps/web2py/wsgihandler.py
  WSGIDaemonProcess web2py user=apache group=apache 
home=/opt/web-apps/web2py
  WSGIProcessGroup web2py

  <Directory /opt/web-apps/web2py>
        AllowOverride None
        Order Allow,Deny
        Deny from all
        <Files wsgihandler.py>
          Allow from all
        </Files>
  </Directory>

  AliasMatch ^/([^/]+)/static/(.*) 
/opt/web-apps/web2py/applications/$1/static/$2

  <Directory /opt/web-apps/web2py/applications/*/static>
        Options -Indexes
        Order Allow,Deny
        Allow from all
  </Directory>

  <Location /admin>
        Deny from all
  </Location>

  <LocationMatch ^/([^/]+)/appadmin>
        Deny from all
  </LocationMatch>

  CustomLog /var/log/httpd/access_log common
  ErrorLog /var/log/httpd/error_log
</VirtualHost>

<VirtualHost *:443>
  ServerName MyServer
  SSLEngine on
  SSLCertificateFile /etc/httpd/ssl/self_signed.cert
  SSLCertificateKeyFile /etc/httpd/ssl/self_signed.key

  RewriteEngine on 
  RewriteRule ^/admin(.*)$ /w2p/admin$1 [PT,L] 
  RewriteRule ^/examples(.*)$ /w2p/examples$1 [PT,L] 

# RewriteLog "/var/log/httpd/rewrite_log"
# RewriteLogLevel 9

  WSGIScriptAlias /w2p /opt/web-apps/web2py/wsgihandler.py
  WSGIDaemonProcess web2py2 user=apache group=apache 
home=/opt/web-apps/web2py
  WSGIProcessGroup web2py2

  <Directory /opt/web-apps/web2py>
    AllowOverride None
    Order Allow,Deny
    Deny from all
    <Files wsgihandler.py>
      Allow from all
    </Files>
  </Directory>

  AliasMatch ^/([^/]+)/static/(.*) 
/opt/web-apps/web2py/applications/$1/static/$2

  <Directory /opt/web-apps/web2py/applications/*/static>
    Options -Indexes
    ExpiresActive On
    ExpiresDefault "access plus 1 hour"
    Order Allow,Deny
    Allow from all
  </Directory>

  CustomLog /var/log/httpd/access_log common
  ErrorLog /var/log/httpd/error_log
</VirtualHost>

------------------------------------------------------------
############################################################




Reply via email to