2014-12-11-how-to-run-hue-with-the-apache-server.md 3.9 KB


title: How to run Hue with the Apache Server author: admin type: post date: 2014-12-11T23:21:39+00:00 url: /how-to-run-hue-with-the-apache-server/ sf_thumbnail_type:

  • none sf_thumbnail_link_type:
  • link_to_post sf_detail_type:
  • none sf_page_title:
  • 1 sf_page_title_style:
  • standard sf_no_breadcrumbs:
  • 1 sf_page_title_bg:
  • none sf_page_title_text_style:
  • light sf_background_image_size:
  • cover sf_social_sharing:
  • 1 sf_sidebar_config:
  • left-sidebar sf_left_sidebar:
  • Sidebar-2 sf_right_sidebar:
  • Sidebar-1 sf_caption_position:
  • caption-right sf_remove_promo_bar:
  • 1 slide_template:
  • default sf_thumbnail_image:
  • 1892 categories:
  • Administration

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!