M22 Centos6上编译安装httpd2.4并实现HTTPS浏览

随着网络技术的发展,人们对信息安全越来越重视,传统的http浏览互联网的方式由于未经加密,其安全性广为人们诟病,https协议作为加密的互联网解决方案解决了这一问题。下面我就简要说明下如何实现通过https发布web页面的。

 

实验目的:

模拟Centos6上安装httpd2.4,并实现https加密访问主页

实验器材:

Centos6.8虚拟机

实验步骤:

1 生成自签名证书

2 下载并编译安装httpd2.4及其相关组件

3 安装ssl模块并修改httpd配置文件

实验过程:

1 生成自签名证书

https协议是基于SSL协议的,在使用https协议之前首先要获得SSLCA证书,在生产情况下此证书需要向CA证书颁发机构购买,而在实验环境下可以使用openssl工具生成自签名证书。

1)  创建根CA证书

CA证书是CA认证机构必须有的,在本实验需要先创建此证书才能为自建网站颁发证书。

cd /etc/pki/CA/ #进入CA目录
touch index.txt #创建index.txt文件,此文件记录了根CA颁发的所有证书
echo 01 > serial #添加起始计数
(umask 077;openssl genrsa -out private/cakey.pem 4096)#生成私钥
openssl req -new -x509 -key private/cakey.pem -out cacert.pem -days 3650 #生成根证书

2)  创建网站CA申请

(umask 066;openssl genrsa -out private/client.key 1024) #生成私钥
openssl req -new -key private/client.key -days 356 -out client.csr #通过私钥生成证书申请文件

3)  申请网站CA证书

openssl ca -in client.csr -out certs/client.cer

至此,网站的CA证书创建完成,证书文件client.cer与私钥client.key备用

2 下载并编译安装httpd2.4及其相关组件

         安装httpd2.4需要的组件包括apr-1.5.0apr-util-1.5.3httpd-2.4.10pcre及openssl-devel

1)  下载编译安装apr-1.5.0

wget http://archive.apache.org/dist/apr/apr-1.5.0.tar.gz
tar xf apr-1.5.0.tar.gz 
cd apr-1.5.0
./configure --prefix=/usr/local/apr
make && make install

2)下载编译安装apr-util-1.5.3

wget http://archive.apache.org/dist/apr/apr-util-1.5.3.tar.gz
tar xf apr-util-1.5.3.tar.gz
cd apr-util-1.5.3
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
make && make install

4)  安装pcre及openssl-devel

yum install -y pcre-devel
yum install –y openssl-devel

5)  下载编译安装httpd-2.4.10

wget http://archive.apache.org/dist/httpd/httpd-2.4.10.tar.gz
tar xf httpd-2.4.10.tar.gz
cd httpd-2.4.10
./configure --prefix=/usr/local/apache24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpm-shared=all --with-mpm=prefork
make && make install

3 安装ssl模块并修改httpd配置文件

1) 安装ssl模块

yum install mod_ssl -y
httpd -M | grep ssl #查看模块安装情况

2)修改配置文件/usr/local/apache24/conf/httpd.conf

LoadModule ssl_module modules/mod_ssl.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
Include conf/extra/httpd-ssl.conf

3)修改配置文件/usr/local/apach24/conf/extra/httpd-ssl.conf

DocumentRoot "/var/www/html"
ServerName www.magedu.com
SSLCertificateFile /usr/local/apach24/ssl/client.csr
SSLCertificateKeyFile /usr/local/apach24/ssl/client.key

4)修改域名

ServerName www.magedu.com:443

重启服务

/usr/local/apache24/bin/apachectl restart

原创文章,作者:realmaster,如若转载,请注明出处:http://www.178linux.com/73814

(0)
realmasterrealmaster
上一篇 2017-04-20
下一篇 2017-04-20

相关推荐

  • 网络第21期第七周作业

    1、创建一个10G分区,并格式为ext4文件系统;    (1) 要求其block大小为2048, 预留空间百分比为2, 卷标为MYDATA, 默认挂载属性包含acl; [root@localhost ~]# fdisk /dev/sdb WARNING: DOS-compatible m…

    Linux干货 2016-10-09
  • 面授20期2班-08月4号课堂与课后习题

    课堂习题 1、显示/etc/init.d/functions文件中所有的单词及出现的次数 cat /etc/init.d/functions | tr -sc "[:alpha:]" '\n' |sort | uniq -c 2、找出ifconfig命令结果中本机的所有IPv4地址 centos6:ifconfig | h…

    Linux干货 2016-08-08
  • 马哥教育网络班22期+第2周课程练习

    1、Linux上文件/目录相关命令有哪些? 1)目录管理类命令:mkdir、rmdir (1)mkdir:make directorise 创建文件夹  使用格式:      mkdir [OPTION]… DIRECTORY…    &nb…

    Linux干货 2016-09-08
  • 马哥教育网络班21期+第2周课程练习

    一、Linux文件管理类命令     1、文件的复制、移动和删除        A、cp  文件的复制          cp命令的用法:    &n…

    Linux干货 2016-06-26
  • 20160804课堂练习

    grep正则表达式课堂练习 1、找出ifconfig命令结果中本机的所有IPv4地址 # ifconfig | head -2 | cut -dt -f2 | cut -dn -f1 | tail -1 2、  查出分区空间使用率的最大百分比值 # df | cut -c56-58 | sort -n | tail -1 3、  查出用户…

    Linux干货 2016-08-05
  • bash编程尾声

    数组 变量:存储单个元素的内存空间 数组:存储多个元素的连续的内存空间,相当于多个变量的集合。 数组名和索引     索引:编号从0开始,属于数值索引     注意:索引可支持使用自定义的格式,而不仅是数值格式,即为关联索引, bash4.0版本之后开始支持。  &nb…

    Linux干货 2016-08-25