nginx showing blank PHP pages

前端 未结 17 2168
走了就别回头了
走了就别回头了 2020-12-04 05:56

I have setup an nginx server with php5-fpm. When I try to load the site I get a blank page with no errors. Html pages are served fine but not php. I tried turning on disp

相关标签:
17条回答
  • 2020-12-04 06:20

    These hints helped me with my Ubuntu 14.04 LTS install,

    In addition I needed to turn on the short_open_tag in /etc/php5/fpm/php.ini

    $ sudo kate /etc/php5/fpm/php.ini
    
    short_open_tag = On
    
    $ sudo service php5-fpm restart
    $ sudo service nginx reload
    
    0 讨论(0)
  • 2020-12-04 06:21

    Make sure you've got this in /etc/nginx/fastcgi_params

    fastcgi_param SCRIPT_FILENAME $request_filename;

    Who knows why this isn't there already? The amount of time this must collectively waste!

    0 讨论(0)
  • 2020-12-04 06:22

    This is my vhost for UBUNTU 18.04+apache+php7.2

    server {
        listen 80;
        server_name test.test;
        root /var/www/html/{DIR_NAME}/public;
        location / {
            try_files $uri /index.php?$args;
        }
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        }
    }
    

    The last line makes it different than the other answers.

    0 讨论(0)
  • 2020-12-04 06:24

    replace

    include fastcgi_params;
    

    with

    include fastcgi.conf;
    

    and remove fastcgi_param SCRIPT_FILENAME ... in nginx.conf

    0 讨论(0)
  • 2020-12-04 06:27

    Also had this issue and finally found the solution here. In short, you need to add the following line to your nginx fastcgi config file (/etc/nginx/fastcgi_params in Ubuntu 12.04)

    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
    
    0 讨论(0)
提交回复
热议问题