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.