3

nginx.conf ファイルをセットアップできました。次のようになります。

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;

  # ~2 seconds is often enough for HTML/CSS, but connections in
  # 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;

  tcp_nopush on; # off may be better for Comet/long-poll stuff
  tcp_nodelay off; # on may be better for Comet/long-poll stuff

  # 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;
    }

    location ~* ^.+\.(ico|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
      # 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;
      }
    }
  }
}

nginx ファイルに関する私の質問は次のとおりです。1) アプリケーションをドメイン名 www.example.com でホストしたいのですが、nginx.conf ファイルのどの行を変更すればよいですか?

私の nginx.conf ファイルは、app.py と同じフォルダーにあります。

2) /etc/init.d/nginx start と入力して nginx を起動しようとすると、次のエラー メッセージが表示されました。

エラーメッセージ:

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

/etc/nginx にある nginx.conf ファイルの構成を行っていません。この部分に関する質問は次のとおりです。3) エラーを修正するにはどうすればよいですか? 4) nginx を自動的に起動するにはどうすればよいですか?

python app.py と入力して Tornado アプリを実行しようとしましたが、http://xxx.xx.xxx.xxx:8888に移動すると、アプリが正しく動作します。

ただし、端末を閉じる (プロセスを強制終了する) と、トルネード アプリはアクティブではなくなります。

ここでの私の質問は次のとおりです。5) トルネード アプリを自動的に起動するにはどうすればよいですか? 6) ドメイン名でトルネードを実行するにはどうすればよいですか?

皆様、今しばらくお待ちいただきますようお願い申し上げます。

よろしくお願いします。

4

2 に答える 2

1

1)を変更しserver_nameます。

2)おそらくApacheを実行しています。

3)サービスを停止し(のようなものを使用してservice httpd stop)、nginxを開始します。

4)次のコマンドを試してください。

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

5)Pythonアプリを実行するためのスーパーバイザーの使用を検討してください

6)リバースプロキシについては、 nginxwikiを確認してください。nginxはドメインへのリクエストを処理し、それらのリクエストをトルネードバックエンドに渡します。

于 2011-04-12T10:54:54.520 に答える
0

エラーメッセージについて:Ubuntu 11.10を使用している場合と同じ問題で、Operaがポート80を占有しているように見えるので、値を変更するだけです。

于 2011-11-30T19:54:02.930 に答える