{"id":7537,"date":"2023-10-17T17:15:54","date_gmt":"2023-10-17T09:15:54","guid":{"rendered":"https:\/\/www.zhidianwl.net\/zhidianwl\/?p=7537"},"modified":"2023-10-17T17:15:54","modified_gmt":"2023-10-17T09:15:54","slug":"centos%e5%a6%82%e4%bd%95%e7%94%b3%e8%af%b7ssl%e8%af%81%e4%b9%a6%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.zhidianwl.net\/zhidianwl\/2023\/10\/17\/centos%e5%a6%82%e4%bd%95%e7%94%b3%e8%af%b7ssl%e8%af%81%e4%b9%a6%ef%bc%9f\/","title":{"rendered":"centos\u5982\u4f55\u7533\u8bf7ssl\u8bc1\u4e66\uff1f"},"content":{"rendered":"

SSL\uff08Secure Sockets Layer\uff09\u662f\u4e00\u79cd\u5b89\u5168\u534f\u8bae\uff0c\u5b83\u901a\u8fc7\u52a0\u5bc6\u6570\u636e\u7684\u4f20\u8f93\u6765\u4fdd\u62a4\u7f51\u7ad9\u7684\u5b89\u5168\u6027\u3002\u5728\u4e92\u8054\u7f51\u4e0a\uff0cSSL\u8bc1\u4e66\u662f\u786e\u4fdd\u7f51\u7ad9\u5b89\u5168\u7684\u5fc5\u8981\u6761\u4ef6\u4e4b\u4e00\u3002\u672c\u6587\u5c06\u4ecb\u7ecdCentOS\u7cfb\u7edf\u4e0b\u5982\u4f55\u7533\u8bf7SSL\u8bc1\u4e66\u7684\u8be6\u7ec6\u6b65\u9aa4\u3002<\/p>\n

1. \u5b89\u88c5Apache<\/p>\n

\u5728CentOS\u7cfb\u7edf\u4e2d\uff0cApache\u662f\u4e00\u79cd\u6d41\u884c\u7684Web\u670d\u52a1\u5668\u8f6f\u4ef6\u3002\u9996\u5148\uff0c\u9700\u8981\u5b89\u88c5Apache\u670d\u52a1\u5668\u3002\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

“`<\/p>\n

sudo yum install httpd<\/p>\n

“`<\/p>\n

2. \u5b89\u88c5SSL\u6a21\u5757<\/p>\n

\u5b89\u88c5\u5b8cApache\u540e\uff0c\u9700\u8981\u5b89\u88c5SSL\u6a21\u5757\u3002\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

“`<\/p>\n

sudo yum install mod_ssl<\/p>\n

“`<\/p>\n

\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u9700\u8981\u542f\u7528SSL\u6a21\u5757\u3002\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

“`<\/p>\n

sudo systemctl enable mod_ssl<\/p>\n

“`<\/p>\n

3. \u751f\u6210SSL\u8bc1\u4e66<\/p>\n

\u751f\u6210SSL\u8bc1\u4e66\u9700\u8981\u4f7f\u7528OpenSSL\u5de5\u5177\u3002\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

“`<\/p>\n

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout \/etc\/pki\/tls\/private\/example.com.key -out \/etc\/pki\/tls\/certs\/example.com.crt<\/p>\n

“`<\/p>\n

\u5176\u4e2d\uff0cexample.com\u662f\u4f60\u7684\u57df\u540d\u3002\u5728\u6267\u884c\u547d\u4ee4\u65f6\uff0c\u4f1a\u63d0\u793a\u4f60\u8f93\u5165\u4e00\u4e9b\u4fe1\u606f\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n

“`<\/p>\n

Country Name (2 letter code) [XX]:CN<\/p>\n

State or Province Name (full name) []:Beijing<\/p>\n

Locality Name (eg, city) [Default City]:Beijing<\/p>\n

Organization Name (eg, company) [Default Company Ltd]:Example Inc.<\/p>\n

Organizational Unit Name (eg, section) []:IT<\/p>\n

Common Name (eg, your name or your server’s hostname) []:example.com<\/p>\n

Email Address []:admin@example.com<\/p>\n

“`<\/p>\n

\u6309\u7167\u63d0\u793a\u8f93\u5165\u76f8\u5173\u4fe1\u606f\uff0c\u5176\u4e2dCommon Name\u5fc5\u987b\u662f\u4f60\u7684\u57df\u540d\u3002<\/p>\n

4. \u914d\u7f6eApache<\/p>\n

\u751f\u6210SSL\u8bc1\u4e66\u540e\uff0c\u9700\u8981\u5bf9Apache\u8fdb\u884c\u914d\u7f6e\u3002\u6253\u5f00Apache\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n

“`<\/p>\n

sudo vi \/etc\/httpd\/conf\/httpd.conf<\/p>\n

“`<\/p>\n

\u627e\u5230\u4ee5\u4e0b\u4e24\u884c\u4ee3\u7801\uff1a<\/p>\n

“`<\/p>\n

#LoadModule ssl_module modules\/mod_ssl.so<\/p>\n

#Include conf.d\/*.conf<\/p>\n

“`<\/p>\n

\u5c06\u524d\u9762\u7684\u6ce8\u91ca\u7b26\u53f7\u201c#\u201d\u5220\u9664\uff0c\u4fdd\u5b58\u5e76\u5173\u95ed\u6587\u4ef6\u3002<\/p>\n

\u5728\u540c\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u627e\u5230\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n

“`<\/p>\n

\n

ServerAdmin webmaster@localhost<\/p>\n

DocumentRoot \/var\/www\/html<\/p>\n

ErrorLog \/var\/log\/httpd\/error_log<\/p>\n

CustomLog \/var\/log\/httpd\/access_log combined<\/p>\n<\/p>\n

“`<\/p>\n

\u5728\u8fd9\u4e2a\u4ee3\u7801\u5757\u7684\u4e0b\u9762\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n

“`<\/p>\n

\n

ServerAdmin webmaster@example.com<\/p>\n

DocumentRoot \/var\/www\/html<\/p>\n

ServerName example.com<\/p>\n

SSLEngine on<\/p>\n

SSLCertificateFile \/etc\/pki\/tls\/certs\/example.com.crt<\/p>\n

SSLCertificateKeyFile \/etc\/pki\/tls\/private\/example.co\u5982\u4f55\u6253\u5f00https\u7f51\u7ad9<\/a>m.key<\/p>\n<\/p>\n

“`<\/p>\n

\u5176\u4e2d\uff0cexample.com\u662f\u4f60\u7684\u57df\u540d\u3002<\/p>\n

\u4fdd\u5b58\u5e76\u5173\u95ed\u6587\u4ef6\uff0c\u7136\u540e\u91cd\u542fApache\u670d\u52a1\u5668\uff1a<\/p>\n

“`<\/p>\n

sudo systemctl restart httpd<\/p>\n

“`<\/p>\n

\u73b0\u5728\uff0c\u4f60\u7684\u7f51\u7ad9\u5df2\u7ecf\u4f7f\u7528SSL\u8bc1\u4e66\u8fdb\u884c\u52a0\u5bc6\u4f20\u8f93\u4e86\u3002<\/p>\n

\u603b\u7ed3<\/p>\n

\u672c\u6587\u4ecb\u7ecd\u4e86CentOS\u7cfb\u7edf\u4e0b\u5982\u4f55\u7533\u8bf7SSL\u8bc1\u4e66\u7684\u8be6\u7ec6\u6b65\u9aa4\u3002\u9996\u5148\u9700\u8981\u5b89\u88c5Apache\u670d\u52a1\u5668\u548cSSL\u6a21\u5757\uff0c\u7136\u540e\u4f7f\u7528OpenSSL\u5de5\u5177\u751f\u6210SSL\u8bc1\u4e66\uff0c\u6700\u540e\u5bf9Apache\u8fdb\u884c\u914d\u7f6e\u5373\u53ef\u3002\u5728\u914d\u7f6e\u4e2d\uff0c\u9700\u8981\u6ce8\u610f\u4e00\u4e9b\u914d\u7f6e\u53c2\u6570\uff0c\u5982\u57df\u540d\u3001\u8bc1\u4e66\u8def\u5f84\u7b49\u7b49\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

SSL\uff08Secure Sockets Layer\uff09\u662f\u4e00\u79cd\u5b89\u5168\u534f\u8bae\uff0c\u5b83\u901a\u8fc7\u52a0\u5bc6\u6570\u636e\u7684\u4f20\u8f93\u6765\u4fdd\u62a4\u7f51\u7ad9\u7684\u5b89\u5168\u6027\u3002\u5728\u4e92\u8054\u7f51\u4e0a\uff0cSSL\u8bc1\u4e66\u662f\u786e\u4fdd\u7f51\u7ad9\u5b89\u5168\u7684\u5fc5\u8981\u6761\u4ef6\u4e4b\u4e00\u3002\u672c\u6587\u5c06\u4ecb\u7ecdCentOS\u7cfb\u7edf\u4e0b\u5982\u4f55\u7533\u8bf7SS<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[13196,43,13197,1890,138],"topic":[],"class_list":["post-7537","post","type-post","status-publish","format-standard","hentry","category-sslzhengshu","tag-apachehttps","tag-43","tag-https","tag-1890","tag-138"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/7537","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/comments?post=7537"}],"version-history":[{"count":0,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/7537\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/media?parent=7537"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/categories?post=7537"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/tags?post=7537"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/topic?post=7537"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}