在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. 开发中history和location

  2. C#设计模式09——组合模式的写法

    1. 什么是C#组合模式? 组合模式是一种结构型设计模式,它允许将对象组合成树形结构以表示"整体/部分"层次结构.使用此模式,客户端可以按相同的方式处理单个对象和对象集合,而不必关 ...

  3. 机器学习-无监督机器学习-主成分分析PCA-23

    目录 1. 降维的方式 2. PCA的一般步骤 3. 思想2 最小化投影距离 4. Kernelized PCA 1. 降维的方式 对于维度灾难.数据冗余,这些在数据处理中常见的场景,我们不得不进一步 ...

  4. node pressure and pod eviction

    0. overview There are too many guides about node pressure and pod eviction, most of them are specifi ...

  5. vue 中对style、disable 等样式进行条件判断

    本文为博主原创,未经允许不得转载: 一 原生用法 style="width: 100%; margin-top: 20px" disabled 二  三元表达式 <a :st ...

  6. P5729 【深基5.例7】工艺品制作

    1.题目介绍 [深基5.例7]工艺品制作 题目描述 现有一个长宽高分别为 \(w,x,h\) 组成的实心玻璃立方体,可以认为是由 \(1\times1\times1\) 的数个小方块组成的,每个小方块 ...

  7. js - 使用 scroll属性手撸轮播图 —— 无缝连接,更丝滑

    上效果图: 上代码: <!DOCTYPE html> <html lang="en"> <head>     <meta charset= ...

  8. canal报错nosuchmethod ..bytebuffer

    解决方法:更新jdk版本与es一致

  9. [转帖]linux audit审计(8)--开启audit对系统性能的影响

    https://www.cnblogs.com/xingmuxin/p/8875783.html 我们使用测试性能的工具,unixbench,它有一下几项测试项目: Execl Throughput ...

  10. [转帖]存储器分级:L1 Cache 比内存和 SSD 快多少倍?

    目录 1.为什么会有存储器分级策略? 2.存储器分级策略 2.1 存储器的级别 2.2.1 L1-Cache 2.2.2 L2-Cache 2.2.3 L3-Cache 3.内存 4.SSD 和硬盘 ...