Custom Apache Config for PHP and Web2Py
Contents
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
- Transfer the apache SSL configuration from the current crm domain (crm.mainpage.com) to the main domain (mainpage.com):
# mv /usr/local/apache/conf/userdata/ssl/2/main/crm.maindomain.com /usr/local/apache/conf/userdata/ssl/2/main/maindomain.com
- Update the apache config
/usr/local/apache/conf/userdata/ssl/2/main/maindomain.com/wsgi.conf
:
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
- Update web2py routing configuration,
/home/main/python/maindomain.com/app/web2py/routes.py
:
routers = dict(
BASE = dict(
default_application='CRM',
path_prefix='crm',
)
)
- Rebuild apache config:
# /scripts/rebuildhttpdconf
- Restart apache:
# /scripts/restartsrv_httpd