一、安装 Apache2

  sudo apt-get update

  sudo apt-get install apache2

  安装完apache2,默认根目录在/var/www/html 下,点击其下的html 文件,可打开 Apache2的默认页面。

输入 http://localhost/index.html, 也可以通过http://localhost/测试一下是否好用。

如下图所示,则说明安装成功。

二、重启电脑
在安装 apache2后,需要重启才能使用a2enmod 等命令。为下一步准备。

sudo reboot 

三、 配置Apache https

  假设 配置 https 所需要的证书 apache.crt apache.key 已经制作完毕,如何制作请见我的另外一篇随笔。

  1、开启SSL模块  

sudo a2enmod ssl

  2、启用SSL站点  

sudo a2ensite default-ssl

  3、加入监听端口 443  

sudo gedit /etc/apache2/ports.conf

Listen 80 443 // 只能这样写 若 Listen 80 Listen 443  分开则出错

#编辑Apache端口配置,加入443端口(HTTPS采用的443端口传输数据)

  4、配置SSL证书
在ServerAdmin下另起一行加上ServerName 你的域名:443,
并找到SSLEngine,SSLCertificateFile,SSLCertificateKeyFile并修改成如下:

sudo gedit /etc/apache2/sites-available/default-ssl.conf

<IfModule mod_ssl.c>

<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
ServerName 127.0.1.1:443
DocumentRoot /var/www/html

SSLEngine on

SSLCertificateFile /etc/apache2/ssl/apache.crt

SSLCertificateKeyFile /etc/apache2/ssl/apache.key

  5、配置 HTTPS 强制跳转

sudo gedit  /etc/apache2/sites-available/-default.conf

在<VirtualHost *:80></VirtualHost>标签内随便一个地方加入以下三行,如在最后加入

<VirtualHost *:80>
...
...
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [L,R]
</VirtualHost>

  6、使配置生效
启动 rewrite mod

sudo a2enmod rewrite

重启 apache

sudo /etc/init.d/apache2 restart

配置结束。不出意外配置应该已经生效。

  7、输入 https://localhost/index.html 测试Apache https 是否成功。

 apache.

ubuntu14.04安装 Apache2 并配置https的更多相关文章

  1. Ubuntu14.04安装JDK与配置环境变量

    工具/原料 Ubuntu14.04系统 方法/步骤   先从Oracle官网下载JDK.先选择同意按钮,然后根据自己的系统下载相应版本.我的系统是Ubuntu14.04 64位的,所以我下载 2 创建 ...

  2. Ubuntu14.04安装pip及配置

    安装pip: wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate sudo python get-pip.py 建立软连接 ...

  3. ubuntu14.04安装rabbitmq

      ubuntu14.04安装rabbitmq及配置 1.修改/etc/apt/sources.list文件 命令:vi /etc/apt/sources.list 在最后一行加上:deb http: ...

  4. Ubuntu14.04安装配置web/ftp/tftp/dns服务器

    目录: 1.安装ftp服务器vsftpd --基于tcp,需要帐号密码 2.安装tftp服务器tftpd-hpa,tftp-hpa --udp 3.web服务器--使用Apache2+Mysql+PH ...

  5. Ubuntu14.04安装配置ndnSIM

    Ubuntu14.04安装配置ndnSIM 预环境 Ubuntu14.04官方系统 请先使用sudo apt-get update更新一下源列表 安装步骤 安装boost-lib sudo apt-g ...

  6. Ubuntu14.04 安装配置Opencv3.0和Python2.7

    http://blog.csdn.NET/u010381648/article/details/49452023 Install OpenCV 3.0 and Python 2.7+ on Ubunt ...

  7. Ubuntu14.04安装intel集显驱动

    Ubuntu14.04安装intel集显驱动 标签(空格分隔): ubuntu linux 驱动安装 1.查看本机显卡型号 使用lspci命令来获取PCI接口硬件信息 o@o-pc:~$ lspci ...

  8. Ubuntu14.04安装中文输入法以及解决Gedit中文乱码问题

    1 设置中文显示环境 1. 打开System Settings 2. 打开Personal-> Language Support. 会弹出如下对话框,提示你“语言支持没安装完整”. 点击“Rem ...

  9. Ubuntu14.04 安装QQ国际版wine-qqintl

    Ubuntu14.04安装qq国际版方式: 首先下载,链接为:  https://pan.baidu.com/s/1boPitVD 密码:jp1j 也可去Ubuntu中文的Kylin(优麒麟)官网下载 ...

随机推荐

  1. 【Spark-core学习之七】 Spark广播变量、累加器

    环境 虚拟机:VMware 10 Linux版本:CentOS-6.5-x86_64 客户端:Xshell4 FTP:Xftp4 jdk1.8 scala-2.10.4(依赖jdk1.8) spark ...

  2. angular和vue还有jquery的区别

    angularjs简单介绍和特点 首先angular是一个mvc框架, 使用mvc解耦, 采用model, controller以及view的方式去组织代码, 会将一个html页面分成若干个模块, 每 ...

  3. 在java中,将String类型字符串s赋值为null后,将字符串与其他字符串拼接后得到结果出现了null字符串与其他字符连接的样式

    String s = null; s  += "hello"; System.out.println(s); 结果为:nullhello 原因: 先应用String.valueOf ...

  4. write RE validation

    正则表达式,又称规则表达式.(英语:Regular Expression,在代码中常简写为regex.regexp或RE),计算机科学的一个概念.正则表达式通常被用来检索.替换那些符合某个模式(规则) ...

  5. FAT32文件系统学习(上)

    2011-06-02 22:30:48 目的:需要编写SD读图片的底层驱动程序.所以要了解一个SD卡常用文件系统基本概念.累计学习用时2.5小时. 一,FAT32的保留区 1,引导扇区 :引导扇区是F ...

  6. GoldenGate实时投递数据到大数据平台(7)– Apache Hbase

    Apache Hbase安装及运行 安装hbase1.4,确保在这之前hadoop是正常运行的.设置相应的环境变量, export HADOOP_HOME=/u01/hadoop export HBA ...

  7. Got error -1 when reading table

    环境:Percona Server for MySQL 5.5.18 模拟三个Terminal,实现当引用锁定表的查询被杀死时,错误日志中出现的Got error -1 when reading ta ...

  8. YII1 增、删、改、查数据库操作

    增 //注意插入的时候 是用的new Post $objectPost = new Post; $objectPost->username = $username; $objectPost-&g ...

  9. 自制操作系统Antz(6)——内核初步,引入c语言

    Antz系统更新地址: https://www.cnblogs.com/LexMoon/category/1262287.html Linux内核源码分析地址:https://www.cnblogs. ...

  10. STATS 326 Applied Time Series

    STATS 326Applied Time SeriesASSIGNMENT THREEDue: 2 May 2019, 11.00 am(Worth 6% of your final grade)H ...