Apache2配置ssl证书

今天上公选课,实在听不进去,就想着把SSL证书配了。最早参考腾讯云的SSL证书安装,结果他给的目录我压根就找不到。于是到Google上搜索,找到了这篇博客,讲的挺好的。我大概把他用中文翻译一下吧。

先开启SSL服务 

sudo a2enmod ssl


应该会显示 Module ssl already enabled 或者 Enabling module ssl 。然后重启

apache sudo service apache2 restart

再用

apachectl -S

查看当前使用的配置文件
842101-20221019200315329-867210381.png

在没有安装好证书之前,应该是没有*:443那一行的。
在我的服务器上,使用的配置文件是/etc/apache2/sites-enabled/000-default.conf。
于是打开这个配置文件,在最后写入(把括号连带括号里的内容替换成自己的配置)

<VirtualHost *:443>
ServerName (DOMAIN NAME OF THE WEBSITE)
DocumentRoot (ROOT FOLDER OF THE WEBSITE)


SSLEngine on
SSLCertificateFile (Certificate PATH)
SSLCertificateKeyFile (Private key PATH)
SSLCertificateChainFile (CA Bundle PATH)
</VirtualHost>

对于我的配置来说,是这样的:

<VirtualHost *:443>
ServerName franky.pro
DocumentRoot /var/www/html

SSLEngine on
SSLCertificateFile /etc/httpd/ssl/franky.pro.crt
SSLCertificateKeyFile /etc/httpd/ssl/franky.pro.key
SSLCertificateChainFile /etc/httpd/ssl/root_bundle.crt
</VirtualHost>

至于那个 SSLCertificateChainFile ,网上说好像不用管,不会用到……
保存以后,再次运行

 apachectl -S

 ,应该就能看到最上面那张图所显示的*:443了。
然后使用 

apachectl -t 


检查你的配置文件有没有语法错误。如果没有语法错误,就可以重启apache 

sudo service apache2 restart 


这时候,你的网站就可以使用https进行访问了。

此外,如果你想把http的访问重定向到https,只需要把配置文件里的 <VirtualHost *:80> 里加上一行 

Redirect permanent / https://xxx.xx 

就行了

842101-20221019201213435-334079988.png
之后,再次重启即可。

这里写一下我遇到的一个小问题:在安装SSL证书以后,网站的css没法正常加载,原因是在emlog的设置里,没有把站点地址改成https,仍然用的是http。但是我已经把http重定向到https了,应该不会出现这种问题呀?

   Apache SSL
  最后修订:2022-10-19

32条评论

  1. Xevil5.0自动解决大多数类型的captchas,
    包括这类验证码: ReCaptcha-2, ReCaptcha v.3, Hotmail (Microsoft), Google captcha, SolveMedia, BitcoinFaucet, Steam, +12k
    + hCaptcha, ReCaptcha Enterprise 支持新的Xevil6.0!

    1.) 快速,轻松
    XEvil是世界上最快的验证码杀手。 它没有解决限制,没有线程数限制
    你甚至可以每天解决1.000.000.000captchas,它将花费0(零)美元! 只需购买许可证59美元和所有!

    2.) 几个Api支持
    XEvil支持超过6种不同的全球知名API: 2Captcha, anti-captcha (antigate), RuCaptcha, DeathByCaptcha, etc.
    只要通过HTTP请求发送您的验证码,因为您可以发送到任何一个服务-和XEvil将解决您的验证码!
    因此,XEvil与数百个SEO/SMM/密码恢复/解析/发布/点击/加密货币/等应用程序兼容。

    3.) 有用的支持和手册
    购买后,您可以访问私人技术。支持论坛,维基,Skype/电报在线支持
    开发人员将免费且非常快速地训练XEvil到您的验证码类型-只需向他们发送示例

    4.) 如何免费试用XEvil完整版?
    - 尝试在Google中搜索 "Home of XEvil"
    - 您将找到Xevil用户打开端口80的Ip(点击任何IP以确保)
    - 尝试通过2captcha API ino其中一个Ip发送您的captcha
    - 如果你有坏的密钥错误,只需tru另一个IP
    - 享受吧! :)
    - (它不适用于hCaptcha!)

    警告:免费XEvil演示不支持ReCaptcha,hCaptcha和大多数其他类型的captcha!

    http://xrumersale.site/

  2. Hеllо!  franky.pro

    Did yоu knоw thаt it is pоssiblе tо sеnd lеttеr   lаwful?
    Wе suggеsting а nеw wаy оf sеnding соmmеrсiаl оffеr thrоugh fееdbасk fоrms. Suсh fоrms аrе lосаtеd оn mаny sitеs.
    Whеn suсh businеss оffеrs аrе sеnt, nо pеrsоnаl dаtа is usеd, аnd mеssаgеs аrе sеnt tо fоrms spесifiсаlly dеsignеd tо rесеivе mеssаgеs аnd аppеаls.
    аlsо, mеssаgеs sеnt thrоugh fееdbасk Fоrms dо nоt gеt intо spаm bесаusе suсh mеssаgеs аrе соnsidеrеd impоrtаnt.
    Wе оffеr yоu tо tеst оur sеrviсе fоr frее. Wе will sеnd up tо 50,000 mеssаgеs fоr yоu.
    Thе соst оf sеnding оnе milliоn mеssаgеs is 49 USD.

    This оffеr is сrеаtеd аutоmаtiсаlly. Plеаsе usе thе соntасt dеtаils bеlоw tо соntасt us.

    Contact us.
    Telegram - @FeedbackMessages
    Skype  live:contactform_18
    WhatsApp - +375259112693
    We only use chat.
    no.reply.scaph@gmail.com

  3. Therefore, Bitcoin is a currency or form of money, and investors wishing to invest in BTCST provided an investment of money <a href=https://clomid.mom/>cheap clomid in the usa</a>

  4. WilliamLap

    <a href=https://mailforbob.com/>https://mailforbob.com/</a>

  5. Hi there

    I Just checked your franky.pro ranks and saw that your site is trending down for some time.

    If you are looking for a trend reversal, we have the right solution for you

    We are offering affordable Content Marketing plans with humanly written SEO content

    For more information, please check our offers
    https://www.digital-x-press.com/product/content-marketing/

    Thanks and regards
    Mike Ayrton

  6. Mice were then treated with 100 mg kg SAHA or vehicle at P30 one day before acute damage, then at P31 8 h after kanamycin furosemide treatment, and at P32 <a href=https://clomid.mom/>clomid for low testosterone</a> The VDRL is the test of choice for evaluating for neurosyphilis, and has a slightly higher specificity when compared to the RPR 96 to 99 compared to 93 to 99, resulting in fewer false positive tests

  7. rr

    你评论里面都是个啥

  8. Hello,

    Best Music https://0daymusic.org/ for DJs that gives you full access to exclusive electronic music.

    0day music team.

  9. <a href=https://lasix.autos/>buy lasix cheap online</a> Cover with clingfilm and leave to rest in the refrigerator for at least 30 minutes

  10. Hello

    I have just analyzed  franky.pro for the ranking keywords and saw that your website could use an upgrade.

    We will increase your SEO metrics and ranks organically and safely, using only whitehat methods, while providing monthly reports and outstanding support.

    Please check our pricelist here, we offer SEO at cheap rates.
    https://www.hilkom-digital.de/cheap-seo-packages/

    Regards
    Mike Vance


    PS: Quality SEO content is included