在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. ME51N 采购申请屏幕增强仅显示字段

    1.业务需求 通过委外工单生成的采购申请,需要将自定义"图号"字段显示在采购申请中,且只用于显示即可 2.增强实现 增强表EBAN的结构CI_EBANDB 增强点CMOD:MERE ...

  2. C# .NET Socket SocketHelper 高性能 5000客户端 异步接收数据

    网上有很多Socket框架,但是我想,C#既然有Socket类,难道不是给人用的吗? 写了一个SocketServerHelper和SocketClientHelper,分别只有5.6百行代码,比不上 ...

  3. Java文件上传与下载压缩

    文件上传与下载压缩 文件上传: 这是一个通用的本地文件的上传代码,可以将文件类型存储到相应的本地目录下 注:本次演示为存储路径为项目所在的resources目录下,可通过url去访问本地文件数据适用于 ...

  4. SpringCloud学习 系列八、OpenFeign

    系列导航 SpringCloud学习 系列一. 前言-为什么要学习微服务 SpringCloud学习 系列二. 简介 SpringCloud学习 系列三. 创建一个没有使用springCloud的服务 ...

  5. js判断null最标准写法

  6. Canvas实现画布的缩放

    主要介绍三种方式: 首先创建一个index.html文件 <!DOCTYPE html> <html lang="en"> <head> < ...

  7. shell 实现项目的启动与停止

    本文为博主原创,转载请注明出处: 1. 以tomcat 为例,编写启动脚本: #!/bin/sh bin=$(cd `dirname $0`; pwd) pid=$(ps aux | grep tom ...

  8. 为什么 sort() 中的 return a-b 可以决定升序

    arr.sort( function(a,b){ return a-b; } ) 千万不要理解成 a 减 b 其实它代表的是26个字母中的 a 和 b b 比 a 大,所以 a - b 就是升序,写成 ...

  9. JS - this 操作 dom , 添加样式

    <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8 ...

  10. Mongo-文档主键-ObjectId

    文档主键 文档主键时 _id,如果插入文档时,没有传入则自动生产ObjectId 作为文档主键 文档主键要求在集合中唯一 文档主键可以时另一个文档,被当作字符串对象处理 ObjectId对象 获取文档 ...