Take the 2-minute tour ×

I've managed to set up my nginx.conf file and it looks like this:

root       www www;

worker_processes 1;

worker_rlimit_nofile 8192;

events {

  worker_connections  8000;

  accept_mutex off;


error_log  logs/error.log;
pid        logs/nginx.pid;

http {
  # Set the mime-types
  include       mime.types;

  # And the fallback mime-type
  default_type  application/octet-stream;

  # Format for our log files
  log_format   main '$remote_addr - $remote_user [$time_local]  $status '
    '"$request" $body_bytes_sent "$http_referer" '
    '"$http_user_agent" "$http_x_forwarded_for"';

  # Click tracking!
  access_log   logs/access.log  main;

  # Nginx are cheap, so generally it's safe to increase it
  keepalive_timeout  5;

  # You usually want to serve static files with Nginx
  sendfile on;


  # Enable Gzip
  gzip  on;
  gzip_http_version 1.0;
  gzip_comp_level 2;
  gzip_min_length 1100;
  gzip_buffers     4 8k;
  gzip_proxied any;
  gzip_types text/html text/plain text/xml application/xml application/xml+rss text/css text/javascript application/javascript application/json;

  gzip_static on;

  gzip_proxied        expired no-cache no-store private auth;
  gzip_disable        "MSIE [1-6]\.";
  gzip_vary           on;

  server {
    # listen 80 default deferred; # for Linux
    # listen 80 default accept_filter=httpready; # for FreeBSD
    listen 80 default;

    # e.g. "localhost" to accept all connections, or "www.example.com"
    # to handle the requests for "example.com" (and www.example.com)
    server_name _;

    # Path for static files
    root /srv/www/example.com/public_html/src/static;

    expires 1M;

    # Static assets
    location ~* ^.+\.(manifest)$ {
      expires -1D;
      root   /srv/www/example.com/public_html/src/;
      access_log /srv/www/example.com/logs/static.logs;

      # Only set expires max IFF the file is a static file and exists
      if (-f $request_filename) {
        expires max;
        root   /srv/www/example.come/public_html/src/static;
        access_log /srv/www/example.com/logs/static.logs;

My questions for nginx file is: 1) I would want to host my application with the domain name : www.example.com, which line of the nginx.conf file do i change?

My nginx.conf file is found in the same folder as app.py.

2) When I was trying to start nginx by typing /etc/init.d/nginx start, I received the following error message:

Error Message:

Starting nginx: [emerg]: bind() to failed (98: Address already in use)
[emerg]: still could not bind()

I have not done any configuration to the nginx.conf file found at /etc/nginx My questions for this part are: 3) How do i fix the error? 4) How do i start nginx automatically?

I've tried running my Tornado app by typing python app.py Than I navigate to http://xxx.xx.xxx.xxx:8888 , and my app works correctly.

However, should I close my terminal ( killing the process ) , my tornado app is no longer active.

My question here is: 5) how do i start tornado app automatically? 6) How do i run tornado on a domain name?

Thank you all for your kind patience.

Best Regards.

share|improve this question
If you haven't done so already, try cross-posting this to ServerFault –  Jordan Reiter Mar 23 '11 at 14:52
You need to give more information about the environment your working in; eg. which version of linux you have installed, which version of nginx/python, etc. –  unpluggd Apr 12 '11 at 10:55
add comment

2 Answers

about the error message: the same problem when using Ubuntu 11.10 , it seems that Opera occupy the port 80, so just modify the value.

share|improve this answer
add comment

1) Change the server_name.

2) You probably have Apache running.

3) Stop the service (using something like service httpd stop) and then start nginx.

4) Try the following commands:

$ chkconfig httpd off
$ chkconfig --add nginx
$ chkconfig nginx on
$ service nginx start

5) Look at using supervisor for running python apps

6) Check out the nginx wiki for information on reverse proxying; nginx handles requests to the domain and passes those requests to your tornado backend.

share|improve this answer
add comment

Your Answer


