{"id":277,"date":"2022-01-15T10:46:21","date_gmt":"2022-01-15T02:46:21","guid":{"rendered":"https:\/\/www.wennroy.com\/?p=277"},"modified":"2022-01-15T10:46:50","modified_gmt":"2022-01-15T02:46:50","slug":"ubuntu20-04-apache-https-tutorial","status":"publish","type":"post","link":"https:\/\/wennroy.com\/index.php\/2022\/01\/15\/ubuntu20-04-apache-https-tutorial\/","title":{"rendered":"Ubuntu20.04 Apache Https Tutorial"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u817e\u8baf\u4e91\u4e00\u952eHTTPS\u670d\u52a1<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/cloud.tencent.com\/document\/product\/400\/68102\">\u4e00\u952eHTTPS\u670d\u52a1\u5230\u671f\u5982\u4f55\u5904\u7406<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u82e5\u4e4b\u524d\u4f7f\u7528\u8fc7\u4e00\u952eHTTPS\u7684\u8bdd\uff0c\u5148\u89e3\u51b3\u4e00\u952eHTTPS\u670d\u52a1\u4fee\u6539DNS\u89e3\u6790\u57df\uff0c\u5b9a\u5411\u5230CNAME\u7684\u95ee\u9898\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u56f0\u6270\u4e86\u6211\u534a\u4e2a\u591a\u5c0f\u65f6= =<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">HTTPS\u670d\u52a1\u8bc1\u4e66\u5b89\u88c5<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u53c2\u8003\u4e86\u4ee5\u4e0b\u4e24\u4e2a\u94fe\u63a5\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/cloud.tencent.com\/document\/product\/400\/35243\">CentOS\u4e0bApache\u670d\u52a1\u5668SSL\u8bc1\u4e66\u5b89\u88c5<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/blog.csdn.net\/cyan20115\/article\/details\/106554254\">\u5728Ubuntu\u4e0a\u7684Apache\u914d\u7f6eSSL(https\u8bc1\u4e66)\u7684\u6b63\u786e\u59ff\u52bf<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u9996\u5148\u662f\u6309\u7167\u817e\u8baf\u4e91\u6559\u7a0b\u4e0b\u8f7d\u8bc1\u4e66\u7b49\uff0c\u8fd9\u91cc\u5c31\u4e0d\u518d\u8be6\u7ec6\u8d58\u8ff0\u3002\u4e3b\u8981\u662f\u9488\u5bf9Ubuntu\u7cfb\u7edf\u4e0b\u5229\u7528 <strong>apt-get\u5b89\u88c5<\/strong> Apache\u4e4b\u540e\u7684\u60c5\u51b5\u3002\u4e0eCentOS\u7684\u60c5\u51b5\u4e0d\u540c\uff0c\u5728Ubuntu\u4e0bApache\u670d\u52a1\u7684\u9ed8\u8ba4\u5730\u5740\u662f<code>\/etc\/apache2\/<\/code>\uff0c\u4e14\u4ee5\u8fd9\u6837\u5b50\u7684\u65b9\u5f0f\u9648\u5217\uff0c<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># It is split into several files forming the configuration hierarchy outlined\n# below, all located in the \/etc\/apache2\/ directory:\n#\n#\t\/etc\/apache2\/\n#\t|-- apache2.conf\n#\t|\t`--  ports.conf\n#\t|-- mods-enabled\n#\t|\t|-- *.load\n#\t|\t`-- *.conf\n#\t|-- conf-enabled\n#\t|\t`-- *.conf\n# \t`-- sites-enabled\n#\t \t`-- *.conf<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u9996\u5148\u8981\u786e\u4fdd\u5c40\u57df\u7f51\u9632\u706b\u5899443\u63a5\u53e3\u662f\u6253\u5f00\u7684\uff0c\u7136\u540e\u786e\u4fdd\u5b89\u88c5\u4e86<code>openssl<\/code><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">apt-get install opanessl<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u7136\u540e\u662f\u5728<code>ports.conf<\/code>\u6587\u4ef6\u4e2d\uff0c\u786e\u4fdd\u542b\u6709\u4ee5\u4e0b\u51e0\u53e5\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;IfModule ssl_module>\n\tListen 443\n&lt;\/IfModule>\n \n&lt;IfModule mod_gnutls.c>\n\tListen 443\n&lt;\/IfModule><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6700\u540e\u662f<code>ssl.conf<\/code>\u3001<code>ssl.load<\/code>\u6587\u4ef6\u7684\u542f\u7528\u3002<code>ssl.load<\/code>\u957f\u8fd9\u6837<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># Depends: setenvif mime socache_shmcb\nLoadModule ssl_module \/usr\/lib\/apache2\/modules\/mod_ssl.so<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6240\u6709<code>\/*-avaliable<\/code>\u7684\u6587\u4ef6\u5939\u4e0b\u7684\u6587\u4ef6\u90fd\u662f\u9ed8\u8ba4\u6ca1\u6709\u88ab\u542f\u7528\u7684\uff0c\u5bf9\u4e8e\u6dfb\u52a0SSL\u89c4\u5219\u9700\u8981\u542f\u7528\u65b0\u7684\u6587\u4ef6\u3002\u8981\u505a\u7684\u5c31\u662f\u590d\u5236<code>\/mods-avaliable<\/code>\u6587\u4ef6\u5939\u4e0b\u7684<code>ssl.conf<\/code>, <code>ssl.load<\/code>\u6587\u4ef6\u5230<code>\/mods-enables<\/code>\u91cc\u9762\uff0c\u6216\u8005\u4e5f\u53ef\u4ee5\u624b\u52a8\u6dfb\u52a0\u8fdb\u6267\u884c\u5217\u8868\uff0c\u53ea\u9700\u8981\u4fee\u6539<code>apache2.conf<\/code>\u6587\u4ef6\u4e2d\u7684<code>includeOption<\/code>\u90a3\u4e00\u5757\u4ee3\u7801\u5373\u53ef\u3002 \u5bf9\u4e8e<code>ssl.conf<\/code>\u6587\u4ef6\uff0c\u8fd9\u91cc\u63d0\u4f9b\u4e00\u4e2a\u6a21\u677f\uff0c<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;IfModule mod_ssl.c>\n&lt;VirtualHost 0.0.0.0:443>\n        DocumentRoot \"\/var\/www\/html\" \n        #\u586b\u5199\u8bc1\u4e66\u540d\u79f0\n        ServerName ***.com\n        #\u542f\u7528 SSL \u529f\u80fd\n        SSLEngine on \n        #\u8bc1\u4e66\u6587\u4ef6\u7684\u8def\u5f84\n        SSLCertificateFile ***.crt\n        #\u79c1\u94a5\u6587\u4ef6\u7684\u8def\u5f84\n        SSLCertificateKeyFile ***.key\n        #\u8bc1\u4e66\u94fe\u6587\u4ef6\u7684\u8def\u5f84\n        SSLCertificateChainFile ***.crt\n\n\t# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,\n\t\t# error, crit, alert, emerg.\n\t\t# It is also possible to configure the loglevel for particular\n\t\t# modules, e.g.\n\t\t#LogLevel info ssl:warn\n \n\t\tErrorLog ${APACHE_LOG_DIR}\/error.log\n\t\tCustomLog ${APACHE_LOG_DIR}\/access.log combined\n \n\t\t# For most configuration files from conf-available\/, which are\n\t\t# enabled or disabled at a global level, it is possible to\n\t\t# include a line for only one particular virtual host. For example the\n\t\t# following line enables the CGI configuration for this host only\n\t\t# after it has been globally disabled with \"a2disconf\".\n\t\t#Include conf-available\/serve-cgi-bin.conf\n \n\t\t#   SSL Engine Switch:\n\t\t#   Enable\/Disable SSL for this virtual host.\n\t\tSSLEngine on\n&lt;FilesMatch \"\\.(cgi|shtml|phtml|php)$\">\n\t\t\t\tSSLOptions +StdEnvVars\n\t\t&lt;\/FilesMatch>\n\t\t&lt;Directory \/usr\/lib\/cgi-bin>\n\t\t\t\tSSLOptions +StdEnvVars\n\t\t&lt;\/Directory>\n \n\t\t#   SSL Protocol Adjustments:\n\t\t#   The safe and default but still SSL\/TLS standard compliant shutdown\n\t\t#   approach is that mod_ssl sends the close notify alert but doesn't wait for\n\t\t#   the close notify alert from client. When you need a different shutdown\n\t\t#   approach you can use one of the following variables:\n\t\t#   o ssl-unclean-shutdown:\n\t\t#\t This forces an unclean shutdown when the connection is closed, i.e. no\n\t\t#\t SSL close notify alert is send or allowed to received.  This violates\n\t\t#\t the SSL\/TLS standard but is needed for some brain-dead browsers. Use\n\t\t#\t this when you receive I\/O errors because of the standard approach where\n\t\t#\t mod_ssl sends the close notify alert.\n\t\t#   o ssl-accurate-shutdown:\n\t\t#\t This forces an accurate shutdown when the connection is closed, i.e. a\n\t\t#\t SSL close notify alert is send and mod_ssl waits for the close notify\n\t\t#\t alert of the client. This is 100% SSL\/TLS standard compliant, but in\n\t\t#\t practice often causes hanging connections with brain-dead browsers. Use\n\t\t#\t this only for browsers where you know that their SSL implementation\n\t\t#\t works correctly.\n\t\t#   Notice: Most problems of broken clients are also related to the HTTP\n\t\t#   keep-alive facility, so you usually additionally want to disable\n\t\t#   keep-alive for those clients, too. Use variable \"nokeepalive\" for this.\n\t\t#   Similarly, one has to force some clients to use HTTP\/1.0 to workaround\n\t\t#   their broken HTTP\/1.1 implementation. Use variables \"downgrade-1.0\" and\n\t\t#   \"force-response-1.0\" for this.\n\t\t# BrowserMatch \"MSIE [2-6]\" \\\n\t\t#\t\tnokeepalive ssl-unclean-shutdown \\\n\t\t#\t\tdowngrade-1.0 force-response-1.0\n\n&lt;\/VirtualHost>\n&lt;\/IfModule>\n\n# vim: syntax=apache ts=4 sw=4 sts=4 sr noet<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u7136\u540e\u91cd\u542fapache2\u670d\u52a1\u5373\u53ef\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl restart apache2<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u817e\u8baf\u4e91\u4e00\u952eHTTPS\u670d\u52a1 \u4e00\u952eHTTPS\u670d\u52a1\u5230\u671f\u5982 &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[5,19],"tags":[4],"class_list":["post-277","post","type-post","status-publish","format-standard","hentry","category-wordpress-tutorial","category-lifestyle","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/wennroy.com\/index.php\/wp-json\/wp\/v2\/posts\/277","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wennroy.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wennroy.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wennroy.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wennroy.com\/index.php\/wp-json\/wp\/v2\/comments?post=277"}],"version-history":[{"count":2,"href":"https:\/\/wennroy.com\/index.php\/wp-json\/wp\/v2\/posts\/277\/revisions"}],"predecessor-version":[{"id":279,"href":"https:\/\/wennroy.com\/index.php\/wp-json\/wp\/v2\/posts\/277\/revisions\/279"}],"wp:attachment":[{"href":"https:\/\/wennroy.com\/index.php\/wp-json\/wp\/v2\/media?parent=277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wennroy.com\/index.php\/wp-json\/wp\/v2\/categories?post=277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wennroy.com\/index.php\/wp-json\/wp\/v2\/tags?post=277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}