cert / letsencrypt-bundle
为您的 Symfony 应用程序提供免费的 SSL/HTTPS,并自动续订和证书监控
dev-master / 1.0.x-dev
2016-11-11 11:16 UTC
Requires
- php: >=5.4
- symfony/console: ~2.3|~3.0
- symfony/framework-bundle: ~2.3|~3.0
Requires (Dev)
- phpunit/phpunit: ^4.8.21
- swiftmailer/swiftmailer: ~4.3|~5
- symfony/yaml: ~2.3|~3.0
This package is not auto-updated.
Last update: 2024-09-23 14:08:57 UTC
README
此扩展包目前处于开发阶段。
CertLetsEncryptBundle 提供了一个简单但可完全配置的 Symfony 命令,可以自动续订您网站的 HTTPS 证书。在 Symfony 应用程序中使用 HTTPS 从来没有这么简单过!
CertLetsEncryptBundle 还能在证书续订失败时提醒您(例如通过邮件)。
安装
使用 Composer
composer require cert/letsencrypt-bundle:1.0.x-dev
在您的 AppKernel
中启用此扩展包
<?php class AppKernel extends Kernel { public function registerBundles() { $bundles = [ // ... new Cert\LetsEncryptBundle\CertLetsEncryptBundle(), // ... ]; // ... } // ... }
使用方法
简单配置扩展包以符合您的需求
# app/config/config.yml cert_lets_encrypt: # Path to the Let's Encrypt executable (usually your letsencrypt-auto binary) letsencrypt: ~ # Required # Recovery email used by Let's Encrypt for registration and recovery contact recovery_email: ~ # Required # Logs directory (if not specified, the application logs directory will be used) logs_directory: null # Domains to get certificates for (this application should response to these domains) domains: [] # Required # Monitorings to be warned if an error occured during the renewal of one of your certificates monitoring: # Email monitoring email: enabled: false # If an error occured, emails where a warning should be sent to: []
对于经典设置,您可以将 Let's Encrypt 存储库克隆到您的 bin
目录中(cd /path/to/your/project/bin && git clone https://github.com/letsencrypt/letsencrypt
),并将其用作脚本。您可能还希望如果发生错误,通过邮件提醒您。
# app/config/config.yml cert_lets_encrypt: letsencrypt: "%kernel.root_dir%/../bin/letsencrypt/letsencrypt-auto" recovery_email: "youremail@example.org" domains: - example1.org - www.example1.org - example2.org - www.example2.org monitoring: email: enabled: true to: [ "youremail@example.org" ]
您可以通过运行以下命令来测试您的参数是否正常工作:
$ sudo -H php app/console cert:letsencrypt
# Or for Symfony 3
$ sudo -H php bin/console cert:letsencrypt
您需要以 root 用户运行此脚本,因为 Let's Encrypt 需要 root 权限。
您可以通过运行以下命令来检查在发生错误时是否得到了适当的提醒:
$ sudo -H php app/console cert:letsencrypt --emulate-failure
# Or for Symfony 3
$ sudo -H php bin/console cert:letsencrypt --emulate-failure
如果一切如预期工作,您可以配置一个 CRON 任务,每隔 2 天运行此命令一次,例如。
$ sudo su
$ crontab -e
0 0 */2 * * sudo -H php /path/to/your/project/app/console cert:letsencrypt
# Or for Symfony 3
0 0 */2 * * sudo -H php /path/to/your/project/bin/console cert:letsencrypt