dongqiaogouk86049 2018-07-12 09:08
浏览 156

localhost上的示例PHP页面显示一个空白页面

I follow this guide to setup a sample WordPress site on my Linux machine. The packages are changed to the newer php7.2-gd, php7.2-curl, and libssh2-php. My /etc/nginx/sites-available/davewordpress file is as follow:

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

    root /var/www/wordpress;
    index index.php index.html index.htm;
    server_name localhost;

    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/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }
}

After creating the davewordpress link in /etc/nginx/sites-enabled and restarting nginx and php7.2-fpm, my localhost gives a blank page. What have I done wrong?

  • 写回答

1条回答 默认 最新

  • doukong1897 2018-07-13 06:06
    关注

    OK, I run into this link while searching for the solution, and it really helps by pointing to the location ~ \.php$ block. I comment out two lines and have it working. That blocks now looks like this:

        location ~ \.php$ {     
        #try_files $uri =404;
        include snippets/fastcgi-php.conf;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        #fastcgi_index index.php;
        include fastcgi_params;
        }
    

    Using sudo nginx -t, the first line reports this problem:

    "try_files" directive is duplicate in /etc/nginx/snippets/fastcgi-php.conf:5
    

    The second line reports this problem:

    "fastcgi_index" directive is duplicate in /etc/nginx/sites-enabled/u1804wordpress:27
    

    Glad to finally figure it out. I understand the first error. However, can anybody explain to me the second one?

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题