Nginx PHP常见错误
1、PHP7.0-fpm.sock权限不足:
[crit] 3182#3182: *20 connect() to unix:/run/PHP/PHP7.0-fpm.sock Failed (13: Permission denied)
2、webroot路径不对:
[error] 3147#3147: *10 FastCGI sent in stderr: "Unable to open primary script: /etc/Nginx/html/index.PHP (No such file or directory)" while reading response header from upstream
PHP7安装
删除PHP7 apt-get autoremove --purge PHP7.0 PHP7.0-cli PHP7.0-common PHP7.0-fpm PHP7.0-gd PHP7.0-json PHP7.0-mbstring PHP7.0-mcrypt PHP7.0-mcrypt PHP7.0-MysqL PHP7.0-opcache PHP7.0-readline PHP7.0-sqlite3 安装PHP7 apt-get install PHP7.0 PHP7.0-cli PHP7.0-common PHP7.0-fpm PHP7.0-gd PHP7.0-json PHP7.0-mbstring PHP7.0-mcrypt PHP7.0-mcrypt PHP7.0-MysqL PHP7.0-opcache PHP7.0-readline PHP7.0-sqlite3
修改PHP.ini
vi /etc/PHP/7.0/fpm/PHP.ini
设置 cgi.fix_pathinfo = 0
修改www.conf
vi /etc/PHP/7.0/fpm/pool.d/www.conf
把listen.mode = 0660
改成 listen.mode = 0666
PHP7.0-fpm.sock
默认(0660)权限
$ls -al /run/PHP/PHP7.0-fpm.sock srw-rw---- 1 www-data www-data 0 Mar 22 13:17 PHP7.0-fpm.sock
PHP7.0-fpm.sock
(0666)权限
$ls -al /run/PHP/PHP7.0-fpm.sock srw-rw-rw- 1 www-data www-data 0 Mar 22 13:17 PHP7.0-fpm.sock
重启系统,这样 /run/PHP/PHP7.0-fpm.sock
文件才会根据0666
权限重新生成
Nginx PHP配置
location ~ \.PHP$ { root /your/web/root/document //必填,否则$document_root会是默认值/etc/Nginx/html fastcgi_pass unix:/run/PHP/PHP7.0-fpm.sock; fastcgi_index index.PHP; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }原文链接:https://www.f2er.com/ubuntu/349813.html