在CentOS上部署Laravel应用程序的SSL证书,通常需要以下几个步骤:
获取SSL证书:
安装Certbot:
sudo yum install epel-release
sudo yum install certbot python2-certbot-apache
获取SSL证书:
example.com
,运行以下命令:sudo certbot --apache -d example.com -d www.example.com
配置Laravel:
.env
文件中设置了正确的SSL相关配置:FORCE_SSL=true
SESSION_SECURE_COOKIE=true
CSRF_COOKIE_SECURE=true
配置Apache虚拟主机:
/etc/httpd/conf.d/example.com.conf
。<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/html/example.com/public
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
<Directory /var/www/html/example.com/public>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/example.com_error.log
CustomLog ${APACHE_LOG_DIR}/example.com_access.log combined
</VirtualHost>
重启Apache服务器:
sudo systemctl restart httpd
验证SSL配置:
https://example.com
,确保SSL证书正确安装并且网站可以通过HTTPS访问。自动续订证书:
sudo certbot renew --dry-run
通过以上步骤,你应该能够在CentOS上成功部署Laravel应用程序的SSL证书。