2017-06-14 30 views
0

我想在我的NGinx服務器上運行Wordpress,但是我認爲有些事情是錯誤的,因爲index.php文件一直在下載而不是正在運行。在Nginx上運行WordPress保持下載文件

這裏是我的地盤,可供選擇:

server { 
    listen 80 default_server; 
    listen [::]:80 default_server ipv6only=on; 

    root /var/www/html; 
    index index.php index.html index.htm; 

    server_name your_domain.com; 

    location/{ 
      # try_files $uri $uri/ =404; 
      try_files $uri $uri/ /index.php?q=$uri&$args; 
    } 

    error_page 404 /404.html; 

    error_page 500 502 503 504 /50x.html; 
    location = /50x.html { 
      root /usr/share/nginx/html; 
    } 

    location ~ \.php$ { 
      try_files $uri =404; 
      fastcgi_split_path_info ^(.+\.php)(/.+)$; 
      fastcgi_pass unix:/var/run/php7.1-fpm.sock; 
      fastcgi_index index.php; 
      include fastcgi_params; 
    } 
} 

我檢查,以確保我有php7.1-FPM運行和我的Nginx的正在運行也是如此。兩個檢查都很好。

我錯過了什麼?

謝謝

+0

本文可能會幫助https://stackoverflow.com/questions/25591040/nginx-serves-php-files-as-downloads-instead-of-executing-them –

+0

可能重複的[ Nginx提供.php文件作爲下載,而不是執行它們](https://stackoverflow.com/questions/25591040/nginx-serves-php-files-as-downloads-instead-of-executing-them) –

+0

@IAmBatman I嘗試了他們在那篇文章中所說的話,但我得到了同樣的結果 – DevShadow

回答

0

這個link解決了我的問題。我錯過了一些wordpress需要的軟件包。經過該指南後,一切工作