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

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

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

[lyshark@localhost] # cat /etc/httpd/conf/httpd.confServerRoot "/etc/httpd"
Listen 80# 导入模块
Include conf.modules.d/*.conf# 启用伪静态
LoadModule rewrite_module modules/mod_rewrite.soUser apache
Group apache
ServerAdmin root@localhost
DocumentRoot "/var/www/html"<Directory />Options FollowSymLinksAllowOverride allRequire all denied
</Directory><Directory "/var/www">Options FollowSymLinksAllowOverride NoneRequire all granted
</Directory><Directory "/var/www/html">Options FollowSymLinksAllowOverride AllRequire 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\"" combinedLogFormat "%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 NoneOptions NoneRequire all granted
</Directory><IfModule mime_module>TypesConfig /etc/mime.typesAddType application/x-compress .ZAddType application/x-gzip .gz .tgzAddType text/html .shtmlAddOutputFilter INCLUDES .shtml
</IfModule>AddDefaultCharset UTF-8<IfModule mime_magic_module>MIMEMagicFile conf/magic
</IfModule>#EnableMMAP off
EnableSendfile onIncludeOptional conf.d/*.conf# 设置http跳转到https上面
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://www.lyshark.comServerTokens 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,DenyDeny from all</LimitExcept>
</Location>

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

[lyshark@localhost] # cat /etc/httpd/conf.d/ssl.confListen 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/.htaccessRewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Linux 系统Apache配置SSL证书相关推荐

  1. Linux下 nginx配置ssl证书实现https访问

    配置ssl证书之前,先准备SSL证书,至于获取的途径很多(阿里云的服务,第三方服务购买).这里不详细解释.以下是我的SSL证书 准备好证书后,找到nginx的安装目录,我的安装位置为:/usr/loc ...

  2. Apache配置SSL证书服务器傻瓜步骤

    在Linux+Apache+OpenSSL中配置SSL安全证书认证是不难的,我的另一篇工作随记中曾提到[url]http://www.host01.com/article/server/0007000 ...

  3. Apache配置SSL证书指引

    一.安装Apache 1) 使用yum安装Apache # yum install httpd -y 2) 修改测试页面 # vim /var/www/html/index.heml PS:修改为测试 ...

  4. apache配置ssl证书

    目的:在阿里云ESC的apache服务器上部署申请的证书实现HTTPS访问 步骤: 1,申请证书(为阿里云自动配发的证书) 2,在apache上部署 2.1,vim /usr/local/apache ...

  5. linux下nginx配置SSL证书

    1.新建证书存放路径(/usr/local/nginx目录下) mkdir ssl 2.生成一个RSA私钥(/usr/local/nginx/ssl目录下) openssl genrsa -des3 ...

  6. 使用Certbot配置SSL证书【ubuntu系统】

    Step1:安装snapd[linux包管理工具] sudo apt install snapd #安装snapd sudo snap install core #安装core sudo snap r ...

  7. 记录一次在linux上配置ssl证书

    5分钟带你配置免费的ssl tomcat版 前言 区别 提前准备 开始 申请 配置 前言 由于最近项目的微信支付一块需要涉及到退款,这个需要https,所以先自己弄一个测试,在此记录这一次配置ssl证 ...

  8. node配置ssl证书_在Linux服务器上部署node项目(git部署,forever持续运行,配置SSL证书)...

    一.环境部署 1.下载安装包: wget https://nodejs.org/dist/v9.9.0/node-v9.9.0-linux-x64.tar.xz 2.解压并进入目录: xz -d no ...

  9. JavaWeb项目部署服务器并配置ssl证书教程

    JavaWeb项目部署服务器并配置ssl证书教程 相信大家学了1.2年的编程后可能已经学会了自己写web项目,但是也只能在自己本地玩耍,十分的打击学习热情(主要是没办法跟朋友装杯).本文是一篇较为详细 ...

最新文章

  1. 干货丨从线性回归到无监督学习,数据科学家需要掌握的十大统计技术
  2. shell 获取ora报错信息_频发:故障排除之又见 ORA-4031丨云和恩墨技术通讯
  3. 《C++覆辙录》——1.9:使用糟糕的语言
  4. 网易云解码实时音视频社交 成就游戏产业发展新变量
  5. 从 FFmpeg 性能加速到端云一体媒体系统优化
  6. 你的ABAP程序给佛祖开过光么?来试试Jerry这个小技巧
  7. golang plugin模块的使用
  8. 无心剑随感《最完美的图形——圆》
  9. activity 、window与view的关系 (上)
  10. flutter初体验之基础控件知识
  11. VSCode 拓展插件推荐
  12. win7系统网络计算机,Win7系统打开局域网没看到其他计算机的修复方法
  13. 安全测试之sql注入
  14. 神思SS628(100)型第二代身份证验证阅读机具二次开发
  15. “WebProxyWrapper”的对象强制转换为类型“System.Net.WebProxy
  16. 菜鸟学算法--二分查找
  17. 跨境电商o2o模式的表现形式有哪些?
  18. Image2icon for Mac(icns图标转换制作工具)
  19. 人工智能年薪百万的工作岗位,主要有哪些?
  20. mysql死锁解决方法_mysql出现死锁的原因及解决方案

热门文章

  1. Android反编译指南
  2. 栈的基本操作及其应用
  3. 基于stc15f2k60s2芯片单片机编程(串口+超声波)
  4. 《汇编语言程序设计》 可执行文件
  5. tars-源码分析-服务端
  6. python调用大漠getcursorpos,GetCursorPos()函数
  7. 如何创建新的虚拟机并安装Linux系统(一步到位,附ISO映像文件)
  8. CE训练教程进阶,步骤 9: 注入++
  9. ubuntu16.04安装libiconv
  10. java中枚举enum