DevOps Zone is brought to you in partnership with:

Matthew is a Linux Consultant and Systems Administrator specialising in removing human error from configuration and deployment through the use of automation. He has supported systems of all sizes, from small businesses to home entertainment and major cloud providers. Matthew is a DZone MVB and is not an employee of DZone and has posted 9 posts at DZone. You can read more from them at their website. View Full User Profile

Migrating from Apache to Nginx with the Edison Build System

  • submit to reddit

I’ve recently decided to take the plunge and move from Apache and Mod_WSGI to Nginx and FastCGI – I was amazed at how simple it was!

To get Edison up and running under Nginx as a fast-cgi Deamon, you just need to do the following:

Install the required packages from EPEL:

rpm -Uvh

yum update

yum install nginx pypthon-flup

The configure a new server (we’ll setup a fake dns hostname of ‘edison.localdomain’) in /etc/nginx/conf.d/edison as follows:

    server {
    # setup the server name
    server_name edison.localdomain;

    # make sure we’re only listening on HTTPS
    listen 443;

    ssl                  on;
    ssl_certificate      /path/to/ssl/edison.localdomain.crt;
    ssl_certificate_key  /path/to/ssl/edison.localdomain.key;

    # Point to the document root
    root /var/djangosites/edison/;

    # setup logging
    error_log /var/log/nginx/edison.localdomain.error;
    access_log /var/log/nginx/edison.localdomain.access;

    # Setup the alias for the Media Directory
    location /media {
    alias /var/djangosites/edison/media/;

    # setup the fastcgi settings
    location / {
    # host and port to fastcgi server
    fastcgi_param PATH_INFO $fastcgi_script_name;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param QUERY_STRING $query_string;
    fastcgi_param SERVER_NAME $server_name;
    fastcgi_param SERVER_PORT $server_port;
    fastcgi_param SERVER_PROTOCOL $server_protocol;
    fastcgi_param CONTENT_TYPE $content_type;
    fastcgi_param CONTENT_LENGTH $content_length;
    fastcgi_param REMOTE_USER       $remote_user;
    fastcgi_param REMOTE_ADDR       $remote_addr;
    fastcgi_param REMOTE_PORT       $remote_port;
    fastcgi_pass_header Authorization;
    fastcgi_intercept_errors off;

Once that’s in place, restart NGinx and then cd to the Edison App dir and run the following command:

./ runfcgi method=threaded host= port=8801

This will start the fast-cgi python script.

Now you can visit https://edison.localdomain/ (assuming it is setup in your DNS!) and you should be able to browse Edison without any issue.

Published at DZone with permission of Matthew Macdonald-wallace, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)