2012-11-21 48 views
2

了我在運行的nginx + PHP-FPM這個簡單配置的服務器:Nginx的&穆寧 - 位置和錯誤404

server { 
    listen 80; 
    server_name ipoftheserver; 
    access_log /var/www/default/logs/access.log; 
    error_log /var/www/default/logs/error.log; 

    location/{ 
     root /var/www/default/public_html; 
     index index.html index.htm index.php; 
    } 


    location ^~ /munin/ { 
     root /var/cache/munin/www/; 
     index index.html index.htm index.php; 
    } 

    location ~\.php$ { 
    include /etc/nginx/fastcgi_params; 
    fastcgi_pass 127.0.0.1:9000; 
    fastcgi_index index.php; 
    fastcgi_param SCRIPT_FILENAME /var/www/default/public_html$fastcgi_script_name; 
    } 
} 

但是當我打開ipoftheserver /穆寧/我收到一個404錯誤(當我請求ipoftheserver// var/www/default/public_html上的文件正確收聽)

Munin安裝完好,工作正常。如果我刪除這個配置我用這一個又一個一切工作好(但不是在/穆寧/目錄):

server { 
    server_name ipoftheserver; 
    root /var/cache/munin/www/; 
    location/{ 
    index index.html; 
    access_log off; 
    } 
} 

如何解決?對你的幫助非常感謝

回答

2

使用,而不是根本解決別名

server { 
    listen 80; 
    server_name ipoftheserver; 
    access_log /var/www/default/logs/access.log; 
    error_log /var/www/default/logs/error.log; 

    location/{ 
     root /var/www/default/public_html; 
     index index.html index.htm index.php; 
    } 


    location /munin/ { 
     alias /var/cache/munin/www/; 
     index index.html index.htm index.php; 
    } 

    location ~\.php$ { 
     include /etc/nginx/fastcgi_params; 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_param SCRIPT_FILENAME /var/www/default/public_html$fastcgi_script_name; 
    } 
}