nginx showing blank PHP pages

前端 未结 17 2166
走了就别回头了
走了就别回头了 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:03

    Add this in /etc/nginx/conf.d/default.conf:

    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
    
    0 讨论(0)
  • 2020-12-04 06:03
    location ~ [^/]\.php(/|$) {
             fastcgi_pass unix:/PATH_TO_YOUR_PHPFPM_SOCKET_FILE/php7.0-fpm.sock;
             include fastcgi_params;
             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
             fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    }
    

    Good luck

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

    In case anyone is having this issue but none of the above answers solve their problems, I was having this same issue and had the hardest time tracking it down since my config files were correct, my ngnix and php-fpm jobs were running fine, and there were no errors coming through any error logs.

    Dumb mistake but I never checked the Short Open Tag variable in my php.ini file which was set to short_open_tag = Off. Since my php files were using <? instead of <?php, the pages were showing up blank. Short Open Tag should have been set to On in my case.

    Hope this helps someone.

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

    If you getting a blank screen, that may be because of 2 reasons:

    1. Browser blocking the Frames from being displayed. In some browsers the frames are considered as unsafe. To overcome this you can launch the frameless version of phpPgAdmin by

      http://-your-domain-name-/intro.php

    2. You have enabled a security feature in Nginx for X-Frame-Options try disabling it.

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

    This solved my issue:

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include snippets/fastcgi-php.conf;
        # With php5-fpm:
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        include fastcgi_params;
    }
    
    0 讨论(0)
  • 2020-12-04 06:09

    For reference, I am attaching my location block for catching files with the .php extension:

    location ~ \.php$ {
        include /path/to/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
    }
    

    Double-check the /path/to/fastcgi-params, and make sure that it is present and readable by the nginx user.

    0 讨论(0)
提交回复
热议问题