栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

centos7.6系统apache服务器配置443端口和https服务,一站式防踩坑,我知道我来晚了

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

centos7.6系统apache服务器配置443端口和https服务,一站式防踩坑,我知道我来晚了

第一步

首先你需要配置好httpd服务,iptables防火墙要打开443端口

-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT

然后输入以下指令

yum install mod_ssl openssl

rpm -qa| grep mod_ssl

rpm -qa| grep openssl

安装完成后会生成一个

/etc/httpd/conf.d/ssl.conf文件

 第二步

这里给大家提供一个免费的颁发ssl证书的网站

Certbot Instructions | Certbot

按照网站指引输入指令

当你到达

 这一步时停止

第三步

输入

vi /etc/httpd/conf/httpd.conf

打开apache配置文件

找到SeverName部分按照如下格式添加,example输入你自己的域名

 

关键时刻来了

找到httpd.conf文件中的

按照如下格式书写,一点也不能更改格式,少个空格都不行!!!!!!!

# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
#  definition.  These values also provide defaults for
# any  containers you may define later in the file.
#
# All of these directives may appear inside  containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

NameVirtualHost 111.222.333.444:80


    ServerAdmin root@localhost
    documentRoot /var/www/html
    ServerName www.gangcaishudeyuming.xyz
    ErrorLog logs/error_log
    TransferLog logs/access_log

域名和ip地址写你自己的

紧接着在loadmodules段按照如下格式写

 保存退出

输入:

systemctl restart httpd

如果重启成功啧代表修改配置成功,如果重启失败提示语法错误说明你刚刚操作错了

如果重启成功,那么回到第二部的最后一步使用certbot给域名安装ssl证书就会成功了,如果成功提示让你选择你的域名,那么代表安装成功,输入对应数字即可选择安装的域名,certbot会自动申请证书

 第五步

使用FileZilla软件或者其他什么能够操作远程操作服务器文件的软件,或者你用指令啥的都可以。

将/etc/letsencrypt/live/这个目录里的文件证书转移到一个方便寻找的地方

以下四个证书都要转出

    cert.pem ->chain.pem ->fullchain.pem ->privkey.pem ->

紧接着编辑ssl.conf文件

vi /etc/httpd/conf.d/ssl.conf

找到如下位置,输入你刚才转移证书所到的那个地址

# General setup for the virtual host, inherited from global configuration
documentRoot "/var/www/html/"
ServerName www.nideyuming.com:443
.
.
.
SSLCertificateFile /etc/letsencrypt/live/fullchain.pem
.
.
.
SSLCertificateKeyFile /etc/letsencrypt/live/privkey.pem
.
.
.

如果以上内容你都正确操作,那么这时候重启httpd服务

systemctl restart httpd

试着用https的方法访问你的域名

https://www.xxxxx.com

如果成功,则恭喜你配置成功了

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/747498.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号