1. enable the module ssl by:

sudo a2enmod ssl

2.after you have enabled module ssl , you will have to restart the web server for the change to be recognized:

sudo service apache2 restart

now ,the web server is able to handle ssl

3. create a directory to place the certificate files that will be maked:

sudo mkdir /etc/apache2/ssl

4.create our key and certificate

sudo openssl req -x509 -nodes -days  -newkey rsa: -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

let's go over what this means :

  • openssl: This is the basic command line tool provided by OpenSSL to create and manage certificates, keys, signing requests, etc.
  • req: This specifies a subcommand for X.509 certificate signing request (CSR) management. X.509 is a public key infrastructure standard that SSL adheres to for its key and certificate managment. Since we are wanting to create a new X.509 certificate, this is what we want.
  • -x509: This option specifies that we want to make a self-signed certificate file instead of generating a certificate request.
  • -nodes: This option tells OpenSSL that we do not wish to secure our key file with a passphrase. Having a password protected key file would get in the way of Apache starting automatically as we would have to enter the password every time the service restarts.
  • -days 365: This specifies that the certificate we are creating will be valid for one year.
  • -newkey rsa:2048: This option will create the certificate request and a new private key at the same time. This is necessary since we didn't create a private key in advance. The rsa:2048 tells OpenSSL to generate an RSA key that is 2048 bits long.
  • -keyout: This parameter names the output file for the private key file that is being created.
  • -out: This option names the output file for the certificate that we are generating.

  when you hit "ENTER" , you will be asked some questions , answer it ....

  then, the key and certificate will be created and placed in the /etc/apache2/ssl directory

  now ! ! ! ! ! ! ! ! ! !  ! we will configure apache to use ssl

  open the file with your editor

  

sudo vi /etc/apache2/site-available/default-ssl.conf

what we should modify is the content with red

<IfModule mod_ssl.c>
<VirtualHost _default_:>
ServerAdmin admin@example.com
ServerName your_domain.com
ServerAlias www.your_domain.com
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
</VirtualHost>
</IfModule>

save and exit the file when you finished

then we enable it by:

sudo a2ensite default-ssl.conf

restart our web server

sudo service apache2 restart

now you can test it in your explorer

https://server_domain_name_or_IP:443

ubuntu apache2 https的更多相关文章

  1. ubuntu apache2 ssl配置

    Ubuntu下HTTPS配置非常简单,对大部分用户而言,使用普通的自签名证书,只需按照步骤进行就可以了,无需了解密钥.证书的更多知识,更深的背景 知识还有RSA算法.DES算法.X509规范.CA机构 ...

  2. Ubuntu下HTTPS配置

    Ubuntu下HTTPS配置非常简单,对大部分用户而言,使用普通的自签名证书,只需按照步骤进行就可以了,无需了解密钥.证书的更多知识,更深的背景知识还有RSA算法.DES算法.X509规范.CA机构. ...

  3. 转 - ubuntu apache2下目录结构

    ubuntu apache2下目录结构 原文:http://blog.csdn.net/jibcy/article/details/8060651 在Windows下,Apache的配置文件通常只有一 ...

  4. ubuntu apache2配置详解(含虚拟主机配置方法)

    ubuntu apache2配置详解(含虚拟主机配置方法) 在Windows下,Apache的配置文件通常只有一个,就是httpd.conf.但我在Ubuntu Linux上用apt-get inst ...

  5. ubuntu apache2下目录结构以及重写规则

    ubuntu apache2下目录结构 在Windows下,Apache的配置文件通常只有一个,就是httpd.conf.但我在Ubuntu Linux上用apt-get install apache ...

  6. ubuntu apache2 虚拟主机服务

    ubuntu apache2 虚拟主机服务 本次配置的是一个 ip 对应多个 虚拟主机 1:先检查 ubuntu server 是否已经安装了 apache2 web服务: apache2 -v 看到 ...

  7. 虚拟主机的搭建(ubuntu+apache2)

    搭建环境:windows+VMware(Ubuntu)+apache2.(同一IP,不同域名) 1:在VMware的虚拟机Ubuntu下安装apache2(怎么安装百度一下就能找到): 2: apac ...

  8. ubuntu+apache2设置访问、重定向到https

    环境:ubunt14裸机,apache2,php5 条件:证书(部分商家买域名送一年),域名,为了方便均在root用户下进行的 web目录:/var/www/test 证书目录(自建):/etc/ap ...

  9. ubuntu apache2 wsgi 部署django

    入题 分为如下几步 1.安装python 2.安装django 3.安装wsgi,如有问题请参照上一篇 ubuntu 编译安装 mod_wsgi 4.与apache集成这里主要讲这部分 环境apach ...

随机推荐

  1. 搭建DNS服务器-bind

    1. 安装 yum install -y bind-chroot yum install -y bind-utils service named-chroot start    2. 修改配置 增加一 ...

  2. Excel对重复数据分组,求出不同的数据(office 2013)

    第一步: 第二步: 第三步:

  3. 报错之-Cannot set property 'onclick' of null

    当js文件放在head里面时,如果绑定了onclick或者onmouseover事件,就会出现如下图类似的错误,是因为浏览器的加载你写的html文档的顺序是从上往下,加载完按钮节点才执行的js,所以当 ...

  4. ceph学习之CRUSH

    CRUSH的全称是Controlled Replication Under Scalable Hashing,是ceph数据存储的分布式选择算法,也是ceph存储引擎的核心.在之前的博客里介绍过,ce ...

  5. ssh的两种连接方法(包括无密码访问)

    一.正常连接方法:ssh root@10.0.0.20 二.无密码连接方法(有两台机器:此处我把被连接的称为服务器,另一台则称为客户端): 1.先在服务器添加目录 .ssh: mkdir  .ssh ...

  6. 通俗地讲,Netty 能做什么?

    https://www.zhihu.com/question/24322387/answer/78947405 作者:郭无心链接:https://www.zhihu.com/question/2432 ...

  7. 8、泛型程序设计与c++标准模板库1、泛型程序设计的概念和术语

    有效地利用已有的成果,将经典的.优秀的算法标准化.模块化,从而提高软件的生产率,是软件产业化的需求,为了实现这一需求,不仅需要面向对象设计思想,而且需要泛型程序设计思想. c++语言提供的标准模板库( ...

  8. 数据库 连接(join)

    转自http://www.cnblogs.com/caozengling/p/5318696.html 数据库中飞内连接,自然连接,外连接 数据库中的连接join氛围内连接,自然连接,外连接,外连接又 ...

  9. Python pandas检查数据中是否有NaN的几种方法

    Python pandas: check if any value is NaN in DataFrame # 查看每一列是否有NaN: df.isnull().any(axis=0) # 查看每一行 ...

  10. ProtoBuf练习(三)

    任意类型 protobuf语言的任意字段类型相当于Boost库的boost::any类型数据,google.protobuf.Any是对protobuf语言的message进行封装,所以需要使用mes ...