2012-06-07 80 views
12

使用nginx/0.7.65我在第4行發現此錯誤。爲什麼它不識別server/etc/nginx/nginx.conf中的未知指令「server」:4

#### CHAT_FRONT #### 

server { 
    listen 7000 default deferred; 
    server_name example.com; 
    root /home/deployer/apps/chat_front/current/public; 

    location ^~ /assets/ { 
    gzip_static on; 
    expires max; 
    add_header Cache-Control public; 
    } 

    error_page 500 502 503 504 /500.html; 
    client_max_body_size 4G; 
    keepalive_timeout 10; 
} 

#### CHAT_STORE #### 

server { 
    listen 7002 default deferred; 
    server_name store.example.com; 
    root /home/deployer/apps/chat_store/current/public; 

    error_page 500 502 503 504 /500.html; 
    client_max_body_size 4G; 
    keepalive_timeout 10; 
} 

#### LOGIN #### 

server { 
    listen 7004 default deferred; 
    server_name login.example.com; 
    root /home/deployer/apps/login/current/public; 

    location ^~ /assets/ { 
    gzip_static on; 
    expires max; 
    add_header Cache-Control public; 
    } 

    error_page 500 502 503 504 /500.html; 
    client_max_body_size 4G; 
    keepalive_timeout 10; 
} 

#### PERMISSIONS #### 

server { 
    listen 7006 default deferred; 
    server_name permissions.example.com; 
    root /home/deployer/apps/permissions/current/public; 

    error_page 500 502 503 504 /500.html; 
    client_max_body_size 4G; 
    keepalive_timeout 10; 
} 

#### SEARCH #### 

server { 
    listen 7008 default deferred; 
    server_name search.example.com; 
    root /home/deployer/apps/search/current/public; 

    error_page 500 502 503 504 /500.html; 
    client_max_body_size 4G; 
    keepalive_timeout 10; 
} 

#### ANALYTICS #### 

server { 
    listen 7010 default deferred; 
    server_name analytics.example.com; 
    root /home/deployer/apps/analytics/current/public; 

    error_page 500 502 503 504 /500.html; 
    client_max_body_size 4G; 
    keepalive_timeout 10; 
} 

回答

23

server指令必須包含在http模塊的上下文中。另外,您缺少頂層事件模塊,該模塊有一個強制設置,以及一系列將位於配置的http模塊中的節。雖然nginx documentation對於從零開始創建配置並不特別有幫助,但在那裏有working examples

來源:nginx documentation on server directive

+1

http指令裏面還有其他的設置,我必須做或只是包裝它? – Chris

+3

現在我得到'沒有「事件」部分在配置中# – Chris

+1

http://wiki.nginx.org/FullExample試試這個。 Events模塊用於告訴nginx如何處理連接(例如,一個worker可以同時保留多少個連接 - 事實上,它是'events'唯一的強制節)。可以在http://wiki.nginx.org/Configuration –

7

添加頂層入口得到解決該問題:

events { } 
0

我改寫了* .conf文件和它的工作。