2011-04-22 22 views
8

我得到這個錯誤在nginx的1.0.0版本配置失敗tornadoweb,未知的指令「用戶」

nginx: [emerg] unknown directive "user" in /etc/nginx/sites-enabled/ 
tornado:1 

如果我刪除用戶WWW的數據的工作進程遇到錯誤

nginx: [emerg] unknown directive "worker_processes" in /etc/nginx/ 
sites-enabled/tornado:1 
nginx的設置

我已經在谷歌搜索,但仍然一無所獲 請幫助

這是我在現場可用

龍捲風0
user www-data www-data; 
worker_processes 1; 

error_log /var/log/nginx/error.log; 
pid /var/run/nginx.pid; 

events { 
    worker_connections 1024; 
    use epoll; 

} 

http { 
    # Enumerate all the Tornado servers here 
    upstream frontends { 
     server 127.0.0.1:8081; 
     server 127.0.0.1:8082; 
     server 127.0.0.1:8083; 
     server 127.0.0.1:8084; 
    } 

    include /etc/nginx/mime.types; 
    default_type application/octet-stream; 

    access_log /var/log/nginx/access.log; 

    keepalive_timeout 65; 
    proxy_read_timeout 200; 
    sendfile on; 
    tcp_nopush on; 
    tcp_nodelay on; 
    gzip on; 
    gzip_min_length 1000; 
    gzip_proxied any; 
    gzip_types text/plain text/html text/css text/xml 
       application/x-javascript application/xml 
       application/atom+xml text/javascript; 

    # Only retry if there was a communication error, not a timeout 
    # on the Tornado server (to avoid propagating "queries of death" 
    # to all frontends) 
    proxy_next_upstream error; 

    server { 
     listen 8080; 

     # Allow file uploads 
     client_max_body_size 50M; 

     location ^~ /static/ { 
      root /var/www; 
      if ($query_string) { 
       expires max; 
      } 
     } 
     location = /favicon.ico { 
      rewrite (.*) /static/favicon.ico; 
     } 
     location = /robots.txt { 
      rewrite (.*) /static/robots.txt; 
     } 

     location/{ 
      proxy_pass_header Server; 
      proxy_set_header Host $http_host; 
      proxy_redirect false; 
      proxy_set_header X-Real-IP $remote_addr; 
      proxy_set_header X-Scheme $scheme; 
      proxy_pass http://frontends; 
     } 
    } 

} 

回答

16

可能有點姍姍來遲,但如果有人在此跌倒這裏有一個提示:

大概配置碰撞,檢查在/ etc/nginx的用相同的指令一個.conf文件。

+0

我不小心在/etc/nginx/nginx.conf裏面包含了/etc/nginx/*.conf,這導致了一個包含循環。在我遵循你的建議之後,我發現了遞歸。謝謝! – Robert 2012-03-23 00:07:02

1

只是想詳細說明Kjetil M.的答案,因爲那對我有用,但我沒有立即明白他的意思。直到經過很多嘗試,我才解決了這個問題,並且有一個「哦,這就是他的意思」這個詞。

如果你的/etc/nginx/nginx.conf文件和其他配置文件之一/ etc/nginx/sites-enabled /使用了相同的指令,比如「user」,你會遇到這個錯誤。只要確保只有1個版本處於活動狀態並註釋掉其他版本。

4

還值得檢查一下,nginx.conf是否有一個「include」行。這很常見,是碰撞的來源。

例如。

[email protected]:~/$ cat /etc/nginx/nginx.conf | grep include 
include /etc/nginx/mime.types; 
include /etc/nginx/conf.d/.conf; 
include /etc/nginx/sites-enabled/; 

在這種情況下,/ etc/nginx/sites-enabled /中的指令將與nginx.conf的內容衝突。確保你沒有在包含文件之間的任何東西上加倍。

0

worker_ *指令必須在構造的頂部,該裝置必須在/etc/nginx/nginx.conf

實施例: 我的首創線有:

user www-data; 
worker_processes 4; 
worker_connections 1024; 

如果你想知道有多少工人是最適合你的服務器的,你可以運行這個命令:

grep processor /proc/cpuinfo | wc -l 

這會告訴你你有多少核心,擁有比網站內核更多的工人是沒有意義的。

如果你想知道你的員工能有多少個連接處理,你可以使用這個

ulimit -n 

希望它能幫助。

0

我得到了同樣的錯誤,但是當我用-c選項nginx的開始作爲

nginx的-c conf.d/MYAPP。CONF

它工作得很好

0

另一件事,如果你已經創建了Windows上的配置文件,並使用在Linux上,確保行結束是正確的(「\ r \ n」與「\ r「)並且該文件不是以unicode存儲的。

相關問題