当前位置: 首页 > news >正文

在Ubuntu16.04系统为Apache服务器安装Let's Encrypt证书

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

By using Let's Encrypt for SSL, you will be able to encrypt transactions/data your site free of charge. The following tutorial will cover the entire process of installing the Let's Encrypt client to installing your SSL certificate on Ubuntu 16.04.

By the end of this Ubuntu guide you will be able to create Let's Encrypt SSL certificates and set them up on your Apache web server.

Step 1: Prerequisites

Let's Encrypt works with a client. You can create SSL certificates from your server, without manual intervention. Installation of the Let's Encrypt client software requires a LAMP stack. If you do not have one yet, please refer to the tutorial How to Install Apache, MySQL, and PHP on Ubuntu.

Once you have a working Apache web server on your Vultr SSD cloud server, it's time to install Let's Encrypt. Download the client to /opt/letsencrypt:

apt-get install git
git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt

Step 2: Generating a Let's Encrypt SSL certificate

Let's Encrypt works by verifying your domain through the client. Let's Encrypt will setup a 'hidden' web server to verify your domain points to your cloud server. Your SSL certificate will automatically be generated using the command:

./letsencrypt-auto --apache -d yourubuntuserver.example

Creating an SSL certificate for multiple domains is even easier: just add the -d switch as many times as you like.

./letsencrypt-auto --apache -d yourubuntuserver.example -d mysslcertificate.example
./letsencrypt-auto --apache -d yourubuntuserver.example -d mysslcertificate.example -d anotherwebsite.example

You can also generate a Let's Encrypt SSL certificate for your www. subdomains as follows:

./letsencrypt-auto --apache -d yourubuntuserver.example -d mysslcertificate.example -d anotherwebsite.example -d www.yourubuntuserver.example -d www.mysslcertificate.example -d www.anotherwebsite.example

Step 3: Forcing SSL

Once you have generated your SSL certificate(s), you will be able to force your websites to redirect to the SSL-protected version of your website. Add the following lines to the .htaccess files of your websites:

RewriteEngine On 
RewriteCond % 80 
RewriteRule ^(.*)$ https://yourubuntuserver.example/$1 [R,L]

If you'd rather redirect to the www. subdomain with Let's Encrypt:

RewriteEngine On 
RewriteCond % 80 
RewriteRule ^(.*)$ https://www.yourubuntuserver.example/$1 [R,L]

Step 4: Automatically renewing Let's Encrypt certificates

Let's Encrypt is a free certificate authority (CA). Because of this, certificates are not valid for longer than 90 days by default. Naturally, if you manage a lot of Let's Encrypt SSL certificates, it's very unhandy to renew these manually. Let's Encrypt provides a utility to automatically attempt to renew all certificates at a time you choose. Vultr recommends doing this at night, as this will not put heavy load on your cloud server.

The automation of this process is done using a cron job.

crontab -e

Append the following cronjob to the bottom of the file:

15 5 * * 5 /opt/letsencrypt/letsencrypt-auto renew >> /var/log/le-renew.log

The cron job we have just created will renew an SSL certificate every Friday at 5:15 A.M. by running the following script: /opt/letsencrypt/letsencrypt-auto renew.

Congratulations! Ubuntu 16.04 is now utilizing SSL certificates using Let's Encrypt completely free of charge. Certificates will be renewed by themselves. If you want to use more SSL certificates on a single Vultr cloud server, simply follow step #2 for every domain you want to protect with SSL.

Thanks for reading this Let's Encrypt guide, should you have any questions please do not hesitate to refer to the official Getting Started guide.

 

转载于:https://my.oschina.net/feanlau/blog/1647042

相关文章:

  • web_reg_find函数检查包含中文字符时报错的解决方案
  • springcloud config+jdbc(mysql)来实现配置管理
  • 从零开始的Spring Session(一)
  • vim 入坑指南
  • Spring技术内幕笔记(2):Spring MVC 与 Web
  • saltstack安装
  • 徒手撸UI之DatePicker
  • 常用链接收藏
  • TPYBoard获取MicroPython提示
  • Esper复杂事务处理一小时入门
  • 第204天:js---重载和多态
  • 【资源共享】5G AP分析
  • webpack4.0入门以及使用
  • Node总结
  • Unity中的平移 缩放 旋转
  • Docker: 容器互访的三种方式
  • JavaScript标准库系列——Math对象和Date对象(二)
  • JavaScript设计模式之工厂模式
  • LeetCode541. Reverse String II -- 按步长反转字符串
  • Quartz实现数据同步 | 从0开始构建SpringCloud微服务(3)
  • Spring Cloud Feign的两种使用姿势
  • Spring思维导图,让Spring不再难懂(mvc篇)
  • 马上搞懂 GeoJSON
  • 前端临床手札——文件上传
  • 微信小程序:实现悬浮返回和分享按钮
  • 异常机制详解
  • 中国人寿如何基于容器搭建金融PaaS云平台
  • elasticsearch-head插件安装
  • 阿里云ACE认证之理解CDN技术
  • ​LeetCode解法汇总1410. HTML 实体解析器
  • ​如何使用ArcGIS Pro制作渐变河流效果
  • !! 2.对十份论文和报告中的关于OpenCV和Android NDK开发的总结
  • #define,static,const,三种常量的区别
  • #pragma once
  • #Ubuntu(修改root信息)
  • #微信小程序:微信小程序常见的配置传旨
  • #预处理和函数的对比以及条件编译
  • (09)Hive——CTE 公共表达式
  • (4)(4.6) Triducer
  • (C语言)二分查找 超详细
  • (zhuan) 一些RL的文献(及笔记)
  • (附源码)ssm高校志愿者服务系统 毕业设计 011648
  • (三) prometheus + grafana + alertmanager 配置Redis监控
  • (十二)devops持续集成开发——jenkins的全局工具配置之sonar qube环境安装及配置
  • (转载)hibernate缓存
  • (转载)虚函数剖析
  • .bat文件调用java类的main方法
  • .net 写了一个支持重试、熔断和超时策略的 HttpClient 实例池
  • .NET/C# 如何获取当前进程的 CPU 和内存占用?如何获取全局 CPU 和内存占用?
  • .NET/C# 使用 ConditionalWeakTable 附加字段(CLR 版本的附加属性,也可用用来当作弱引用字典 WeakDictionary)
  • .NET企业级应用架构设计系列之开场白
  • .vue文件怎么使用_我在项目中是这样配置Vue的
  • @require_PUTNameError: name ‘require_PUT‘ is not defined 解决方法
  • [AIGC] Nacos:一个简单 yet powerful 的配置中心和服务注册中心
  • [C/C++]数据结构 循环队列