2013-05-25 8 views
9

Recentemente ho installato NGINX e PHP-FPM su un server Centos6. Sono in grado di visualizzare altre pagine PHP sul mio sito, ma per qualche ragione il mio file index.php viene scaricato piuttosto che elaborato come una normale pagina php.NGINX e PHP-FPM stanno scaricando index.php invece di elaborarlo

Qui è il config nginx:

# The default server 
# 
server { 
listen  80 default_server; 
server_name example.com; 

#charset koi8-r; 

#access_log logs/host.access.log main; 

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

error_page 404    /404.html; 
location = /index.php { 
    root /var/www/html; 
} 

# redirect server error pages to the static page /50x.html 
# 
error_page 500 502 503 504 /50x.html; 
location = /50x.html { 
    root /usr/share/nginx/html; 
} 

# proxy the PHP scripts to Apache listening on 127.0.0.1:80 
# 
#location ~ \.php$ { 
# proxy_pass http://127.0.0.1; 
#} 

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 
# 
location ~ \.php$ { 
    root   /var/www/html; 
    fastcgi_pass 127.0.0.1:9000; 
    fastcgi_index index.php; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    include  fastcgi_params; 
} 

# deny access to .htaccess files, if Apache's document root 
# concurs with nginx's one 
# 
location ~ /\.ht { 
    deny all; 
} 

} 

risposta

6

tenta di rimuovere questo blocco:

location = /index.php { 
    root /var/www/html; 
} 
+0

SI! Funziona! GRAZIE! – Salty

+4

Una piccola spiegazione del motivo per cui ciò accadrà, mi avrà '+ 1' da me – samayo

+3

Credo perché viene prima del blocco" location ~ \ .php $ "e corrisponde a /index.php che viene eseguito per primo, e doesn ' t includere qualsiasi comando di fastcgi per dire a nginx di effettuare la chiamata a fastcgi ... così nginx serve il file php come download binario perché non sa cosa fare con un file .php –

Problemi correlati