2017-06-14 55 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需要的软件包。经过该指南后,一切工作