Custom Apache Config for PHP and Web2Py

Problem:

As you probably know, the web2py admin must be hosted on a secured domain. We set a client up with a basic CRM system under the domain http://crm.maindomain.com, which worked perfectly until a GeoTrust SSL Certificate was installed.

Since the purchased GeoTrust certificate was just for a single domain, there was no way to access the web2py admin unless another dedicated IP address was purchased - which the site owner did not want to pay for.

Fortunately, there is a work around.

Solution:

After hours of research/tests, the identified solution was to configure the web2py application, as well as the admin, under the main domain:

  • App: https://maindomain.com/crm
  • Admin: https://maindomain.com/crm/admin

Essentially, any URL pattern that fell under /crm/ would be served by web2py, while all other URLS would be served by an existing Joomla application.

Steps:

  1. Transfer the apache SSL configuration from the current crm domain (crm.mainpage.com) to the main domain (mainpage.com):
1
# mv /usr/local/apache/conf/userdata/ssl/2/main/crm.maindomain.com /usr/local/apache/conf/userdata/ssl/2/main/maindomain.com
  1. Update the apache config /usr/local/apache/conf/userdata/ssl/2/main/maindomain.com/wsgi.conf:
1
2
3
4
ServerName maindomain.com
ServerAlias crm.maindomain.com www.maindomain.com

WSGIScriptAlias /crm /home/main/python/maindomain.com/app/app.wsgi

Note: Make sure to also comment out ‘UserDir disabled’ and all apache Rewrite lines

  1. Update web2py routing configuration, /home/main/python/maindomain.com/app/web2py/routes.py:
1
2
3
4
5
6
routers = dict(
    BASE = dict(
    default_application='CRM',
    path_prefix='crm',
    )
)
  1. Rebuild apache config:
1
# /scripts/rebuildhttpdconf
  1. Restart apache:
1
# /scripts/restartsrv_httpd

Comments