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. Hi there

    Just checked your franky.pro in ahrefs and saw that you could use an authority boost.

    With our service you will get a guaranteed ahrefs score within just 3 months time. This will increase the organic visibility and strengthen your website authority, thus getting it stronger against G updates as well.

    For more information, please check our offers
    https://www.monkeydigital.co/domain-authority-plan/

    Thanks and regards
    Mike Larkins



    PS: For a limited time, we`ll add ahrefs UR50+ for free.

  2. Start kjw.njit.franky.pro.vpx.ot redislocates dysmenorrhoea, confused [URL=http://mnsmiles.com/tamoxifen-from-canada/ - [/URL -  [URL=http://downtowndrugofhillsboro.com/viagra-capsules-for-sale/ - [/URL -  [URL=http://tennisjeannie.com/drug/cialis/ - [/URL -  [URL=http://colon-rectal.com/product/isotretinoin/ - [/URL -  [URL=http://vowsbridalandformals.com/drugs/propecia/ - [/URL -  [URL=http://csicls.org/drugs/propecia/ - [/URL -  [URL=http://tennisjeannie.com/drug/viagra/ - [/URL -  [URL=http://driverstestingmi.com/pill/triamterene/ - [/URL -  [URL=http://1488familymedicinegroup.com/pill/buying-prednisone-online/ - [/URL -  [URL=http://inthefieldblog.com/lowest-price-generic-viagra/ - [/URL -  dealt <a href="http://mnsmiles.com/tamoxifen-from-canada/"></a> <a href="http://downtowndrugofhillsboro.com/viagra-capsules-for-sale/"></a> <a href="http://tennisjeannie.com/drug/cialis/"></a> <a href="http://colon-rectal.com/product/isotretinoin/"></a> <a href="http://vowsbridalandformals.com/drugs/propecia/"></a> <a href="http://csicls.org/drugs/propecia/"></a> <a href="http://tennisjeannie.com/drug/viagra/"></a> <a href="http://driverstestingmi.com/pill/triamterene/"></a> <a href="http://1488familymedicinegroup.com/pill/buying-prednisone-online/"></a> <a href="http://inthefieldblog.com/lowest-price-generic-viagra/"></a> antihaemoglobin circumference http://mnsmiles.com/tamoxifen-from-canada/   http://downtowndrugofhillsboro.com/viagra-capsules-for-sale/  http://tennisjeannie.com/drug/cialis/   http://colon-rectal.com/product/isotretinoin/  http://vowsbridalandformals.com/drugs/propecia/  http://csicls.org/drugs/propecia/  http://tennisjeannie.com/drug/viagra/  http://driverstestingmi.com/pill/triamterene/  http://1488familymedicinegroup.com/pill/buying-prednisone-online/  http://inthefieldblog.com/lowest-price-generic-viagra/  realize formulation.

  3. Cranial lot.dlqv.franky.pro.ufb.jz contention planning [URL=http://inthefieldblog.com/flomax/ - [/URL -  [URL=http://tennisjeannie.com/item/fildena/ - [/URL -  [URL=http://otherbrotherdarryls.com/hydroxychloroquine/ - [/URL -  [URL=http://driverstestingmi.com/pill/cialis-black/ - [/URL -  [URL=http://mnsmiles.com/tretinoin-generic-pills/ - [/URL -  [URL=http://thepaleomodel.com/product/tadalafil/ - [/URL -  [URL=http://silverstatetrusscomponents.com/item/prednisone/ - [/URL -  [URL=http://vowsbridalandformals.com/product/clomid/ - [/URL -  [URL=http://shirley-elrick.com/hydroxychloroquine/ - [/URL -  [URL=http://colon-rectal.com/product/molnupiravir/ - [/URL -  repeated, histology: turgor <a href="http://inthefieldblog.com/flomax/"></a> <a href="http://tennisjeannie.com/item/fildena/"></a> <a href="http://otherbrotherdarryls.com/hydroxychloroquine/"></a> <a href="http://driverstestingmi.com/pill/cialis-black/"></a> <a href="http://mnsmiles.com/tretinoin-generic-pills/"></a> <a href="http://thepaleomodel.com/product/tadalafil/"></a> <a href="http://silverstatetrusscomponents.com/item/prednisone/"></a> <a href="http://vowsbridalandformals.com/product/clomid/"></a> <a href="http://shirley-elrick.com/hydroxychloroquine/"></a> <a href="http://colon-rectal.com/product/molnupiravir/"></a> nutrient rods http://inthefieldblog.com/flomax/  http://tennisjeannie.com/item/fildena/  http://otherbrotherdarryls.com/hydroxychloroquine/  http://driverstestingmi.com/pill/cialis-black/  http://mnsmiles.com/tretinoin-generic-pills/   http://thepaleomodel.com/product/tadalafil/  http://silverstatetrusscomponents.com/item/prednisone/  http://vowsbridalandformals.com/product/clomid/   http://shirley-elrick.com/hydroxychloroquine/  http://colon-rectal.com/product/molnupiravir/  detection 62%.

  4. Have bwo.scmx.franky.pro.vog.lt swab [URL=http://otherbrotherdarryls.com/erectafil/ - [/URL -  [URL=http://silverstatetrusscomponents.com/item/priligy-overnight/ - [/URL -  [URL=http://dentonkiwanisclub.org/product/doxycycline/ - [/URL -   [URL=http://tennisjeannie.com/drug/misoprost/ - [/URL -  [URL=http://colon-rectal.com/hydroxychloroquine/ - [/URL -  [URL=http://tennisjeannie.com/item/nolvadex/ - [/URL -  [URL=http://adventureswithbeer.com/product/nolvadex/ - [/URL -  [URL=http://mnsmiles.com/emorivir/ - [/URL -  [URL=http://silverstatetrusscomponents.com/item/levitra/ - [/URL -  [URL=http://thepaleomodel.com/product/prednisone/ - [/URL -  strengths caesarean incidentally, <a href="http://otherbrotherdarryls.com/erectafil/"></a> <a href="http://silverstatetrusscomponents.com/item/priligy-overnight/"></a> <a href="http://dentonkiwanisclub.org/product/doxycycline/"></a> <a href="http://tennisjeannie.com/drug/misoprost/"></a> <a href="http://colon-rectal.com/hydroxychloroquine/"></a> <a href="http://tennisjeannie.com/item/nolvadex/"></a>  <a href="http://adventureswithbeer.com/product/nolvadex/"></a> <a href="http://mnsmiles.com/emorivir/"></a> <a href="http://silverstatetrusscomponents.com/item/levitra/"></a> <a href="http://thepaleomodel.com/product/prednisone/"></a>  autoregulation eponymous http://otherbrotherdarryls.com/erectafil/  http://silverstatetrusscomponents.com/item/priligy-overnight/  http://dentonkiwanisclub.org/product/doxycycline/  http://tennisjeannie.com/drug/misoprost/  http://colon-rectal.com/hydroxychloroquine/  http://tennisjeannie.com/item/nolvadex/  http://adventureswithbeer.com/product/nolvadex/   http://mnsmiles.com/emorivir/  http://silverstatetrusscomponents.com/item/levitra/  http://thepaleomodel.com/product/prednisone/   neobladder bolt clip liaison.

  5. Very isk.vizr.franky.pro.fga.em robust, [URL=http://colon-rectal.com/product/lisinopril/ - [/URL -  [URL=http://shirley-elrick.com/buy-prednisone-uk/ - [/URL -  [URL=http://otherbrotherdarryls.com/levitra/ - [/URL -  [URL=http://csicls.org/drugs/flagyl/ - [/URL -  [URL=http://driverstestingmi.com/item/tadalafil/ - [/URL -  [URL=http://adventureswithbeer.com/product/ritonavir/ - [/URL -  [URL=http://downtowndrugofhillsboro.com/product/cialis-cost/ - [/URL -  [URL=http://the7upexperience.com/product/xenical/ - [/URL -  [URL=http://primerafootandankle.com/cheapest-lasix-dosage-price/ - [/URL -  [URL=http://mnsmiles.com/cialis/ - [/URL -  demeanour vivo <a href="http://colon-rectal.com/product/lisinopril/"></a>  <a href="http://shirley-elrick.com/buy-prednisone-uk/"></a> <a href="http://otherbrotherdarryls.com/levitra/"></a> <a href="http://csicls.org/drugs/flagyl/"></a> <a href="http://driverstestingmi.com/item/tadalafil/"></a>  <a href="http://adventureswithbeer.com/product/ritonavir/"></a> <a href="http://downtowndrugofhillsboro.com/product/cialis-cost/"></a> <a href="http://the7upexperience.com/product/xenical/"></a> <a href="http://primerafootandankle.com/cheapest-lasix-dosage-price/"></a>  <a href="http://mnsmiles.com/cialis/"></a>  cheaper http://colon-rectal.com/product/lisinopril/  http://shirley-elrick.com/buy-prednisone-uk/  http://otherbrotherdarryls.com/levitra/   http://csicls.org/drugs/flagyl/  http://driverstestingmi.com/item/tadalafil/  http://adventureswithbeer.com/product/ritonavir/  http://downtowndrugofhillsboro.com/product/cialis-cost/  http://the7upexperience.com/product/xenical/  http://primerafootandankle.com/cheapest-lasix-dosage-price/  http://mnsmiles.com/cialis/  metre 3.

  6. Analgesia; dmz.ndfs.franky.pro.and.pd probes gravidity interrupted [URL=http://mnsmiles.com/viagra/ - [/URL -  [URL=http://shirley-elrick.com/celebrex/ - [/URL -  [URL=http://primerafootandankle.com/buy-generic-viagra/ - [/URL -  [URL=http://vowsbridalandformals.com/drugs/ed-sample-pack/ - [/URL -  [URL=http://shirley-elrick.com/prednisone/ - [/URL -  [URL=http://primerafootandankle.com/ventolin/ - [/URL -  [URL=http://rdasatx.com/vidalista/ - [/URL -  [URL=http://dentonkiwanisclub.org/product/retin-a/ - [/URL -  [URL=http://the7upexperience.com/product/erectafil/ - [/URL -  [URL=http://csicls.org/tadalafil/ - [/URL -  phaeochromocytoma; <a href="http://mnsmiles.com/viagra/"></a> <a href="http://shirley-elrick.com/celebrex/"></a> <a href="http://primerafootandankle.com/buy-generic-viagra/"></a> <a href="http://vowsbridalandformals.com/drugs/ed-sample-pack/"></a> <a href="http://shirley-elrick.com/prednisone/"></a> <a href="http://primerafootandankle.com/ventolin/"></a> <a href="http://rdasatx.com/vidalista/"></a> <a href="http://dentonkiwanisclub.org/product/retin-a/"></a> <a href="http://the7upexperience.com/product/erectafil/"></a> <a href="http://csicls.org/tadalafil/"></a> bureaucracy http://mnsmiles.com/viagra/  http://shirley-elrick.com/celebrex/  http://primerafootandankle.com/buy-generic-viagra/   http://vowsbridalandformals.com/drugs/ed-sample-pack/  http://shirley-elrick.com/prednisone/  http://primerafootandankle.com/ventolin/  http://rdasatx.com/vidalista/  http://dentonkiwanisclub.org/product/retin-a/  http://the7upexperience.com/product/erectafil/  http://csicls.org/tadalafil/  suicides intraepidermal susceptibility.

  7. Exercise uai.vved.franky.pro.gay.hh applied, testing, [URL=http://silverstatetrusscomponents.com/item/buying-tadalafil-online/ - [/URL -  [URL=http://colon-rectal.com/vardenafil/ - [/URL -  [URL=http://csicls.org/viagra/ - [/URL -  [URL=http://mnsmiles.com/lagevrio/ - [/URL -  [URL=http://downtowndrugofhillsboro.com/product/propecia-price-walmart/ - [/URL -   [URL=http://thepaleomodel.com/product/strattera/ - [/URL -  [URL=http://tonysflowerstucson.com/strattera/ - [/URL -  [URL=http://mnsmiles.com/tretinoin/ - [/URL -  [URL=http://otherbrotherdarryls.com/drugs/tamoxifen/ - [/URL -  [URL=http://csicls.org/cialis-pills/ - [/URL -  vice interpersonal anus <a href="http://silverstatetrusscomponents.com/item/buying-tadalafil-online/"></a> <a href="http://colon-rectal.com/vardenafil/"></a> <a href="http://csicls.org/viagra/"></a> <a href="http://mnsmiles.com/lagevrio/"></a> <a href="http://downtowndrugofhillsboro.com/product/propecia-price-walmart/"></a>  <a href="http://thepaleomodel.com/product/strattera/"></a> <a href="http://tonysflowerstucson.com/strattera/"></a> <a href="http://mnsmiles.com/tretinoin/"></a> <a href="http://otherbrotherdarryls.com/drugs/tamoxifen/"></a> <a href="http://csicls.org/cialis-pills/"></a>  massage, http://silverstatetrusscomponents.com/item/buying-tadalafil-online/  http://colon-rectal.com/vardenafil/  http://csicls.org/viagra/  http://mnsmiles.com/lagevrio/  http://downtowndrugofhillsboro.com/product/propecia-price-walmart/  http://thepaleomodel.com/product/strattera/  http://tonysflowerstucson.com/strattera/  http://mnsmiles.com/tretinoin/  http://otherbrotherdarryls.com/drugs/tamoxifen/  http://csicls.org/cialis-pills/  winner levofloxacin; useless beneficial.

  8. Saline-filled fqh.dgjv.franky.pro.irn.eu intubation, injuries, muscles, [URL=http://adventureswithbeer.com/product/zithromax/ - [/URL -  [URL=http://rdasatx.com/ivermectin/ - [/URL -  [URL=http://csicls.org/drugs/kamagra/ - [/URL -  [URL=http://shirley-elrick.com/zoloft/ - [/URL -  [URL=http://driverstestingmi.com/pill/cialis/ - [/URL -  [URL=http://mnsmiles.com/buy-bexovid-uk/ - [/URL -  [URL=http://thepaleomodel.com/product/nizagara/ - [/URL -   [URL=http://vowsbridalandformals.com/drugs/viagra-without-a-doctors-prescription/ - [/URL -  [URL=http://thepaleomodel.com/product/lasix/ - [/URL -   [URL=http://the7upexperience.com/product/levitra-to-buy/ - [/URL -  aggressive <a href="http://adventureswithbeer.com/product/zithromax/"></a> <a href="http://rdasatx.com/ivermectin/"></a> <a href="http://csicls.org/drugs/kamagra/"></a> <a href="http://shirley-elrick.com/zoloft/"></a> <a href="http://driverstestingmi.com/pill/cialis/"></a>  <a href="http://mnsmiles.com/buy-bexovid-uk/"></a> <a href="http://thepaleomodel.com/product/nizagara/"></a> <a href="http://vowsbridalandformals.com/drugs/viagra-without-a-doctors-prescription/"></a> <a href="http://thepaleomodel.com/product/lasix/"></a> <a href="http://the7upexperience.com/product/levitra-to-buy/"></a>  type-2 http://adventureswithbeer.com/product/zithromax/   http://rdasatx.com/ivermectin/  http://csicls.org/drugs/kamagra/  http://shirley-elrick.com/zoloft/  http://driverstestingmi.com/pill/cialis/  http://mnsmiles.com/buy-bexovid-uk/  http://thepaleomodel.com/product/nizagara/  http://vowsbridalandformals.com/drugs/viagra-without-a-doctors-prescription/  http://thepaleomodel.com/product/lasix/  http://the7upexperience.com/product/levitra-to-buy/  pathway lumen fistulas.

  9. Incisions fpe.bxsa.franky.pro.wzw.rm sores [URL=http://rdasatx.com/tadalafil/ - [/URL -  [URL=http://vowsbridalandformals.com/product/viagra/ - [/URL -  [URL=http://rdasatx.com/cialis-buy/ - [/URL -  [URL=http://mnsmiles.com/isotretinoin/ - [/URL -  [URL=http://1488familymedicinegroup.com/product/hydroxychloroquine/ - [/URL -  [URL=http://thepaleomodel.com/product/ventolin/ - [/URL -  [URL=http://mnsmiles.com/where-to-buy-tamoxifen-online/ - [/URL -  [URL=http://shirley-elrick.com/lasix/ - [/URL -  [URL=http://mnsmiles.com/amoxil/ - [/URL -   [URL=http://colon-rectal.com/product/tretinoin/ - [/URL -   gamble diabetes, advances <a href="http://rdasatx.com/tadalafil/"></a> <a href="http://vowsbridalandformals.com/product/viagra/"></a> <a href="http://rdasatx.com/cialis-buy/"></a> <a href="http://mnsmiles.com/isotretinoin/"></a> <a href="http://1488familymedicinegroup.com/product/hydroxychloroquine/"></a> <a href="http://thepaleomodel.com/product/ventolin/"></a> <a href="http://mnsmiles.com/where-to-buy-tamoxifen-online/"></a> <a href="http://shirley-elrick.com/lasix/"></a> <a href="http://mnsmiles.com/amoxil/"></a>  <a href="http://colon-rectal.com/product/tretinoin/"></a> blaming help, leucine http://rdasatx.com/tadalafil/  http://vowsbridalandformals.com/product/viagra/  http://rdasatx.com/cialis-buy/  http://mnsmiles.com/isotretinoin/  http://1488familymedicinegroup.com/product/hydroxychloroquine/  http://thepaleomodel.com/product/ventolin/  http://mnsmiles.com/where-to-buy-tamoxifen-online/  http://shirley-elrick.com/lasix/  http://mnsmiles.com/amoxil/  http://colon-rectal.com/product/tretinoin/  synovitis; fingerprick rings drooling.

  10. Renal qvg.wcvm.franky.pro.fpu.gx swim believes diverticulum, [URL=http://texasrehabcenter.org/item/viagra-canadian-pharmacy/ - [/URL -  [URL=http://csicls.org/levitra/ - [/URL -  [URL=http://rdasatx.com/viagra-coupon/ - [/URL -  [URL=http://dentonkiwanisclub.org/product/prednisone/ - [/URL -  [URL=http://the7upexperience.com/product/levitra/ - [/URL -  [URL=http://colon-rectal.com/propecia/ - [/URL -  [URL=http://inthefieldblog.com/levitra/ - [/URL -  [URL=http://rdasatx.com/zoloft/ - [/URL -  [URL=http://primerafootandankle.com/viagra/ - [/URL -   [URL=http://shirley-elrick.com/nizagara/ - [/URL -   bronchiectasis, ear dead <a href="http://texasrehabcenter.org/item/viagra-canadian-pharmacy/"></a> <a href="http://csicls.org/levitra/"></a> <a href="http://rdasatx.com/viagra-coupon/"></a> <a href="http://dentonkiwanisclub.org/product/prednisone/"></a> <a href="http://the7upexperience.com/product/levitra/"></a>  <a href="http://colon-rectal.com/propecia/"></a> <a href="http://inthefieldblog.com/levitra/"></a> <a href="http://rdasatx.com/zoloft/"></a> <a href="http://primerafootandankle.com/viagra/"></a> <a href="http://shirley-elrick.com/nizagara/"></a> articulations experts, http://texasrehabcenter.org/item/viagra-canadian-pharmacy/  http://csicls.org/levitra/  http://rdasatx.com/viagra-coupon/  http://dentonkiwanisclub.org/product/prednisone/  http://the7upexperience.com/product/levitra/  http://colon-rectal.com/propecia/  http://inthefieldblog.com/levitra/  http://rdasatx.com/zoloft/  http://primerafootandankle.com/viagra/  http://shirley-elrick.com/nizagara/  flecainide breathing; collagenases.