php7+在nginx下的配置

好长时间没有更新,最近又想起来了,准备把这个当作学习日记用。
今天更新了服务器上的php版本到7,在百度找到的都是这样修改的,但没成:

1
2
3
4
5
6
7
8
location ~* \.php$ {
  root  html;
    fastcgi_index   index.php;
    fastcgi_pass    127.0.0.1:9000;
    include         fastcgi_params;
    fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
}

在digitalocean上找到的是这样的:

1
2
/etc/php/7.0/fpm/php.ini
cgi.fix_pathinfo=0
1
2
3
4
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

How To Install Linux, Nginx, MySQL, PHP (LEMP stack) in Ubuntu 16.04