nginx showing blank PHP pages

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

    The reason this problem occurs is because the fastcgi configurations in nginx do not function as required and in place or processing, they respond as html data. There are two possible ways in which you can configure your nginx to avoid this problem.

    1. Method 1:

          location ~ \.php$ {
                  fastcgi_split_path_info ^(.+\.php)(/.+)$;
                  # With php5-fpm:
                  fastcgi_pass unix:/run/php5-fpm.sock;
                  fastcgi_index index.php;
                  include fastcgi.conf;
          }
      
    2. Method 2:

      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;
      }
      

    Both the methods would work properly, you can go ahead and take any one of them. They almost perform the same operations with a very few difference.

提交回复
热议问题