在Ubuntu系统中配置PHP时,可能会遇到一些常见问题。以下是一些常见错误及其解决方法:
connect() failed (111: Connection refused)
sudo systemctl status php7.0-fpm
。sudo systemctl start php7.0-fpm
。/etc/php/7.0/fpm/pool.d/www.conf
),确保listen
参数配置正确。默认情况下,它可能是unix:/run/php/php7.0-fpm.sock
。sudo systemctl restart nginx
和sudo systemctl restart php7.0-fpm
。connect() to unix:/run/php/php7.0-fpm.sock failed (13: Permission denied)
/etc/php/7.0/fpm/pool.d/www.conf
),将listen.owner
和listen.group
设置为www-data
。listen.mode
设置为0666
:listen.mode = 0666
。sudo systemctl restart php7.0-fpm
。FastCGI sent in stderr: "Unable to open primary script: /etc/nginx/html/index.php (No such file or directory)"
root
指令指向正确的项目文档根目录。location ~ \.php$
块,确保fastcgi_pass
指向正确的php-fpm监听地址和端口。nginx -t
命令检查Nginx配置文件的语法。server_name
、root
、fastcgi_pass
等。chown
和chmod
命令正确设置文件权限。以上是Ubuntu PHP配置中常见的一些错误及其解决方法。如果问题仍然存在,建议查看相关的日志文件(如Nginx和php-fpm的日志)以获取更多详细的错误信息,并根据具体情况进行进一步的排查和解决。