ubuntu14.04安装 Apache2 并配置https
一、安装 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的更多相关文章
- Ubuntu14.04安装JDK与配置环境变量
工具/原料 Ubuntu14.04系统 方法/步骤 先从Oracle官网下载JDK.先选择同意按钮,然后根据自己的系统下载相应版本.我的系统是Ubuntu14.04 64位的,所以我下载 2 创建 ...
- Ubuntu14.04安装pip及配置
安装pip: wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate sudo python get-pip.py 建立软连接 ...
- ubuntu14.04安装rabbitmq
ubuntu14.04安装rabbitmq及配置 1.修改/etc/apt/sources.list文件 命令:vi /etc/apt/sources.list 在最后一行加上:deb http: ...
- Ubuntu14.04安装配置web/ftp/tftp/dns服务器
目录: 1.安装ftp服务器vsftpd --基于tcp,需要帐号密码 2.安装tftp服务器tftpd-hpa,tftp-hpa --udp 3.web服务器--使用Apache2+Mysql+PH ...
- Ubuntu14.04安装配置ndnSIM
Ubuntu14.04安装配置ndnSIM 预环境 Ubuntu14.04官方系统 请先使用sudo apt-get update更新一下源列表 安装步骤 安装boost-lib sudo apt-g ...
- Ubuntu14.04 安装配置Opencv3.0和Python2.7
http://blog.csdn.NET/u010381648/article/details/49452023 Install OpenCV 3.0 and Python 2.7+ on Ubunt ...
- Ubuntu14.04安装intel集显驱动
Ubuntu14.04安装intel集显驱动 标签(空格分隔): ubuntu linux 驱动安装 1.查看本机显卡型号 使用lspci命令来获取PCI接口硬件信息 o@o-pc:~$ lspci ...
- Ubuntu14.04安装中文输入法以及解决Gedit中文乱码问题
1 设置中文显示环境 1. 打开System Settings 2. 打开Personal-> Language Support. 会弹出如下对话框,提示你“语言支持没安装完整”. 点击“Rem ...
- Ubuntu14.04 安装QQ国际版wine-qqintl
Ubuntu14.04安装qq国际版方式: 首先下载,链接为: https://pan.baidu.com/s/1boPitVD 密码:jp1j 也可去Ubuntu中文的Kylin(优麒麟)官网下载 ...
随机推荐
- Pycharm激活方法步骤
Pycharm激活步骤 第一步:找到hosts文件 先按下键盘的win + r ,然后复制c:\windows\system32\drivers\etc粘贴到对话框回车打开文件管理器 第二步:修改ho ...
- [macOS] Cannot find libz when install php56
After upgraded to 10.12 and xcode8.2, when updating php with homebrew, i got these errors: /usr/loca ...
- python多线程学习三
本文希望达到的目标: 1.服务器端与线程池 (实例demo) 2.并发插入db与线程池(实例demo) 3.线程池使用说明 4.线程池源码解析 一.基于socket的服务器与线程池连接. 1.在i7 ...
- 3D打印机如何添加自动调平功能
原理说明 Kossel/Rostock等Delta(并联/三角洲)类型的机器,可以参考:http://learn.makerlab.me/guides/11 3d打印打印时最重要的是第一层的效果,如果 ...
- Maven 的41种骨架功能介绍(转)
Maven 的41种骨架: ...>mvn archetype:generate 1: internal -> appfuse-basic-jsf (创建一个基于Hibernate,Spr ...
- javascript:void(0) 和 href="#"的区别
<a href="javascript:void(0);">点击 <a href="#">点击 如果使用下面一种方式,会跳到网页顶部. ...
- flutter 常用插件
audio_recorder: any #录音.播放 flutter_sound: ^1.1.5#录音 dropdown_menu: ^1.1.0#下拉菜单 simple_permissions:#权 ...
- pytesseract使用的坑
今天学了下python的OCR识别,其中遇到好多坑,下面就一一阐述是如何破解的,本人用的是Windows 64位,IDE是VS2017. pip版本过低. 首先安装pytesseract这个库,pip ...
- Unable to execute 'doFinal' with cipher instance
今天项目启动后登录项目,突然爆出Unable to execute 'doFinal' with cipher instance错误.清除cookie登录测试,又不报错了,以前也见过类似问题,因为不影 ...
- 常用验证正则:用户名、密码、邮箱、手机号、身份证(PHP和JavaScript)
日常开发中,常常会用到一些简单常用的正则表达式,用于判断一些常见的情况 下边,就列出五种(验证用户名,密码强度,邮箱格式,手机号格式和身份证格式)常见的情况 分成PHP版本和JavaScript两个版 ...