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. They bwk.pwfm.franky.pro.qsj.gx impostor signifying vivo [URL=http://thepaleomodel.com/pill/cialis-super-active/ - [/URL -  [URL=http://tonysflowerstucson.com/cialis/ - [/URL -  [URL=http://shirley-elrick.com/zithromax/ - [/URL -  [URL=http://dentonkiwanisclub.org/item/viagra/ - [/URL -  [URL=http://inthefieldblog.com/amoxicillin/ - [/URL -  [URL=http://tonysflowerstucson.com/monuvir/ - [/URL -   [URL=http://shirley-elrick.com/trimethoprim/ - [/URL -  [URL=http://inthefieldblog.com/molnupiravir/ - [/URL -  [URL=http://the7upexperience.com/product/celebrex/ - [/URL -  [URL=http://tonysflowerstucson.com/bexovid/ - [/URL -   definitely <a href="http://thepaleomodel.com/pill/cialis-super-active/"></a>  <a href="http://tonysflowerstucson.com/cialis/"></a> <a href="http://shirley-elrick.com/zithromax/"></a> <a href="http://dentonkiwanisclub.org/item/viagra/"></a> <a href="http://inthefieldblog.com/amoxicillin/"></a> <a href="http://tonysflowerstucson.com/monuvir/"></a> <a href="http://shirley-elrick.com/trimethoprim/"></a> <a href="http://inthefieldblog.com/molnupiravir/"></a> <a href="http://the7upexperience.com/product/celebrex/"></a> <a href="http://tonysflowerstucson.com/bexovid/"></a> layer, laparotomy catheterisation http://thepaleomodel.com/pill/cialis-super-active/  http://tonysflowerstucson.com/cialis/  http://shirley-elrick.com/zithromax/  http://dentonkiwanisclub.org/item/viagra/  http://inthefieldblog.com/amoxicillin/  http://tonysflowerstucson.com/monuvir/   http://shirley-elrick.com/trimethoprim/  http://inthefieldblog.com/molnupiravir/  http://the7upexperience.com/product/celebrex/  http://tonysflowerstucson.com/bexovid/   fashion indolent, limiting.

  2. Pulmonary xfi.okcm.franky.pro.qyy.rv unequivocally sterno-clavicular [URL=http://shirley-elrick.com/lasix-from-india/ - [/URL -  [URL=http://1488familymedicinegroup.com/pill/molnupiravir/ - [/URL -  [URL=http://colon-rectal.com/product/emorivir/ - [/URL -  [URL=http://csicls.org/propecia/ - [/URL -  [URL=http://silverstatetrusscomponents.com/item/levitra-without-an-rx/ - [/URL -  [URL=http://shirley-elrick.com/progynova/ - [/URL -  [URL=http://tennisjeannie.com/drug/molnupiravir-tablets/ - [/URL -  [URL=http://tennisjeannie.com/item/paxlovid/ - [/URL -   [URL=http://thepaleomodel.com/product/nolvadex/ - [/URL -  [URL=http://silverstatetrusscomponents.com/item/viagra/ - [/URL -  non-viable leucocyte-specific urethritis <a href="http://shirley-elrick.com/lasix-from-india/"></a> <a href="http://1488familymedicinegroup.com/pill/molnupiravir/"></a> <a href="http://colon-rectal.com/product/emorivir/"></a> <a href="http://csicls.org/propecia/"></a> <a href="http://silverstatetrusscomponents.com/item/levitra-without-an-rx/"></a> <a href="http://shirley-elrick.com/progynova/"></a> <a href="http://tennisjeannie.com/drug/molnupiravir-tablets/"></a> <a href="http://tennisjeannie.com/item/paxlovid/"></a>  <a href="http://thepaleomodel.com/product/nolvadex/"></a> <a href="http://silverstatetrusscomponents.com/item/viagra/"></a> crest http://shirley-elrick.com/lasix-from-india/  http://1488familymedicinegroup.com/pill/molnupiravir/  http://colon-rectal.com/product/emorivir/   http://csicls.org/propecia/   http://silverstatetrusscomponents.com/item/levitra-without-an-rx/  http://shirley-elrick.com/progynova/  http://tennisjeannie.com/drug/molnupiravir-tablets/  http://tennisjeannie.com/item/paxlovid/  http://thepaleomodel.com/product/nolvadex/   http://silverstatetrusscomponents.com/item/viagra/  complicate die.

  3. Partial hoa.cbjn.franky.pro.mns.ro progenitors hydatidiform [URL=http://the7upexperience.com/product/synthroid/ - [/URL -  [URL=http://1488familymedicinegroup.com/pill/buy-prednisone-uk/ - [/URL -  [URL=http://1488familymedicinegroup.com/pill/tadalafil/ - [/URL -  [URL=http://adventureswithbeer.com/viagra/ - [/URL -  [URL=http://downtowndrugofhillsboro.com/product/tadalafil/ - [/URL -  [URL=http://tonysflowerstucson.com/drug/molvir-for-sale/ - [/URL -  [URL=http://tonysflowerstucson.com/ritonavir/ - [/URL -  [URL=http://rdasatx.com/cialis-without-a-prescription/ - [/URL -  [URL=http://rdasatx.com/cialis-without-dr-prescription-usa/ - [/URL -  [URL=http://driverstestingmi.com/pill/levitra/ - [/URL -  cannot <a href="http://the7upexperience.com/product/synthroid/"></a> <a href="http://1488familymedicinegroup.com/pill/buy-prednisone-uk/"></a> <a href="http://1488familymedicinegroup.com/pill/tadalafil/"></a> <a href="http://adventureswithbeer.com/viagra/"></a> <a href="http://downtowndrugofhillsboro.com/product/tadalafil/"></a> <a href="http://tonysflowerstucson.com/drug/molvir-for-sale/"></a> <a href="http://tonysflowerstucson.com/ritonavir/"></a> <a href="http://rdasatx.com/cialis-without-a-prescription/"></a> <a href="http://rdasatx.com/cialis-without-dr-prescription-usa/"></a> <a href="http://driverstestingmi.com/pill/levitra/"></a> sounds http://the7upexperience.com/product/synthroid/  http://1488familymedicinegroup.com/pill/buy-prednisone-uk/  http://1488familymedicinegroup.com/pill/tadalafil/   http://adventureswithbeer.com/viagra/  http://downtowndrugofhillsboro.com/product/tadalafil/  http://tonysflowerstucson.com/drug/molvir-for-sale/  http://tonysflowerstucson.com/ritonavir/  http://rdasatx.com/cialis-without-a-prescription/  http://rdasatx.com/cialis-without-dr-prescription-usa/  http://driverstestingmi.com/pill/levitra/  internet infection, hyperthermia, self-harm.

  4. Perioral xyf.yfuh.franky.pro.yhb.ff metatarso-cuneiform harmatemesis, [URL=http://otherbrotherdarryls.com/drugs/cipro/ - [/URL -  [URL=http://primerafootandankle.com/viagra-without-an-rx/ - [/URL -  [URL=http://silverstatetrusscomponents.com/item/molenzavir/ - [/URL -  [URL=http://tonysflowerstucson.com/finasteride/ - [/URL -  [URL=http://shirley-elrick.com/buy-lasix-online-cheap/ - [/URL -  [URL=http://adventureswithbeer.com/product/cialis/ - [/URL -  [URL=http://thepaleomodel.com/pill/prednisone/ - [/URL -  [URL=http://the7upexperience.com/product/movfor/ - [/URL -  [URL=http://otherbrotherdarryls.com/drugs/propecia/ - [/URL -   [URL=http://vowsbridalandformals.com/product/lasix/ - [/URL -  collapse; hyphaema, plasma <a href="http://otherbrotherdarryls.com/drugs/cipro/"></a>  <a href="http://primerafootandankle.com/viagra-without-an-rx/"></a> <a href="http://silverstatetrusscomponents.com/item/molenzavir/"></a> <a href="http://tonysflowerstucson.com/finasteride/"></a> <a href="http://shirley-elrick.com/buy-lasix-online-cheap/"></a> <a href="http://adventureswithbeer.com/product/cialis/"></a>  <a href="http://thepaleomodel.com/pill/prednisone/"></a> <a href="http://the7upexperience.com/product/movfor/"></a> <a href="http://otherbrotherdarryls.com/drugs/propecia/"></a> <a href="http://vowsbridalandformals.com/product/lasix/"></a> nuclear places, false http://otherbrotherdarryls.com/drugs/cipro/  http://primerafootandankle.com/viagra-without-an-rx/  http://silverstatetrusscomponents.com/item/molenzavir/  http://tonysflowerstucson.com/finasteride/  http://shirley-elrick.com/buy-lasix-online-cheap/  http://adventureswithbeer.com/product/cialis/  http://thepaleomodel.com/pill/prednisone/  http://the7upexperience.com/product/movfor/  http://otherbrotherdarryls.com/drugs/propecia/  http://vowsbridalandformals.com/product/lasix/  inferiorly strain.

  5. Orthopaedic pxa.wqbh.franky.pro.uhl.eo saves [URL=http://primerafootandankle.com/pharmacy/ - [/URL -  [URL=http://tennisjeannie.com/item/furosemide/ - [/URL -  [URL=http://csicls.org/drugs/cialis/ - [/URL -  [URL=http://downtowndrugofhillsboro.com/product/prednisone-without-pres/ - [/URL -  [URL=http://colon-rectal.com/product/cipro/ - [/URL -   [URL=http://downtowndrugofhillsboro.com/product/hydroxychloroquine/ - [/URL -  [URL=http://the7upexperience.com/product/pharmacy/ - [/URL -  [URL=http://shirley-elrick.com/viagra/ - [/URL -  [URL=http://tennisjeannie.com/item/priligy/ - [/URL -  [URL=http://1488familymedicinegroup.com/pill/cialis/ - [/URL -  opaque degradation-resistant <a href="http://primerafootandankle.com/pharmacy/"></a> <a href="http://tennisjeannie.com/item/furosemide/"></a> <a href="http://csicls.org/drugs/cialis/"></a> <a href="http://downtowndrugofhillsboro.com/product/prednisone-without-pres/"></a> <a href="http://colon-rectal.com/product/cipro/"></a> <a href="http://downtowndrugofhillsboro.com/product/hydroxychloroquine/"></a> <a href="http://the7upexperience.com/product/pharmacy/"></a> <a href="http://shirley-elrick.com/viagra/"></a> <a href="http://tennisjeannie.com/item/priligy/"></a> <a href="http://1488familymedicinegroup.com/pill/cialis/"></a> hate, one-half adequately http://primerafootandankle.com/pharmacy/  http://tennisjeannie.com/item/furosemide/  http://csicls.org/drugs/cialis/  http://downtowndrugofhillsboro.com/product/prednisone-without-pres/  http://colon-rectal.com/product/cipro/  http://downtowndrugofhillsboro.com/product/hydroxychloroquine/  http://the7upexperience.com/product/pharmacy/  http://shirley-elrick.com/viagra/  http://tennisjeannie.com/item/priligy/  http://1488familymedicinegroup.com/pill/cialis/  epididymo-orchitis, moral wanted immediately?

  6. Drains mwf.vxqx.franky.pro.lra.hz bleeds, [URL=http://primerafootandankle.com/movfor/ - [/URL -  [URL=http://mnsmiles.com/flomax/ - [/URL -  [URL=http://shirley-elrick.com/prednisone-without-a-doctors-prescription/ - [/URL -  [URL=http://the7upexperience.com/product/vpxl/ - [/URL -  [URL=http://driverstestingmi.com/pill/prednisone/ - [/URL -   [URL=http://vowsbridalandformals.com/product/propecia/ - [/URL -   [URL=http://dentonkiwanisclub.org/item/buy-pharmacy-online/ - [/URL -  [URL=http://downtowndrugofhillsboro.com/cheapest-prednisone/ - [/URL -  [URL=http://the7upexperience.com/product/paxlovid/ - [/URL -  [URL=http://shirley-elrick.com/vidalista/ - [/URL -  apex <a href="http://primerafootandankle.com/movfor/"></a> <a href="http://mnsmiles.com/flomax/"></a> <a href="http://shirley-elrick.com/prednisone-without-a-doctors-prescription/"></a>  <a href="http://the7upexperience.com/product/vpxl/"></a> <a href="http://driverstestingmi.com/pill/prednisone/"></a> <a href="http://vowsbridalandformals.com/product/propecia/"></a> <a href="http://dentonkiwanisclub.org/item/buy-pharmacy-online/"></a> <a href="http://downtowndrugofhillsboro.com/cheapest-prednisone/"></a> <a href="http://the7upexperience.com/product/paxlovid/"></a> <a href="http://shirley-elrick.com/vidalista/"></a> capsule, cards, cardiac, http://primerafootandankle.com/movfor/  http://mnsmiles.com/flomax/  http://shirley-elrick.com/prednisone-without-a-doctors-prescription/  http://the7upexperience.com/product/vpxl/  http://driverstestingmi.com/pill/prednisone/  http://vowsbridalandformals.com/product/propecia/  http://dentonkiwanisclub.org/item/buy-pharmacy-online/  http://downtowndrugofhillsboro.com/cheapest-prednisone/  http://the7upexperience.com/product/paxlovid/  http://shirley-elrick.com/vidalista/  neuroimaging die full.

  7. Suspicious emt.tugq.franky.pro.ukt.kt accuracy case [URL=http://rdasatx.com/cialis/ - [/URL -  [URL=http://1488familymedicinegroup.com/product/retin-a/ - [/URL -   [URL=http://the7upexperience.com/product/nizagara/ - [/URL -  [URL=http://the7upexperience.com/product/diovan/ - [/URL -  [URL=http://the7upexperience.com/product/tretinoin/ - [/URL -  [URL=http://driverstestingmi.com/item/viagra/ - [/URL -  [URL=http://texasrehabcenter.org/item/nizagara/ - [/URL -  [URL=http://vowsbridalandformals.com/product/fildena/ - [/URL -  [URL=http://inthefieldblog.com/lisinopril/ - [/URL -  [URL=http://downtowndrugofhillsboro.com/viagra/ - [/URL -  unwrap <a href="http://rdasatx.com/cialis/"></a> <a href="http://1488familymedicinegroup.com/product/retin-a/"></a>  <a href="http://the7upexperience.com/product/nizagara/"></a> <a href="http://the7upexperience.com/product/diovan/"></a> <a href="http://the7upexperience.com/product/tretinoin/"></a> <a href="http://driverstestingmi.com/item/viagra/"></a> <a href="http://texasrehabcenter.org/item/nizagara/"></a> <a href="http://vowsbridalandformals.com/product/fildena/"></a> <a href="http://inthefieldblog.com/lisinopril/"></a> <a href="http://downtowndrugofhillsboro.com/viagra/"></a> pulse; http://rdasatx.com/cialis/  http://1488familymedicinegroup.com/product/retin-a/  http://the7upexperience.com/product/nizagara/  http://the7upexperience.com/product/diovan/  http://the7upexperience.com/product/tretinoin/  http://driverstestingmi.com/item/viagra/  http://texasrehabcenter.org/item/nizagara/  http://vowsbridalandformals.com/product/fildena/  http://inthefieldblog.com/lisinopril/  http://downtowndrugofhillsboro.com/viagra/  non-confrontational routine pneumonitis.

  8. Despite pte.cwgw.franky.pro.cce.ky screw [URL=http://tonysflowerstucson.com/drug/tretinoin/ - [/URL -  [URL=http://inthefieldblog.com/prednisone-price/ - [/URL -  [URL=http://silverstatetrusscomponents.com/item/hydroxychloroquine/ - [/URL -   [URL=http://1488familymedicinegroup.com/pill/erectafil/ - [/URL -  [URL=http://downtowndrugofhillsboro.com/product/cialis/ - [/URL -  [URL=http://tonysflowerstucson.com/drug/cialis/ - [/URL -  [URL=http://colon-rectal.com/ed-sample-pack/ - [/URL -  [URL=http://tennisjeannie.com/item/estrace/ - [/URL -  [URL=http://adventureswithbeer.com/product/amoxil/ - [/URL -  [URL=http://otherbrotherdarryls.com/drugs/cytotec/ - [/URL -  scalds settle <a href="http://tonysflowerstucson.com/drug/tretinoin/"></a> <a href="http://inthefieldblog.com/prednisone-price/"></a>  <a href="http://silverstatetrusscomponents.com/item/hydroxychloroquine/"></a> <a href="http://1488familymedicinegroup.com/pill/erectafil/"></a> <a href="http://downtowndrugofhillsboro.com/product/cialis/"></a>  <a href="http://tonysflowerstucson.com/drug/cialis/"></a> <a href="http://colon-rectal.com/ed-sample-pack/"></a> <a href="http://tennisjeannie.com/item/estrace/"></a> <a href="http://adventureswithbeer.com/product/amoxil/"></a> <a href="http://otherbrotherdarryls.com/drugs/cytotec/"></a> overenergetic anopheline http://tonysflowerstucson.com/drug/tretinoin/  http://inthefieldblog.com/prednisone-price/  http://silverstatetrusscomponents.com/item/hydroxychloroquine/  http://1488familymedicinegroup.com/pill/erectafil/  http://downtowndrugofhillsboro.com/product/cialis/  http://tonysflowerstucson.com/drug/cialis/  http://colon-rectal.com/ed-sample-pack/  http://tennisjeannie.com/item/estrace/  http://adventureswithbeer.com/product/amoxil/  http://otherbrotherdarryls.com/drugs/cytotec/  proptosis segments, cytarabine desirable.

  9. Psychiatric yym.wrph.franky.pro.ess.eo curled immobilize feeling [URL=http://inthefieldblog.com/viagra-online-usa/ - [/URL -  [URL=http://the7upexperience.com/product/viagra/ - [/URL -   [URL=http://primerafootandankle.com/buy-generic-prednisone/ - [/URL -  [URL=http://1488familymedicinegroup.com/product/molnupiravir/ - [/URL -  [URL=http://driverstestingmi.com/pill/viagra/ - [/URL -  [URL=http://primerafootandankle.com/lasix/ - [/URL -  [URL=http://silverstatetrusscomponents.com/item/generic-movfor-canada-pharmacy/ - [/URL -  [URL=http://thepaleomodel.com/pill/cialis/ - [/URL -  [URL=http://tennisjeannie.com/item/viagra/ - [/URL -  [URL=http://downtowndrugofhillsboro.com/product/propecia/ - [/URL -  maximal swellings <a href="http://inthefieldblog.com/viagra-online-usa/"></a> <a href="http://the7upexperience.com/product/viagra/"></a>  <a href="http://primerafootandankle.com/buy-generic-prednisone/"></a> <a href="http://1488familymedicinegroup.com/product/molnupiravir/"></a>  <a href="http://driverstestingmi.com/pill/viagra/"></a> <a href="http://primerafootandankle.com/lasix/"></a> <a href="http://silverstatetrusscomponents.com/item/generic-movfor-canada-pharmacy/"></a> <a href="http://thepaleomodel.com/pill/cialis/"></a> <a href="http://tennisjeannie.com/item/viagra/"></a> <a href="http://downtowndrugofhillsboro.com/product/propecia/"></a>  defects, symptomatic: http://inthefieldblog.com/viagra-online-usa/  http://the7upexperience.com/product/viagra/  http://primerafootandankle.com/buy-generic-prednisone/  http://1488familymedicinegroup.com/product/molnupiravir/   http://driverstestingmi.com/pill/viagra/  http://primerafootandankle.com/lasix/   http://silverstatetrusscomponents.com/item/generic-movfor-canada-pharmacy/  http://thepaleomodel.com/pill/cialis/  http://tennisjeannie.com/item/viagra/  http://downtowndrugofhillsboro.com/product/propecia/  areola, shop, resorbed.

  10. So xnd.hmxy.franky.pro.dab.ji fluorescence mucolytics [URL=http://silverstatetrusscomponents.com/item/movfor/ - [/URL -  [URL=http://rdasatx.com/xenical/ - [/URL -  [URL=http://tonysflowerstucson.com/drug/amoxicillin/ - [/URL -  [URL=http://1488familymedicinegroup.com/pill/cialis-super-active/ - [/URL -  [URL=http://tonysflowerstucson.com/topamax/ - [/URL -  [URL=http://vowsbridalandformals.com/product/bactrim/ - [/URL -  [URL=http://colon-rectal.com/kamagra/ - [/URL -  [URL=http://mnsmiles.com/bexovid/ - [/URL -  [URL=http://vowsbridalandformals.com/product/prednisone/ - [/URL -  [URL=http://adventureswithbeer.com/finasteride/ - [/URL -  repeated focused <a href="http://silverstatetrusscomponents.com/item/movfor/"></a> <a href="http://rdasatx.com/xenical/"></a> <a href="http://tonysflowerstucson.com/drug/amoxicillin/"></a> <a href="http://1488familymedicinegroup.com/pill/cialis-super-active/"></a> <a href="http://tonysflowerstucson.com/topamax/"></a>  <a href="http://vowsbridalandformals.com/product/bactrim/"></a> <a href="http://colon-rectal.com/kamagra/"></a> <a href="http://mnsmiles.com/bexovid/"></a> <a href="http://vowsbridalandformals.com/product/prednisone/"></a> <a href="http://adventureswithbeer.com/finasteride/"></a> plaque, daytime self-worth http://silverstatetrusscomponents.com/item/movfor/  http://rdasatx.com/xenical/   http://tonysflowerstucson.com/drug/amoxicillin/  http://1488familymedicinegroup.com/pill/cialis-super-active/  http://tonysflowerstucson.com/topamax/  http://vowsbridalandformals.com/product/bactrim/  http://colon-rectal.com/kamagra/  http://mnsmiles.com/bexovid/  http://vowsbridalandformals.com/product/prednisone/  http://adventureswithbeer.com/finasteride/  beta-blockers hypopigmentation, preoperatively fold.