Anthony
Anthony

Reputation: 23

Use custom mod_wsgi and python with limited access to a shared server

I've been given access to an Ubuntu machine running Apache 2.4.18 for the purpose of hosting a small web application I've developed in Flask. I'm a user without root privileges. The system administrator has kindly installed mod_wsgi for me, but this module is linked against the system python, which is version 2.7, and I'd like to use python >= 3.6. I've therefore compiled my own python 3.7 and my own mod_wsgi on this machine, and am having trouble getting Apache to use it. Is this possible?

I've tried adding a LoadModule wsgi_module .../mod_wsgi-py37.cpython-37m-x86-64-linux-gnu.so line to var/www/html/whatever/.htaccess, but have learned that this is not allowed at the Directory level of the configuration. I've also tried using WSGIDaemonProcess user python-home=..., but this also causes Apache to return an Internal Server Error.

To make matters worse, I do not have permissions on var/log/apache2, so I can't see any Apache output except what it's serving.

Is it possible to point Apache to my own mod_wsgi and python binaries without having access to the root configuration of Apache or the system? If not, are there any workarounds?

Upvotes: 1

Views: 125

Answers (1)

Mark Bailey
Mark Bailey

Reputation: 1675

AFAIK you can only run Apache with a single version of mod_wsgi at any one time. This means that all apps must use the same version of Python, which is a problem I have run into before. I think your options are:

a) Persuade the sysadmin to switch to your version. It is fine to use a version of Python that is different to system Python.

b) Have a look at something like Gunicorn. That is more separated from Apache, so will allow apps to use different versions of Python on the same server.

Upvotes: 1

Related Questions