在Centos7系列系统下,配置Apache服务器,给服务器增加SSL证书功能,让页面访问是不再提示不安全,具体操作流程如下。

1.第一步首先需要安装mod_ssl模块,执行yum install -y mod_ssl命令即可安装完毕。

打开配置文件写入以下配置项。

[lyshark@localhost] # cat /etc/httpd/conf/httpd.conf

ServerRoot "/etc/httpd"
Listen 80 # 导入模块
Include conf.modules.d/*.conf # 启用伪静态
LoadModule rewrite_module modules/mod_rewrite.so User apache
Group apache
ServerAdmin root@localhost
DocumentRoot "/var/www/html" <Directory />
Options FollowSymLinks
AllowOverride all
Require all denied
</Directory> <Directory "/var/www">
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory> <Directory "/var/www/html">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory> <IfModule dir_module>
DirectoryIndex index.html
</IfModule> <Files ".ht*">
Require all denied
</Files> ErrorLog "logs/error_log"
LogLevel warn <IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common <IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule> CustomLog "logs/access_log" combined
</IfModule> <IfModule alias_module>
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule> <Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory> <IfModule mime_module>
TypesConfig /etc/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</IfModule> AddDefaultCharset UTF-8 <IfModule mime_magic_module>
MIMEMagicFile conf/magic
</IfModule> #EnableMMAP off
EnableSendfile on IncludeOptional conf.d/*.conf # 设置http跳转到https上面
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://www.lyshark.com ServerTokens Prod
ServerSignature Off # 设置加密访问,当用户访问lyshark目录需要密码
# htpasswd -c /etc/htpasswd.db test
#<Directory /var/www/html/lyshark>
# AuthName "请输入管理员密码"
# AuthType Basic
# AuthUserFile /etc/htpasswd.db
# Require valid-user
#</Directory> # 限制Apache只允许接受GET POST请求方式
<Location "/">
<LimitExcept GET POST>
Order Allow,Deny
Deny from all
</LimitExcept>
</Location>

2.其次需要打开ssl配置目录,将证书上传到指定目录下,并增加你自己的证书文件路径。

[lyshark@localhost] # cat /etc/httpd/conf.d/ssl.conf

Listen 443 https
SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog
SSLSessionCache shmcb:/run/httpd/sslcache(512000)
SSLSessionCacheTimeout 300
SSLRandomSeed startup file:/dev/urandom 256
SSLRandomSeed connect builtin
SSLCryptoDevice builtin <VirtualHost _default_:443>
DocumentRoot "/var/www/html"
ServerName www.lyshark.com:443
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn
SSLEngine on
SSLProtocol all -SSLv2 -SSLv3
SSLCipherSuite HIGH:3DES:!aNULL:!MD5:!SEED:!IDEA # 此处增加SSL证书具体路径
SSLCertificateFile /var/www/ssl/4575832_www.lyshark.com_public.crt
SSLCertificateKeyFile /var/www/ssl/4575832_www.lyshark.com.key
SSLCertificateChainFile /var/www/ssl/4575832_www.lyshark.com_chain.crt <Files ~ "\.(cgi|shtml|phtml|php3?)$">
SSLOptions +StdEnvVars
</Files>
<Directory "/var/www/cgi-bin">
SSLOptions +StdEnvVars
</Directory> BrowserMatch "MSIE [2-5]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
CustomLog logs/ssl_request_log \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" </VirtualHost>

至此只需要重启systemctl restart httpd服务器即可完成ssl配置。

3.如果需要配置伪静态,则在Web网站根目录下增加一个隐藏文件,并写入一下配置,伪静态转发。

[lyshark@localhost] # cat /var/www/html/.htaccess

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Linux 系统Apache配置SSL证书的更多相关文章

  1. window下为apache配置ssl证书

    转载自 子非鱼 的博客稍作修改 第一步:依赖 配置Apache服务器支持https协议和SSL证书,最基本的要求是Apache包含openssl模块.还好apache/bin目录下有libeay32. ...

  2. linux系统下安装ssl证书(tomcat)

    1.申请ssl证书 2.下载ssl证书 打开此网址  https://myssl.com/cert_convert.html 将证书文件(xxx.com.crt)和密钥文件上传(xxx.com.key ...

  3. Appserv(Apache) 配置ssl证书

    一:打开httpd.conf文件,移除注释的行: Include conf/extra/httpd-ahssl.conf LoadModule ssl_module modules/mod_ssl.s ...

  4. linux下nginx配置ssl证书(https)

    nginx配置ssl很简单,首先需要两个文件,一个是crt文件,另一个是key文件,如下所示: xxx.crt;  #(证书公钥)xxx.key; #(证书私钥) 把这两个文件放到nginx的conf ...

  5. Linux下Apache配置SSL支持https

    参考:http://www.thinksaas.cn/group/topic/280017/ 生成证书过程如下 Step :生成服务器密钥: mkdir -p /etc/pki/test cd /et ...

  6. PHPWAMP集成环境配置ssl证书

    和apache配置ssl证书流程一样, LoadModule socache_shmcb_module modules/mod_socache_shmcb.so LoadModule ssl_modu ...

  7. Linux 搭建Nginx并添加配置 SSL 证书

    1. 安装准备   1.1 gcc安装 安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装: [root@nginx ~]# yum -y i ...

  8. Linux系统Apache服务 - 配置 HTTP 的虚拟机主机

    接Linux系统Apache服务 - 配置HTTP的默认主页 1.创建/srv目录,作为httpd的文件目录,并创建/srv/default/www和/srv/www1.example.com/www ...

  9. phpstudy配置SSL证书的步骤(Apache环境)以及一些注意事项

    准备工具(我自己的): 腾讯云的域名和云主机,还有SSL证书,以及phpstudy 首先要下载自己的SSL证书,会得到一个压缩包,解压以后会得到四个文件夹和一个csr文件, Apache文件夹内三个文 ...

  10. ubuntu中apache的ssl证书配置及url重写

    一.https原理 借用网上的图(图片来源: https://www.cnblogs.com/xiohao/p/9054355.html ),用到了对称加密和非对称加密.    二.ubuntu的ap ...

随机推荐

  1. 数字U家,即刻出发!2022联合利华黑客马拉松启动!

    2022联合利华黑客马拉松火热报名倒计时! 欢迎各领域的个人及组织团队参与 人工智能.数据挖掘.市场规模预测.原材料与包装风险控制.AR/VR.低碳.消费者偏好研究等超多创新赛题,任选其一. 作为快消 ...

  2. 五、java操作redis

    系列导航 一.redis单例安装(linux) 二.redis主从环境搭建 三.redis集群搭建 四.redis增加密码验证 五.java操作redis --demo主方法 package com. ...

  3. git branch 分支命令图文详解

    https://blog.csdn.net/wangdawei_/article/details/124556712 git branch 分支命令详解git branch (查看本地分支)git b ...

  4. SD Host控制器微架构设计

    微架构设计思路 ahb_slave_if中的寄存器可以在datasheet中进行描述 sd_clk - 时钟产生模块的接口描述 sd_data_fsm和sd_cmd_fsm - 状态机描述 发送时序需 ...

  5. 【SHELL】跨行内容查找、替换、删除

    跨行内容查找.替换.删除 sed '/START-TAG/{:a;N;/END-TAG/!ba};/ID: 222/d' data.txt /START-TAG/ { # Match 'START-T ...

  6. Android——SQLiteOpenHelper

    使用步骤: 新建一个继承自SQLiteOpenHelper的数据库操作类,提示重写onCreate和OnUpgraed两个方法.其中,onCreate方法只在第一次打开数据库时执行,在此可进行表结构创 ...

  7. [转帖]修改Linux内核参数,减少TCP连接中的TIME-WAIT

    https://www.cnblogs.com/xiaoleiel/p/8340346.html 一台服务器CPU和内存资源额定有限的情况下,如何提高服务器的性能是作为系统运维的重要工作.要提高Lin ...

  8. Oracle19c on 银河麒麟的安装与升级

    Oracle19c on 银河麒麟的安装与升级 下载内容 preinstall CentOS8 https://yum.oracle.com/repo/OracleLinux/OL8/appstrea ...

  9. [转帖]浅谈redis采用不同内存分配器tcmalloc和jemalloc

    http://www.kaotop.com/it/173669.html 我们知道Redis并没有自己实现内存池,没有在标准的系统内存分配器上再加上自己的东西.所以系统内存分配器的性能及碎片率会对Re ...

  10. [转帖]Linux中最全shell命令&常用注意事项

    在编辑linux脚本中不断的会用到复杂的脚本编辑,写文章记录. Linux命令大全(手册) – 真正好用的Linux命令在线查询网站 目录 推荐书籍: Linux常用命令 Linux 常用命令 在li ...