在Ubuntu系统下为PHP-FPM配置SSL,需要遵循以下步骤:
sudo apt update
sudo apt install certbot python3-certbot-nginx
yourdomain.com替换为你的实际域名。sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
Certbot会自动创建一个新的Nginx配置文件,用于处理HTTPS请求。同时,它会要求你输入电子邮件地址以接收有关证书的信息,并设置自动续订。
/etc/php/7.x/fpm/pool.d/www.conf(其中7.x是你的PHP版本)。找到以下行:;listen = 127.0.0.1:9000
取消注释(删除行首的分号),并确保监听地址设置为127.0.0.1。这样可以确保只有本地连接可以访问PHP-FPM,提高安全性。
listen = 127.0.0.1:9000
sudo systemctl restart nginx
sudo systemctl restart php7.x-fpm
(请将7.x替换为你的PHP版本)
完成以上步骤后,你的Ubuntu系统下的PHP-FPM应该已经成功配置了SSL。