Over a million developers have joined DZone.

Migrating from Apache to Nginx with the Edison Build System

The DevOps zone is brought to you in partnership with Sonatype Nexus. The Nexus suite helps scale your DevOps delivery with continuous component intelligence integrated into development tools, including Eclipse, IntelliJ, Jenkins, Bamboo, SonarQube and more. Schedule a demo today

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 http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

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_pass 127.0.0.1:8801;
    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:

./manage.py runfcgi method=threaded host=127.0.0.1 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.

The DevOps zone is brought to you in partnership with Sonatype Nexus. Use the Nexus Suite to automate your software supply chain and ensure you're using the highest quality open source components at every step of the development lifecycle. Get Nexus today

Topics:

Published at DZone with permission of Matthew Macdonald-wallace, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}