首先先检查编译环境和安装环境

  1. yum -y install gcc gcc-c++ zlib zlib-devel | 安装 gcc编译环境 zlib 环境。
  2. yum -y install openssl-devel | 安装 openssl 证书服务。
  3. yum -y install update openssl | 升级ssl证书服务。

安装apr服务

  1. 安装包我已经放入到linux 操作系统中
  2. tar -xvf apr-1.5.2.tar.bz2 -C /usr/local/src/

(1)将arp等安装包通过 rz -y 命令上传到apache2目录下
image.png
(2)执行解压apr命令image.png
解压完成后目录效果
image.png
(3)接下来进行编译 make

  1. make -j 5 | 开启多线程编译
  2. make install | 编译后安装
  3. ./configure --prefix=/opt/apache/apr && make -j5 && make install | 进行配置文件的编译,编译到 /opt/apache/apr目录下。

(3)执行命令进行编译 | 执行完命令后等到相关组件
image.png
(4)安装apr-util模块

  1. tar -xvf apr-util-1.5.4.tar.bz2 -C /usr/local/src/
  2. make -j 5 | 开启多线程编译
  3. make install | 编译后安装
  4. ./configure --prefix=/opt/apache/apr-util --with-apr=/opt/apache/apr && make -j5 && make install | 进行配置文件的编译,编译到 /opt/apache/apr目录下。
  5. --with-apr 的意思是:因为apr-utilapr的组件包,所以--with-apr是将apr-util关联到 apr组件中去。

(4)执行./configure命令
image.png

三、prce安装和部署

  1. tar -xvf pcre-8.37.tar.bz2 -C /usr/local/src/
  2. make -j 5 | 开启多线程编译
  3. make install | 编译后安装
  4. ./configure --prefix=/opt/apache/pcre && make -j5 && make install

(4)执行命令 ./configure —prefix=/opt/apache/pcre && make -j5 && make install
image.png
四、Apache下载和安装部署

  1. tar -xvf httpd-2.4.17.tar.bz2 -C /usr/local/src/ | http解压到/src/的目录下。
  2. cd /usr/local/src/httpd-2.4.17
  3. ./configure --prefix=/opt/apache/httpd --enable-rewrite --enable-so --enable-headers --enable-expires --enable-modules=most --enable-deflate --enable-rewrite=shared --enable-deflate=shared --enable-expires=shared --enable-static-support --with-mpm=worker --with-apr=/opt/apache/apr --with-apr-util=/opt/apache/apr-util --with-pcre=/opt/apache/pcre --enable-ssl --enable-ssl-staticlib-deps && make -j5 && make install
  4. cd /opt/apache/httpd/bin
  5. ./apachectl -k start | stop

(3)执行完参数后,查看http服务。
image.png
执行apache启动服务。
cd /opt/apache/httpd/bin
./apachectl -k start | stop
image.png
查看80 端口 lsof -i:80
image.png

Apache配置HTTPS服务

  1. 创建证书:
  2. 1,openssl genrsa -des3 -out upwen.key 1024
  3. 私钥去除密码:
  4. 2cp upwen.key upwen.key.org
  5. openssl rsa -in upwen.key.org -out upwen.key
  6. 创建证书请求文件(CSR
  7. 3.openssl req -new -key upwen.key -out upwen.csr
  8. 生成证书(certificate
  9. 4.openssl x509 -req -days 100 -in upwen.csr -signkey upwen.key -out upwen.crt

1,openssl genrsa -des3 -out upwen.key 1024 | 密码 redhat
image.png
生成一个upwen.key
2.私钥去除密码:
cp upwen-server.key upwen-server.key.org
openssl rsa -in upwen-server.key.org -out upwen-server.key
image.png
3.创建证书请求文件 csr
opnssl req -new -key upwen.key -out upwen.csr
image.png
使用upwen.key 创建 upwen.csr证书请求文件。
4.生成证书文件
openssl x509 -req -days 100 -in upwen.csr -signkey upwen.key -out upwen.crt
image.png
证书生成完毕,接下来在http中放入证书文件。

在httpd.conf中修改如下内容
编辑httpd.conf文件找到 # LoadModule ssl_module/mod_ssl.so 和 # Includeconf/extra/httpd-ssl.conf 去掉前面的#号

  1. # LoadModule ssl_module/mod_ssl.so
  2. Includeconf/extra/httpd-ssl.conf

1.# LoadModule ssl_module/mod_ssl.so
image.png
2.# Includeconf/extra/httpd-ssl.conf
image.png
3.cd /opt/apache/httpd/conf/extra/http-ssl.conf
配置ssl证书的路径
image.png
配置key的路径
image.png
执行重启apache操作
image.png
查看80:443端口是否正常启动
image.png
进入web测试 https://192.168.96.137
image.png
https成功配置完成。

Apache安全配置

  1. 伪装apache版本号
  2. ServerTokens Prod
  3. ServerSignature Off
  4. httpd.conf中添加这两条配置参数。

image.png
重启服务 ./apachectl -k stop && ./apachectl -k start | 必须关闭后,在重新启动。
禁止使用目录索引:
在httpd.conf中配置相关参数
image.png