在CentOS上为PHP配置SSL,通常需要以下几个步骤:
对于Nginx:
sudo yum install epel-release
sudo yum install certbot python2-certbot-nginx
对于Apache:
sudo yum install epel-release
sudo yum install certbot python2-certbot-apache
对于Nginx:
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
对于Apache:
sudo certbot --apache -d yourdomain.com -d www.yourdomain.com
Certbot会自动创建一个新的Nginx或Apache配置文件,并启用SSL。它还会提示你重定向所有HTTP流量到HTTPS。
; 对于PHP-FPM(Nginx)
cgi.fix_pathinfo=0
open_basedir=/var/www/vhosts/yourdomain.com/httpdocs/:/tmp/
; 对于PHP模块(Apache)
cgi.fix_pathinfo=0
open_basedir=/var/www/vhosts/yourdomain.com/httpdocs/:/tmp/
确保将yourdomain.com
替换为你的实际域名。
sudo systemctl restart nginx
对于Apache:
sudo systemctl restart httpd
现在,你的PHP应用程序应该已经配置为使用SSL。请确保在访问你的网站时使用HTTPS协议。