How to run Hue with the Apache Server

Published on 11 December 2014 in - 2 minutes read - Last modified on 06 March 2021

Hue ships out of the box with the HTTP server CherryPy, but some users have expressed interest having Apache HTTP 2 serve Hue with mod_wsgi. Their motivation is that they are more familiar with Apache or have already several Apache instances deployed.

It turns out it’s pretty simple to do. It only requires a small script, a Hue configuration option, and a configuration block inside Apache. This post describes how to have Apache serve the static content and run the Python code of Hue.

 

This script (which was just added in desktop/core/desktop/wsgi.py) enables any Web server that speaks WSGI to launch Hue and route requests to it:



import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "desktop.settings")

\# This application object is used by the development server

\# as well as any WSGI server configured to use this file.

from django.core.wsgi import get_wsgi_application

application = get_wsgi_application()

The next step disables booting Hue from the runcpserver command. In Cloudera Manager, go to Hue > Configuration > Service-Wide > Advanced, and add the following to the hue safety valve:

If you are running Hue outside of Cloudera Manager, modify desktop/conf/hue.ini with:



[desktop]

...

enable_server=no

The final step is to configure Apache to launch Hue by adding the following to the apache.conf:

WSGIScriptAlias / $HUE_PATH/desktop/core/src/desktop/wsgi.py

WSGIPythonPath $HUE_PATH/desktop/core/src/desktop:$HUE_PATH/build/env/lib/python2.7/site-packages

WSGIDaemonProcess $HOSTNAME home=$HUE_PATH python-path=$HUE_PATH/desktop/core/src/desktop:$HUE_PATH/build/env/lib/python2.7/site-packages threads=30

WSGIProcessGroup $HOSTNAME





Order Deny,Allow

\# If apache 2.4

Require all granted

\# otherwise

\# Allow from all

\# Some systems, like Redhat, lock down /var/run, so you may need to change where to store the socket with:

\# WSGISocketPrefix run/wsgi





Where $HOSTNAME should be the hostname of the machine running Hue, and $HUE_PATH is where Hue is installed. If you’re using Cloudera Manager, by default it should be either /usr/lib/hue for a package install, or /opt/cloudera/parcels/CDH/lib/hue for a parcel install.

 

Have any questions? Feel free to contact us on hue-user or @gethue!


comments powered by Disqus

More recent stories

26 June 2024
Integrating Trino Editor in Hue: Supporting Data Mesh and SQL Federation
Read More
03 May 2023
Discover the power of Apache Ozone using the Hue File Browser
Read More