NGINX下载PHP文件而不是显示

时间:2018-01-18 22:03:08

标签: php linux nginx

我正在尝试在我的NGINX网络服务器上显示index.php和info.php,但由于某些原因我无法正常工作,我的浏览器不断下载文件而不是显示它们。我尝试了很多教程,但我不知道什么是错的。

操作系统:Ubuntu 17.10服务器

PHP版本:7.1

cgi.fix_pathinfo设置为0

除了de cgi.fix_pathinfo

之外,

www.conf文件是默认的

server {
    listen 80 default_server;
    listen [::]:80 default_server;


    root /var/www/html;

  # Add index.php to the list if you are using PHP
    index index.php index.html index.htm index.nginx-debian.html;

    server_name nginx1.domain.com;

    location / {
        try_files $uri $uri/ =404;
   }

    location ~ \.php$ {
            try_files $uri $uri/ =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
    #       # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
    #
    #       # With php5-cgi alone:
            fastcgi_pass 127.0.0.1:9000;
    #       # With php5-fpm:
                fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
    }

    #location ~ /\.ht {
    #       deny all;
    #}
}

有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:0)

请尝试这个较小的例子。

python setup.py install --prefix /home/peng/python-temp
running install
Checking .pth file support in /home/peng/python-temp/lib/python3.6/site-packages/
/opt/conda3/bin/python -E -c pass
TEST FAILED: /home/peng/python-temp/lib/python3.6/site-packages/ does NOT support .pth files
error: bad install directory or PYTHONPATH

You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from.  The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /home/peng/python-temp/lib/python3.6/site-packages/

and your PYTHONPATH environment variable currently contains:

    ''

Here are some of your options for correcting the problem:

* You can choose a different installation directory, i.e., one that is
  on PYTHONPATH or supports .pth files

* You can add the installation directory to the PYTHONPATH environment
  variable.  (It must then also be on PYTHONPATH whenever you run
  Python and want to use the package(s) you are installing.)

* You can set up the installation directory to support ".pth" files by
  using one of the approaches described here:

  https://setuptools.readthedocs.io/en/latest/easy_install.html#custom-installation-locations


Please make the appropriate changes for your system and try again.

仔细检查你的php-fpm是否正在运行:

location ~ \.php$ {
        fastcgi_pass unix:/run/php/php7.1-fpm.sock;
        include snippets/fastcgi-php.conf;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }