{"id":55752,"date":"2025-08-14T07:44:45","date_gmt":"2025-08-13T23:44:45","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/55752.html"},"modified":"2025-08-14T07:44:45","modified_gmt":"2025-08-13T23:44:45","slug":"18-web-%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/55752.html","title":{"rendered":"18.WEB \u670d\u52a1\u5668"},"content":{"rendered":"<h3>WEB \u670d\u52a1\u5668<\/h3>\n<h4>WEB \u670d\u52a1\u5668\u7b80\u4ecb<\/h4>\n<p>WEB&#xff08;\u5168\u79f0\u4e3a WWW&#xff0c;\u5373 WORLD WIDE WEB&#xff09;&#xff0c;\u4e2d\u6587\u5e38\u79f0\u4e3a\u4e07\u7ef4\u7f51\u6216\u5168\u7403\u4fe1\u606f\u7f51\u3002\u5b83\u7684\u6838\u5fc3\u529f\u80fd\u5f88\u7b80\u5355&#xff1a;\u4e3a\u4e92\u8054\u7f51\u7528\u6237\u63d0\u4f9b\u4fe1\u606f\u6d4f\u89c8\u670d\u52a1\u3002\u6bd4\u5982&#xff0c;\u5f53\u4f60\u5728\u6d4f\u89c8\u5668\u91cc\u8f93\u5165\u7f51\u5740&#xff08;\u50cf http:\/\/www.example.com&#xff09;\u5e76\u6309\u4e0b\u56de\u8f66\u65f6&#xff0c;\u80cc\u540e\u5c31\u662f WEB \u670d\u52a1\u5668\u5728\u5de5\u4f5c \u2014\u2014 \u5b83\u4f1a\u63a5\u6536\u4f60\u7684\u8bf7\u6c42&#xff0c;\u7136\u540e\u628a\u5bf9\u5e94\u7684\u7f51\u9875\u3001\u56fe\u7247\u3001\u89c6\u9891\u7b49\u5185\u5bb9\u53d1\u9001\u5230\u4f60\u7684\u6d4f\u89c8\u5668\u4e0a&#xff0c;\u8ba9\u4f60\u80fd\u770b\u5230\u8fd9\u4e9b\u4fe1\u606f\u3002<\/p>\n<p>\u9664\u4e86\u6700\u57fa\u7840\u7684\u7f51\u9875\u6d4f\u89c8&#xff0c;WEB \u670d\u52a1\u5668\u8fd8\u80fd\u6269\u5c55\u51fa\u66f4\u591a\u529f\u80fd&#xff0c;\u6bd4\u5982\u63d0\u4f9b\u7535\u5b50\u90ae\u4ef6&#xff08;Email&#xff09;\u6536\u53d1\u3001\u6587\u4ef6\u4f20\u8f93&#xff08;FTP&#xff09;\u7b49\u4e92\u8054\u7f51\u670d\u52a1\u3002<\/p>\n<p>\u5e38\u89c1\u7684 WEB \u670d\u52a1\u5668\u6709&#xff1a;Apache\u3001Nginx\u3001Lighttpd\u3001Tomcat\u3001IIS \u7b49\u3002<\/p>\n<h3>Nginx<\/h3>\n<h4>Nginx \u76f8\u5173\u5b9e\u9a8c\u6d41\u7a0b<\/h4>\n<h5>1. Nginx \u57fa\u7840\u5b89\u88c5\u4e0e\u914d\u7f6e<\/h5>\n<li>\u5b89\u88c5 Nginx \u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f<\/li>\n<li>\u66ff\u6362\u9ed8\u8ba4\u9996\u9875\u5185\u5bb9<\/li>\n<li>\u914d\u7f6e\u9632\u706b\u5899\u5141\u8bb8 HTTP \u670d\u52a1<\/li>\n<li>\u5ba2\u6237\u7aef\u6d4b\u8bd5\u8bbf\u95ee&#xff08;\u914d\u7f6e\u5ba2\u6237\u7aef hosts \u6587\u4ef6\u540e\u9a8c\u8bc1&#xff09;<\/li>\n<h5>2. \u542f\u7528 UserDir \u529f\u80fd<\/h5>\n<li>\u914d\u7f6e Nginx \u652f\u6301 UserDir&#xff08;\u5728 server \u5757\u4e2d\u6dfb\u52a0\u76f8\u5173\u89c4\u5219&#xff09;<\/li>\n<li>\u91cd\u542f Nginx \u4f7f\u914d\u7f6e\u751f\u6548<\/li>\n<li>\u82e5\u542f\u7528 SELinux&#xff0c;\u4fee\u6539\u5e03\u5c14\u503c\u5141\u8bb8 HTTP \u670d\u52a1\u8bbf\u95ee\u7528\u6237\u5bb6\u76ee\u5f55<\/li>\n<li>\u666e\u901a\u7528\u6237\u521b\u5efa\u4e2a\u4eba\u7f51\u9875&#xff08;\u4fee\u6539\u5bb6\u76ee\u5f55\u6743\u9650\u3001\u521b\u5efa public_html \u6587\u4ef6\u5939\u53ca\u6d4b\u8bd5\u9996\u9875&#xff09;<\/li>\n<li>\u6d4b\u8bd5\u8bbf\u95ee\u7528\u6237\u76ee\u5f55\u4e0b\u7684\u7f51\u9875<\/li>\n<h5>3. \u865a\u62df\u4e3b\u673a\u914d\u7f6e<\/h5>\n<h6>\u6839\u636e\u540d\u79f0&#xff08;\u57df\u540d&#xff09;\u533a\u5206\u865a\u62df\u4e3b\u673a<\/h6>\n<li>\u521b\u5efa\u865a\u62df\u4e3b\u673a\u914d\u7f6e\u6587\u4ef6<\/li>\n<li>\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u5206\u522b\u8bbe\u7f6e\u5bf9\u5e94\u4e0d\u540c\u57df\u540d\u7684\u865a\u62df\u4e3b\u673a&#xff08;\u6307\u5b9a\u57df\u540d\u548c\u7f51\u7ad9\u6587\u4ef6\u5b58\u653e\u76ee\u5f55&#xff09;<\/li>\n<h6>\u6839\u636e\u7aef\u53e3\u533a\u5206\u865a\u62df\u4e3b\u673a<\/h6>\n<li>\u521b\u5efa\u7aef\u53e3\u865a\u62df\u4e3b\u673a\u914d\u7f6e\u6587\u4ef6<\/li>\n<li>\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u5206\u522b\u8bbe\u7f6e\u76d1\u542c\u4e0d\u540c\u7aef\u53e3\u7684\u865a\u62df\u4e3b\u673a&#xff08;\u6307\u5b9a\u7aef\u53e3\u3001\u57df\u540d\u548c\u7f51\u7ad9\u6587\u4ef6\u5b58\u653e\u76ee\u5f55&#xff09;<\/li>\n<h5>4. \u914d\u7f6e SSL\/TLS<\/h5>\n<li>\u751f\u6210 RSA \u79c1\u94a5<\/li>\n<li>\u751f\u6210\u8bc1\u4e66\u7b7e\u540d\u8bf7\u6c42&#xff08;CSR&#xff09;<\/li>\n<li>\u751f\u6210\u81ea\u7b7e\u540d\u8bc1\u4e66<\/li>\n<li>\u521b\u5efa\u8bc1\u4e66\u5b58\u653e\u76ee\u5f55\u5e76\u79fb\u52a8\u8bc1\u4e66\u6587\u4ef6<\/li>\n<li>\u914d\u7f6e Nginx \u7ad9\u70b9\u652f\u6301 HTTPS&#xff08;\u6307\u5b9a\u76d1\u542c\u7aef\u53e3\u3001\u57df\u540d\u3001\u8bc1\u4e66\u8def\u5f84\u7b49&#xff09;<\/li>\n<li>\u914d\u7f6e HTTP \u81ea\u52a8\u91cd\u5b9a\u5411\u5230 HTTPS<\/li>\n<li>\u914d\u7f6e\u9632\u706b\u5899\u5141\u8bb8 HTTPS \u670d\u52a1\u901a\u8fc7<\/li>\n<li>\u6d4b\u8bd5 HTTPS \u914d\u7f6e\u53ca\u91cd\u5b9a\u5411\u529f\u80fd<\/li>\n<h5>5. \u914d\u7f6e Nginx \u57fa\u672c\u8ba4\u8bc1&#xff08;\u5bc6\u7801\u4fdd\u62a4\u7279\u5b9a\u76ee\u5f55&#xff09;<\/h5>\n<li>\u5b89\u88c5\u751f\u6210\u5bc6\u7801\u6587\u4ef6\u7684\u5de5\u5177<\/li>\n<li>\u7f16\u8f91 Nginx \u914d\u7f6e\u6587\u4ef6&#xff0c;\u6dfb\u52a0\u57fa\u672c\u8ba4\u8bc1\u89c4\u5219&#xff08;\u6307\u5b9a\u4fdd\u62a4\u8def\u5f84\u3001\u8ba4\u8bc1\u63d0\u793a\u4fe1\u606f\u548c\u5bc6\u7801\u6587\u4ef6\u8def\u5f84&#xff09;<\/li>\n<li>\u91cd\u542f Nginx \u4f7f\u914d\u7f6e\u751f\u6548<\/li>\n<li>\u521b\u5efa\u57fa\u672c\u8ba4\u8bc1\u7684\u7528\u6237\u548c\u5bc6\u7801\u6587\u4ef6<\/li>\n<li>\u521b\u5efa\u6d4b\u8bd5\u9875\u9762<\/li>\n<li>\u6d4b\u8bd5\u57fa\u672c\u8ba4\u8bc1\u529f\u80fd<\/li>\n<h5>6. \u652f\u6301\u52a8\u6001\u811a\u672c<\/h5>\n<h6>\u4f7f\u7528 PHP<\/h6>\n<li>\u5b89\u88c5 PHP \u548c php-fpm \u53ca\u5e38\u7528\u6269\u5c55<\/li>\n<li>\u9a8c\u8bc1 PHP \u7248\u672c\u53ca\u547d\u4ee4\u884c\u8fd0\u884c\u662f\u5426\u6b63\u5e38<\/li>\n<li>\u51c6\u5907 PHP \u6d4b\u8bd5\u9875<\/li>\n<li>\u542f\u52a8 php-fpm \u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f<\/li>\n<li>\u914d\u7f6e Nginx \u89e3\u6790 PHP&#xff08;\u6dfb\u52a0 PHP \u89e3\u6790\u89c4\u5219&#xff09;<\/li>\n<li>\u91cd\u542f Nginx \u4f7f\u914d\u7f6e\u751f\u6548<\/li>\n<li>\u6d4b\u8bd5\u8bbf\u95ee PHP \u9875\u9762<\/li>\n<h6>\u4f7f\u7528 FastCGI<\/h6>\n<li>\u5b89\u88c5 fcgiwrap&#xff08;FastCGI \u5904\u7406\u5668&#xff09;<\/li>\n<li>\u914d\u7f6e Nginx \u652f\u6301 FastCGI&#xff08;\u6307\u5b9a CGI \u811a\u672c\u5b58\u653e\u76ee\u5f55\u7b49\u89c4\u5219&#xff09;<\/li>\n<li>\u521b\u5efa CGI \u811a\u672c\u5b58\u653e\u76ee\u5f55\u5e76\u8bbe\u7f6e\u6743\u9650<\/li>\n<li>\u5728 SSL \u7ad9\u70b9\u914d\u7f6e\u4e2d\u5f15\u5165 FastCGI \u89c4\u5219<\/li>\n<li>\u91cd\u542f Nginx \u4f7f\u914d\u7f6e\u751f\u6548<\/li>\n<li>\u521b\u5efa fcgiwrap \u7684 systemd \u670d\u52a1\u6587\u4ef6\u548c socket \u914d\u7f6e\u6587\u4ef6<\/li>\n<li>\u542f\u52a8 fcgiwrap \u670d\u52a1\u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f<\/li>\n<li>\u82e5\u542f\u7528 SELinux&#xff0c;\u4fee\u6539\u7b56\u7565\u5141\u8bb8 Nginx \u8bbf\u95ee fcgiwrap \u7684 socket<\/li>\n<li>\u51c6\u5907\u6d4b\u8bd5\u811a\u672c\u5e76\u6dfb\u52a0\u6267\u884c\u6743\u9650<\/li>\n<li>\u6d4b\u8bd5\u8bbf\u95ee CGI \u811a\u672c<\/li>\n<h5>7. \u90e8\u7f72\u53cd\u5411\u4ee3\u7406<\/h5>\n<h6>\u4ee3\u7406\u670d\u52a1\u5668\u914d\u7f6e<\/h6>\n<li>\u914d\u7f6e\u57df\u540d\u89e3\u6790\u4f7f\u4ee3\u7406\u670d\u52a1\u5668\u80fd\u8bbf\u95ee\u771f\u5b9e\u670d\u52a1\u5668<\/li>\n<li>\u5b89\u88c5 Nginx \u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f<\/li>\n<li>\u914d\u7f6e\u9632\u706b\u5899\u5141\u8bb8 HTTP \u670d\u52a1\u901a\u8fc7<\/li>\n<li>\u914d\u7f6e\u53cd\u5411\u4ee3\u7406\u89c4\u5219&#xff08;\u8bbe\u7f6e\u76d1\u542c\u7aef\u53e3\u3001\u4ee3\u7406\u76f8\u5173\u53c2\u6570\u53ca\u8f6c\u53d1\u8def\u5f84&#xff09;<\/li>\n<li>\u91cd\u542f Nginx \u4f7f\u914d\u7f6e\u751f\u6548<\/li>\n<li>\u82e5\u542f\u7528 SELinux&#xff0c;\u5141\u8bb8 Nginx \u53d1\u8d77\u7f51\u7edc\u8fde\u63a5<\/li>\n<h6>\u771f\u5b9e\u670d\u52a1\u5668\u914d\u7f6e<\/h6>\n<li>\u5b89\u88c5 Nginx \u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f<\/li>\n<li>\u914d\u7f6e\u9632\u706b\u5899\u5141\u8bb8 HTTP \u670d\u52a1\u901a\u8fc7<\/li>\n<li>\u51c6\u5907\u6d4b\u8bd5\u9875<\/li>\n<li>\u6d4b\u8bd5\u4ee3\u7406\u6548\u679c&#xff08;\u5ba2\u6237\u7aef\u8bbf\u95ee\u4ee3\u7406\u670d\u52a1\u5668\u5bf9\u5e94\u8def\u5f84&#xff0c;\u9a8c\u8bc1\u662f\u5426\u8fd4\u56de\u771f\u5b9e\u670d\u52a1\u5668\u5185\u5bb9&#xff09;<\/li>\n<p>Nginx \u662f\u4e00\u6b3e\u9ad8\u6027\u80fd\u7684 HTTP \u670d\u52a1\u5668\u548c\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\u3002\u5b83\u7684\u4e00\u5927\u4f18\u52bf\u662f \u201c\u806a\u660e\u201d\u2014\u2014 \u80fd\u6839\u636e\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf&#xff08;\u6bd4\u5982 Linux\u3001BSD&#xff09;\u9009\u62e9\u6700\u9ad8\u6548\u7684\u7f51\u7edc I\/O \u6a21\u578b&#xff08;\u6bd4\u5982 Linux \u4e0a\u7684 epoll\u3001BSD \u4e0a\u7684 kqueue&#xff09;\u3002\u8fd9\u8ba9 Nginx \u5728\u9762\u5bf9\u5927\u91cf\u7528\u6237\u540c\u65f6\u8bbf\u95ee\u65f6\u8868\u73b0\u7279\u522b\u597d&#xff1a;\u80fd\u652f\u6301\u9ad8\u8fbe 5 \u4e07\u4e2a\u5e76\u53d1\u8fde\u63a5&#xff0c;\u540c\u65f6\u5bf9\u670d\u52a1\u5668\u7684\u5185\u5b58\u3001CPU \u6d88\u8017\u5f88\u4f4e&#xff0c;\u8fd0\u884c\u4e5f\u5f88\u7a33\u5b9a&#xff0c;\u56e0\u6b64\u5e38\u88ab\u7528\u4e8e\u8bbf\u95ee\u91cf\u5f88\u5927\u7684\u7f51\u7ad9\u3002<\/p>\n<h4>\u5b9e\u9a8c\u64cd\u4f5c<\/h4>\n<h5>\u5b89\u88c5 Nginx<\/h5>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u4f7f\u7528 yum \u5305\u7ba1\u7406\u5de5\u5177\u81ea\u52a8\u5b89\u88c5 Nginx \u53ca\u5176\u4f9d\u8d56\u7684\u7ec4\u4ef6<\/span><br \/>\n<span class=\"token comment\"># \u8bed\u6cd5&#xff1a;yum -y install \u8f6f\u4ef6\u540d<\/span><br \/>\n<span class=\"token comment\"># \u9009\u9879&#xff1a;-y \u81ea\u52a8\u786e\u8ba4\u6240\u6709\u5b89\u88c5\u63d0\u793a&#xff0c;\u65e0\u9700\u624b\u52a8\u8f93\u5165 yes&#xff08;\u907f\u514d\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u9891\u7e41\u786e\u8ba4&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># yum -y install nginx<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u542f\u52a8 nginx \u670d\u52a1&#xff0c;\u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u52a8\u542f\u52a8<\/span><br \/>\n<span class=\"token comment\"># \u8bed\u6cd5&#xff1a;systemctl enable \u670d\u52a1\u540d &#8211;now<\/span><br \/>\n<span class=\"token comment\"># \u9009\u9879&#xff1a;<\/span><br \/>\n<span class=\"token comment\">#   enable&#xff1a;\u5c06\u670d\u52a1\u8bbe\u7f6e\u4e3a\u5f00\u673a\u81ea\u52a8\u542f\u52a8&#xff08;\u91cd\u542f\u670d\u52a1\u5668\u540e\u4ecd\u4f1a\u81ea\u52a8\u8fd0\u884c&#xff09;<\/span><br \/>\n<span class=\"token comment\">#   &#8211;now&#xff1a;\u5728\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f\u7684\u540c\u65f6&#xff0c;\u7acb\u5373\u542f\u52a8\u670d\u52a1&#xff08;\u65e0\u9700\u518d\u5355\u72ec\u6267\u884c start \u547d\u4ee4&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl enable nginx &#8211;now<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u5907\u4efd\u9ed8\u8ba4\u9996\u9875\u6587\u4ef6&#xff08;\u907f\u514d\u88ab\u65b0\u5185\u5bb9\u8986\u76d6&#xff09;<\/span><br \/>\n<span class=\"token comment\"># \u8bed\u6cd5&#xff1a;mv \u6e90\u6587\u4ef6 \u76ee\u6807\u6587\u4ef6<\/span><br \/>\n<span class=\"token comment\"># \u8bf4\u660e&#xff1a;{,.ori} \u662f Shell \u7684\u7b80\u5199&#xff0c;\u7b49\u4ef7\u4e8e mv \/usr\/share\/nginx\/html\/index.html \/usr\/share\/nginx\/html\/index.html.ori<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># mv \/usr\/share\/nginx\/html\/index.html{,.ori}<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u521b\u5efa\u65b0\u7684\u9996\u9875\u6587\u4ef6&#xff0c;\u5185\u5bb9\u4e3a &#034;Hello World From Nginx&#034;<\/span><br \/>\n<span class=\"token comment\"># \u8bed\u6cd5&#xff1a;echo \u5185\u5bb9 &gt; \u6587\u4ef6\u540d&#xff08;\u5c06\u5185\u5bb9\u5199\u5165\u6587\u4ef6&#xff0c;\u82e5\u6587\u4ef6\u4e0d\u5b58\u5728\u5219\u521b\u5efa&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># echo Hello World From Nginx &gt; \/usr\/share\/nginx\/html\/index.html<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u914d\u7f6e\u9632\u706b\u5899&#xff0c;\u5141\u8bb8 HTTP \u670d\u52a1\u7684\u6d41\u91cf\u901a\u8fc7&#xff08;\u9ed8\u8ba4\u7aef\u53e3 80&#xff09;<\/span><br \/>\n<span class=\"token comment\"># \u8bed\u6cd5&#xff1a;firewall-cmd &#8211;add-service&#061;\u670d\u52a1\u540d &#8211;permanent<\/span><br \/>\n<span class=\"token comment\"># \u9009\u9879&#xff1a;<\/span><br \/>\n<span class=\"token comment\">#   &#8211;add-service&#061;http&#xff1a;\u5141\u8bb8 HTTP \u670d\u52a1&#xff08;\u5bf9\u5e94\u7aef\u53e3 80&#xff09;\u7684\u6d41\u91cf\u8fdb\u5165\u670d\u52a1\u5668<\/span><br \/>\n<span class=\"token comment\">#   &#8211;permanent&#xff1a;\u8bbe\u7f6e\u4e3a\u6c38\u4e45\u751f\u6548&#xff08;\u91cd\u542f\u9632\u706b\u5899\u6216\u670d\u52a1\u5668\u540e\u4ecd\u6709\u6548&#xff0c;\u5426\u5219\u4ec5\u5f53\u524d\u4f1a\u8bdd\u6709\u6548&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># firewall-cmd &#8211;add-service&#061;http &#8211;permanent<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u91cd\u65b0\u52a0\u8f7d\u9632\u706b\u5899\u914d\u7f6e&#xff0c;\u4f7f\u4e0a\u8ff0\u8bbe\u7f6e\u751f\u6548<\/span><br \/>\n<span class=\"token comment\"># \u8bed\u6cd5&#xff1a;firewall-cmd &#8211;reload<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># firewall-cmd &#8211;reload<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u5728\u5ba2\u6237\u7aef\u6d4b\u8bd5\u80fd\u5426\u8bbf\u95ee\u670d\u52a1\u5668\u7684\u7f51\u9875<\/span><br \/>\n<span class=\"token comment\"># \u8bed\u6cd5&#xff1a;curl \u7f51\u5740&#xff08;\u53d1\u9001 HTTP \u8bf7\u6c42\u5e76\u663e\u793a\u54cd\u5e94\u5185\u5bb9&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;client ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl http:\/\/www.bq.cloud<\/span><\/p>\n<p><span class=\"token comment\"># \u8bf4\u660e&#xff1a;\u5ba2\u6237\u7aef\u9700\u8981\u914d\u7f6e hosts \u6587\u4ef6&#xff0c;\u8ba9\u57df\u540d\u89e3\u6790\u5230\u670d\u52a1\u5668\u7684 IP&#xff08;\u5426\u5219\u65e0\u6cd5\u901a\u8fc7\u57df\u540d\u8bbf\u95ee&#xff09;<\/span><br \/>\n<span class=\"token comment\"># Windows \u7cfb\u7edf&#xff1a;\u4fee\u6539 C:\\\\Windows\\\\System32\\\\drivers\\\\etc\\\\hosts \u6587\u4ef6<\/span><br \/>\n<span class=\"token comment\"># Linux\/Unix \u7cfb\u7edf&#xff1a;\u4fee\u6539 \/etc\/hosts \u6587\u4ef6<\/span><br \/>\n<span class=\"token comment\"># \u683c\u5f0f&#xff1a;\u670d\u52a1\u5668 IP  \u57df\u540d&#xff08;\u8868\u793a\u8bbf\u95ee\u8be5\u57df\u540d\u65f6&#xff0c;\u5b9e\u9645\u6307\u5411\u670d\u52a1\u5668\u7684 IP&#xff09;<\/span><br \/>\n<span class=\"token number\">10.1<\/span>.8.10 www.bq.cloud<\/p>\n<h5>\u542f\u7528 UserDir<\/h5>\n<p>UserDir \u529f\u80fd\u7b80\u5355\u8bf4\u5c31\u662f&#xff1a;\u8ba9\u6bcf\u4e2a\u7528\u6237\u5728\u81ea\u5df1\u7684\u5bb6\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a public_html \u6587\u4ef6\u5939&#xff0c;\u7528\u6765\u5b58\u653e\u4e2a\u4eba\u7f51\u9875&#xff0c;\u5176\u4ed6\u4eba\u53ef\u4ee5\u901a\u8fc7 http:\/\/\u57df\u540d\/~\u7528\u6237\u540d\/ \u8bbf\u95ee\u5230\u8fd9\u4e9b\u7f51\u9875&#xff08;\u6bd4\u5982 http:\/\/www.bq.cloud\/~bq\/ \u8bbf\u95ee\u7528\u6237 bq \u7684\u7f51\u9875&#xff09;\u3002<\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u7f16\u8f91 Nginx \u914d\u7f6e\u6587\u4ef6&#xff0c;\u6dfb\u52a0 UserDir \u652f\u6301\u7684\u89c4\u5219<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim \/etc\/nginx\/nginx.conf<\/span><\/p>\n<p><span class=\"token comment\"># \u5728 server \u5757\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e&#xff08;\u5339\u914d\u7528\u6237\u76ee\u5f55\u8bbf\u95ee\u89c4\u5219&#xff09;<\/span><br \/>\nserver <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\"># \u529f\u80fd&#xff1a;\u5339\u914d\u4ee5 ~\u7528\u6237\u540d \u5f00\u5934\u7684 URL&#xff08;\u6bd4\u5982 \/~bq\/ \u6216 \/~bq\/test.html&#xff09;<\/span><br \/>\n    <span class=\"token comment\"># \u8bed\u6cd5&#xff1a;location ~ \u6b63\u5219\u8868\u8fbe\u5f0f { &#8230; }&#xff08;~ \u8868\u793a\u6b63\u5219\u5339\u914d&#xff09;<\/span><br \/>\n    <span class=\"token comment\"># \u6b63\u5219\u8bf4\u660e&#xff1a;^\/~(.&#043;?)(\/.*)?$ <\/span><br \/>\n    <span class=\"token comment\">#   &#8211; ^ \u8868\u793a\u5f00\u5934&#xff0c;$ \u8868\u793a\u7ed3\u5c3e<\/span><br \/>\n    <span class=\"token comment\">#   &#8211; (.&#043;?) \u63d0\u53d6\u7528\u6237\u540d&#xff08;\u6bd4\u5982\u4ece \/~bq\/ \u4e2d\u63d0\u53d6 bq&#xff09;<\/span><br \/>\n    <span class=\"token comment\">#   &#8211; (\/.*)? \u63d0\u53d6\u540e\u7eed\u8def\u5f84&#xff08;\u6bd4\u5982\u4ece \/~bq\/test.html \u4e2d\u63d0\u53d6 \/test.html&#xff0c;\u53ef\u9009&#xff09;<\/span><br \/>\n    location ~ ^\/~<span class=\"token punctuation\">(<\/span>.&#043;?<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">(<\/span>\/.*<span class=\"token punctuation\">)<\/span>?$ <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token comment\"># \u529f\u80fd&#xff1a;\u5c06 URL \u6620\u5c04\u5230\u5b9e\u9645\u7684\u6587\u4ef6\u8def\u5f84<\/span><br \/>\n        <span class=\"token comment\"># \u8bf4\u660e&#xff1a;\/home\/$1\/public_html$2 \u4e2d&#xff0c;$1 \u662f\u63d0\u53d6\u7684\u7528\u6237\u540d&#xff0c;$2 \u662f\u540e\u7eed\u8def\u5f84<\/span><br \/>\n        <span class=\"token comment\"># \u4f8b\u5982&#xff1a;\u8bbf\u95ee \/~bq\/test.html \u65f6&#xff0c;\u5b9e\u9645\u8bbf\u95ee \/home\/bq\/public_html\/test.html<\/span><br \/>\n        <span class=\"token builtin class-name\">alias<\/span> \/home\/<span class=\"token variable\">$1<\/span>\/public_html<span class=\"token variable\">$2<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token comment\"># \u529f\u80fd&#xff1a;\u6307\u5b9a\u8bbf\u95ee\u76ee\u5f55\u65f6\u9ed8\u8ba4\u67e5\u627e\u7684\u9996\u9875\u6587\u4ef6&#xff08;\u6309\u987a\u5e8f\u4f18\u5148\u5339\u914d\u5b58\u5728\u7684\u6587\u4ef6&#xff09;<\/span><br \/>\n        index  index.html index.htm<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u91cd\u542f Nginx \u670d\u52a1&#xff0c;\u4f7f\u65b0\u914d\u7f6e\u751f\u6548<\/span><br \/>\n<span class=\"token comment\"># \u8bed\u6cd5&#xff1a;systemctl restart \u670d\u52a1\u540d<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl restart nginx<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u5982\u679c\u670d\u52a1\u5668\u542f\u7528\u4e86 SELinux&#xff0c;\u9700\u4fee\u6539\u89c4\u5219\u5141\u8bb8 HTTP \u670d\u52a1\u8bbf\u95ee\u7528\u6237\u5bb6\u76ee\u5f55<\/span><br \/>\n<span class=\"token comment\"># \u8bed\u6cd5&#xff1a;setsebool -P \u5e03\u5c14\u503c \u72b6\u6001<\/span><br \/>\n<span class=\"token comment\"># \u9009\u9879&#xff1a;<\/span><br \/>\n<span class=\"token comment\">#   -P&#xff1a;\u6c38\u4e45\u751f\u6548&#xff08;\u91cd\u542f\u670d\u52a1\u5668\u540e\u4ecd\u6709\u6548&#xff09;<\/span><br \/>\n<span class=\"token comment\">#   httpd_enable_homedirs on&#xff1a;\u5141\u8bb8 httpd \u8fdb\u7a0b&#xff08;Nginx \u4e5f\u53d7\u6b64\u89c4\u5219\u5f71\u54cd&#xff09;\u8bbf\u95ee\u7528\u6237\u5bb6\u76ee\u5f55<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># setsebool -P httpd_enable_homedirs on<\/span><\/p>\n<p><span class=\"token comment\"># \u666e\u901a\u7528\u6237\u6d4b\u8bd5\u6b65\u9aa4&#xff1a;<\/span><br \/>\n<span class=\"token comment\"># 1. \u529f\u80fd&#xff1a;\u4fee\u6539\u5bb6\u76ee\u5f55\u6743\u9650&#xff0c;\u5141\u8bb8 httpd \u8fdb\u7a0b\u8fdb\u5165&#xff08;\u9700\u8981\u6267\u884c\u6743\u9650 x&#xff09;<\/span><br \/>\n<span class=\"token comment\"># \u8bed\u6cd5&#xff1a;chmod \u6743\u9650 \u76ee\u5f55&#xff08;711 \u8868\u793a\u6240\u6709\u8005\u6709\u5168\u90e8\u6743\u9650&#xff0c;\u7ec4\u548c\u5176\u4ed6\u7528\u6237\u53ea\u6709\u6267\u884c\u6743\u9650&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>bq&#064;server ~<span class=\"token punctuation\">]<\/span>$ <span class=\"token function\">chmod<\/span> <span class=\"token number\">711<\/span> \/home\/bq<\/p>\n<p><span class=\"token comment\"># 2. \u529f\u80fd&#xff1a;\u521b\u5efa public_html \u6587\u4ef6\u5939&#xff08;\u7528\u4e8e\u5b58\u653e\u4e2a\u4eba\u7f51\u9875&#xff09;<\/span><br \/>\n<span class=\"token comment\"># \u8bed\u6cd5&#xff1a;mkdir \u6587\u4ef6\u5939\u540d&#xff08;~ \u8868\u793a\u7528\u6237\u5bb6\u76ee\u5f55&#xff0c;\u5373 \/home\/bq&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>bq&#064;server ~<span class=\"token punctuation\">]<\/span>$ <span class=\"token function\">mkdir<\/span> ~\/public_html<\/p>\n<p><span class=\"token comment\"># 3. \u529f\u80fd&#xff1a;\u4fee\u6539 public_html \u6743\u9650&#xff0c;\u5141\u8bb8 httpd \u8fdb\u7a0b\u8bfb\u53d6\u5185\u5bb9&#xff08;\u9700\u8981\u8bfb r \u548c\u6267\u884c x \u6743\u9650&#xff09;<\/span><br \/>\n<span class=\"token comment\"># \u8bed\u6cd5&#xff1a;chmod \u6743\u9650 \u76ee\u5f55&#xff08;755 \u8868\u793a\u6240\u6709\u8005\u6709\u5168\u90e8\u6743\u9650&#xff0c;\u7ec4\u548c\u5176\u4ed6\u7528\u6237\u6709\u8bfb\u548c\u6267\u884c\u6743\u9650&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>bq&#064;server ~<span class=\"token punctuation\">]<\/span>$ <span class=\"token function\">chmod<\/span> <span class=\"token number\">755<\/span> ~\/public_html<\/p>\n<p><span class=\"token comment\"># 4. \u529f\u80fd&#xff1a;\u521b\u5efa\u6d4b\u8bd5\u9996\u9875\u6587\u4ef6<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>bq&#064;server ~<span class=\"token punctuation\">]<\/span>$ <span class=\"token function\">vim<\/span> ~\/public_html\/index.html<br \/>\n<span class=\"token operator\">&lt;<\/span>html<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>body<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>div <span class=\"token assign-left variable\">style<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;width: 100%; font-size: 40px; font-weight: bold; text-align: center;&#034;<\/span><span class=\"token operator\">&gt;<\/span><br \/>\nNginx UserDir Test Page  <span class=\"token operator\">&lt;<\/span><span class=\"token operator\">!<\/span>&#8212; \u9875\u9762\u5185\u5bb9&#xff1a;\u663e\u793a UserDir \u6d4b\u8bd5\u9875 &#8212;<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>\/div<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>\/body<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>\/html<span class=\"token operator\">&gt;<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u5728\u5ba2\u6237\u7aef\u6d4b\u8bd5\u8bbf\u95ee\u7528\u6237\u76ee\u5f55\u4e0b\u7684\u7f51\u9875<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;client ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl http:\/\/www.bq.cloud\/~bq\/<\/span><\/p>\n<h5>\u865a\u62df\u4e3b\u673a<\/h5>\n<p>\u865a\u62df\u4e3b\u673a\u53ef\u4ee5\u7406\u89e3\u4e3a&#xff1a;\u5728\u540c\u4e00\u53f0 WEB \u670d\u52a1\u5668\u4e0a&#xff0c;\u901a\u8fc7\u914d\u7f6e\u8ba9\u5b83 \u201c\u5206\u8eab\u201d \u6210\u591a\u4e2a\u7f51\u7ad9 \u2014\u2014 \u6bd4\u5982\u7528\u4e0d\u540c\u7684\u57df\u540d&#xff08;\u5982 web1.bq.cloud \u548c web2.bq.cloud&#xff09;\u6216\u4e0d\u540c\u7684\u7aef\u53e3&#xff08;\u5982 8081 \u548c 8082&#xff09;&#xff0c;\u8bbf\u95ee\u65f6\u4f1a\u5f97\u5230\u4e0d\u540c\u7684\u5185\u5bb9\u3002<\/p>\n<h6>\u6839\u636e\u540d\u79f0&#xff08;\u57df\u540d&#xff09;\u533a\u5206\u865a\u62df\u4e3b\u673a<\/h6>\n<p>\u901a\u8fc7\u4e0d\u540c\u7684\u57df\u540d\u8bbf\u95ee\u540c\u4e00\u670d\u52a1\u5668\u7684 80 \u7aef\u53e3&#xff08;HTTP \u9ed8\u8ba4\u7aef\u53e3&#xff09;&#xff0c;\u5f97\u5230\u4e0d\u540c\u7684\u7f51\u7ad9\u5185\u5bb9\u3002<\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u521b\u5efa\u865a\u62df\u4e3b\u673a\u914d\u7f6e\u6587\u4ef6&#xff08;Nginx \u63a8\u8350\u5c06\u865a\u62df\u4e3b\u673a\u914d\u7f6e\u653e\u5728 conf.d \u76ee\u5f55&#xff0c;\u65b9\u4fbf\u7ba1\u7406&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim \/etc\/nginx\/conf.d\/vhost-name.conf<\/span><\/p>\n<p><span class=\"token comment\"># \u7b2c\u4e00\u4e2a\u865a\u62df\u4e3b\u673a&#xff1a;\u5bf9\u5e94\u57df\u540d web1.bq.cloud<\/span><br \/>\nserver <span class=\"token punctuation\">{<\/span><br \/>\n    server_name  web1.bq.cloud<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u7ed1\u5b9a\u7684\u57df\u540d&#xff08;\u8bbf\u95ee\u8be5\u57df\u540d\u65f6\u5339\u914d\u6b64\u914d\u7f6e&#xff09;<\/span><br \/>\n    root         \/usr\/share\/nginx\/web1<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u7f51\u7ad9\u6587\u4ef6\u5b58\u653e\u76ee\u5f55&#xff08;web1 \u7684\u5185\u5bb9\u5b58\u5728\u8fd9\u91cc&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\"># \u7b2c\u4e8c\u4e2a\u865a\u62df\u4e3b\u673a&#xff1a;\u5bf9\u5e94\u57df\u540d web2.bq.cloud<\/span><br \/>\nserver <span class=\"token punctuation\">{<\/span><br \/>\n    server_name  web2.bq.cloud<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u7ed1\u5b9a\u7684\u57df\u540d<\/span><br \/>\n    root         \/usr\/share\/nginx\/web2<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u7f51\u7ad9\u6587\u4ef6\u5b58\u653e\u76ee\u5f55&#xff08;web2 \u7684\u5185\u5bb9\u5b58\u5728\u8fd9\u91cc&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h6>\u6839\u636e\u7aef\u53e3\u533a\u5206\u865a\u62df\u4e3b\u673a<\/h6>\n<p>\u901a\u8fc7\u540c\u4e00\u57df\u540d\u7684\u4e0d\u540c\u7aef\u53e3\u8bbf\u95ee&#xff0c;\u5f97\u5230\u4e0d\u540c\u7684\u7f51\u7ad9\u5185\u5bb9\u3002<\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u521b\u5efa\u7aef\u53e3\u865a\u62df\u4e3b\u673a\u914d\u7f6e\u6587\u4ef6<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim \/etc\/nginx\/conf.d\/vhost-port.conf<\/span><\/p>\n<p><span class=\"token comment\"># \u7b2c\u4e00\u4e2a\u865a\u62df\u4e3b\u673a&#xff1a;\u76d1\u542c 8081 \u7aef\u53e3<\/span><br \/>\nserver <span class=\"token punctuation\">{<\/span><br \/>\n    listen       <span class=\"token number\">8081<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u76d1\u542c\u7684\u7aef\u53e3&#xff08;\u8bbf\u95ee 8081 \u7aef\u53e3\u65f6\u5339\u914d\u6b64\u914d\u7f6e&#xff09;<\/span><br \/>\n    server_name  www.bq.cloud<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u7ed1\u5b9a\u7684\u57df\u540d<\/span><br \/>\n    root         \/usr\/share\/nginx\/8081<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u7f51\u7ad9\u6587\u4ef6\u5b58\u653e\u76ee\u5f55<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\"># \u7b2c\u4e8c\u4e2a\u865a\u62df\u4e3b\u673a&#xff1a;\u76d1\u542c 8082 \u7aef\u53e3<\/span><br \/>\nserver <span class=\"token punctuation\">{<\/span><br \/>\n    listen       <span class=\"token number\">8082<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u76d1\u542c\u7684\u7aef\u53e3<\/span><br \/>\n    server_name  www.bq.cloud<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u7ed1\u5b9a\u7684\u57df\u540d<\/span><br \/>\n    root         \/usr\/share\/nginx\/8082<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u7f51\u7ad9\u6587\u4ef6\u5b58\u653e\u76ee\u5f55<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u8865\u5145&#xff1a;\u914d\u7f6e\u7aef\u53e3\u865a\u62df\u4e3b\u673a\u540e&#xff0c;\u9700\u5728\u9632\u706b\u5899\u5f00\u653e\u5bf9\u5e94\u7aef\u53e3&#xff08;\u5982 8081\u30018082&#xff09;&#xff0c;\u5426\u5219\u5916\u90e8\u65e0\u6cd5\u8bbf\u95ee(\u6216\u8005\u76f4\u63a5\u5c06\u9632\u706b\u5899\u5173\u95ed)&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u5f00\u653e 8081 \u7aef\u53e3&#xff08;\u6c38\u4e45\u751f\u6548&#xff09;<\/span><br \/>\nfirewall-cmd &#8211;add-port<span class=\"token operator\">&#061;<\/span><span class=\"token number\">8081<\/span>\/tcp <span class=\"token parameter variable\">&#8211;permanent<\/span><br \/>\n<span class=\"token comment\"># \u5f00\u653e 8082 \u7aef\u53e3&#xff08;\u6c38\u4e45\u751f\u6548&#xff09;<\/span><br \/>\nfirewall-cmd &#8211;add-port<span class=\"token operator\">&#061;<\/span><span class=\"token number\">8082<\/span>\/tcp <span class=\"token parameter variable\">&#8211;permanent<\/span><br \/>\n<span class=\"token comment\"># \u91cd\u65b0\u52a0\u8f7d\u9632\u706b\u5899\u914d\u7f6e<\/span><br \/>\nfirewall-cmd <span class=\"token parameter variable\">&#8211;reload<\/span><\/p>\n<h5>\u914d\u7f6e SSL\/TLS<\/h5>\n<p>SSL\/TLS \u662f\u7528\u4e8e\u52a0\u5bc6\u7f51\u7edc\u901a\u4fe1\u7684\u534f\u8bae\u3002\u914d\u7f6e\u540e&#xff0c;\u7f51\u7ad9\u53ef\u4ee5\u901a\u8fc7 HTTPS&#xff08;\u9ed8\u8ba4\u7aef\u53e3 443&#xff09;\u63d0\u4f9b\u670d\u52a1&#xff0c;\u8ba9\u7528\u6237\u548c\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u6570\u636e\u4f20\u8f93\u66f4\u5b89\u5168&#xff08;\u6bd4\u5982\u767b\u5f55\u5bc6\u7801\u3001\u652f\u4ed8\u4fe1\u606f\u4e0d\u4f1a\u88ab\u4e2d\u9014\u7a83\u53d6&#xff09;\u3002<\/p>\n<h6>OpenSSL \u5de5\u5177<\/h6>\n<p>OpenSSL \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u52a0\u5bc6\u5de5\u5177\u5e93&#xff0c;\u662f\u914d\u7f6e SSL\/TLS \u7684 \u201c\u6838\u5fc3\u5de5\u5177\u201d&#xff0c;\u53ef\u4ee5\u751f\u6210\u5bc6\u94a5\u3001\u8bc1\u4e66&#xff0c;\u8fd8\u80fd\u8fdb\u884c\u52a0\u5bc6\u89e3\u5bc6\u7b49\u64cd\u4f5c\u3002<\/p>\n<p>\u57fa\u7840\u9009\u9879<\/p>\n<ul>\n<li>-in &lt;file&gt;&#xff1a;\u6307\u5b9a\u8f93\u5165\u6587\u4ef6&#xff08;\u6bd4\u5982\u79c1\u94a5\u3001\u8bc1\u4e66\u7b49&#xff09;\u3002<\/li>\n<li>-out &lt;file&gt;&#xff1a;\u6307\u5b9a\u8f93\u51fa\u6587\u4ef6&#xff08;\u6bd4\u5982\u751f\u6210\u7684\u5bc6\u94a5\u3001\u8bc1\u4e66\u7b49&#xff09;\u3002<\/li>\n<li>-help&#xff1a;\u67e5\u770b\u67d0\u4e2a\u5b50\u547d\u4ee4\u7684\u8be6\u7ec6\u9009\u9879&#xff08;\u4f8b\u5982 openssl genrsa -help&#xff09;\u3002<\/li>\n<\/ul>\n<p>\u5bc6\u94a5\u751f\u6210\u76f8\u5173\u547d\u4ee4<\/p>\n<li>openssl genrsa&#xff08;\u751f\u6210 RSA \u79c1\u94a5&#xff09;\n<ul>\n<li>\u529f\u80fd&#xff1a;\u751f\u6210 RSA \u7b97\u6cd5\u7684\u79c1\u94a5&#xff08;\u79c1\u94a5\u662f\u52a0\u5bc6\u901a\u4fe1\u7684\u6838\u5fc3&#xff0c;\u5fc5\u987b\u59a5\u5584\u4fdd\u7ba1&#xff0c;\u4e0d\u80fd\u6cc4\u9732&#xff09;\u3002<\/li>\n<li>\u8bed\u6cd5&#xff1a;openssl genrsa [\u9009\u9879] \u5bc6\u94a5\u957f\u5ea6<\/li>\n<li>\u5e38\u7528\u9009\u9879&#xff1a;\n<ul>\n<li>-des3&#xff1a;\u7528 3DES \u7b97\u6cd5\u52a0\u5bc6\u79c1\u94a5&#xff08;\u4f7f\u7528\u79c1\u94a5\u65f6\u9700\u8981\u8f93\u5165\u5bc6\u7801&#xff0c;\u66f4\u5b89\u5168\u4f46\u9ebb\u70e6&#xff09;\u3002<\/li>\n<li>-aes256&#xff1a;\u7528 AES-256 \u7b97\u6cd5\u52a0\u5bc6\u79c1\u94a5&#xff08;\u6bd4 3DES \u66f4\u5b89\u5168&#xff0c;\u63a8\u8350\u4f7f\u7528&#xff09;\u3002<\/li>\n<li>2048\/4096&#xff1a;\u6307\u5b9a\u5bc6\u94a5\u957f\u5ea6&#xff08;\u5355\u4f4d&#xff1a;\u4f4d&#xff09;\u30022048 \u4f4d\u6ee1\u8db3\u57fa\u7840\u5b89\u5168\u9700\u6c42&#xff0c;4096 \u4f4d\u66f4\u5b89\u5168\u4f46\u52a0\u5bc6\u89e3\u5bc6\u901f\u5ea6\u7a0d\u6162\u3002<\/li>\n<li>-out &lt;file&gt;&#xff1a;\u5c06\u751f\u6210\u7684\u79c1\u94a5\u4fdd\u5b58\u5230\u6307\u5b9a\u6587\u4ef6\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>openssl ecparam&#xff08;\u751f\u6210 ECC \u692d\u5706\u66f2\u7ebf\u5bc6\u94a5&#xff09;\n<ul>\n<li>\u529f\u80fd&#xff1a;\u751f\u6210\u57fa\u4e8e\u692d\u5706\u66f2\u7ebf\u7b97\u6cd5&#xff08;ECC&#xff09;\u7684\u79c1\u94a5&#xff08;ECC \u6bd4 RSA \u66f4\u9ad8\u6548&#xff0c;\u76f8\u540c\u5b89\u5168\u7ea7\u522b\u4e0b\u5bc6\u94a5\u66f4\u77ed&#xff09;\u3002<\/li>\n<li>\u8bed\u6cd5&#xff1a;openssl ecparam [\u9009\u9879]<\/li>\n<li>\u5e38\u7528\u9009\u9879&#xff1a;\n<ul>\n<li>-genkey&#xff1a;\u751f\u6210\u692d\u5706\u66f2\u7ebf\u79c1\u94a5\u3002<\/li>\n<li>-name &lt;curve&gt;&#xff1a;\u6307\u5b9a\u692d\u5706\u66f2\u7ebf\u7c7b\u578b&#xff08;\u5982 secp256r1\u3001prime256v1&#xff0c;\u5b89\u5168\u6027\u9ad8\u4e14\u6027\u80fd\u597d&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<p>\u8bc1\u4e66\u7b7e\u540d\u8bf7\u6c42&#xff08;CSR&#xff09;\u76f8\u5173\u547d\u4ee4<br \/>\nopenssl req&#xff08;\u751f\u6210 CSR \u6216\u81ea\u7b7e\u540d\u8bc1\u4e66&#xff09;<\/p>\n<ul>\n<li>\u529f\u80fd&#xff1a;\u751f\u6210 CSR&#xff08;\u5411\u8bc1\u4e66\u9881\u53d1\u673a\u6784 CA \u7533\u8bf7\u6b63\u5f0f\u8bc1\u4e66\u7684\u8bf7\u6c42\u6587\u4ef6&#xff09;&#xff0c;\u6216\u76f4\u63a5\u751f\u6210\u81ea\u7b7e\u540d\u8bc1\u4e66&#xff08;\u7528\u4e8e\u6d4b\u8bd5&#xff0c;\u6d4f\u89c8\u5668\u4f1a\u63d0\u793a \u201c\u8bc1\u4e66\u4e0d\u53d7\u4fe1\u4efb\u201d&#xff09;\u3002<\/li>\n<li>\u8bed\u6cd5&#xff1a;openssl req [\u9009\u9879]<\/li>\n<li>\u5e38\u7528\u9009\u9879&#xff1a;\n<ul>\n<li>-new&#xff1a;\u751f\u6210\u65b0\u7684 CSR \u6587\u4ef6\u3002<\/li>\n<li>-key &lt;file&gt;&#xff1a;\u6307\u5b9a\u79c1\u94a5\u6587\u4ef6&#xff08;CSR \u5fc5\u987b\u4e0e\u79c1\u94a5\u7ed1\u5b9a&#xff09;\u3002<\/li>\n<li>-x509&#xff1a;\u8df3\u8fc7 CSR \u6b65\u9aa4&#xff0c;\u76f4\u63a5\u751f\u6210\u81ea\u7b7e\u540d\u8bc1\u4e66&#xff08;\u4ec5\u7528\u4e8e\u6d4b\u8bd5&#xff09;\u3002<\/li>\n<li>-days &lt;num&gt;&#xff1a;\u6307\u5b9a\u8bc1\u4e66\u6709\u6548\u671f&#xff08;\u4ec5\u4e0e -x509 \u914d\u5408\u4f7f\u7528&#xff0c;\u5982 365 \u8868\u793a 1 \u5e74&#xff09;\u3002<\/li>\n<li>-subj &lt;string&gt;&#xff1a;\u975e\u4ea4\u4e92\u5f0f\u6307\u5b9a\u8bc1\u4e66\u4e3b\u9898\u4fe1\u606f&#xff08;\u907f\u514d\u624b\u52a8\u8f93\u5165&#xff09;&#xff0c;\u683c\u5f0f&#xff1a;<br \/>\n\/C&#061;\u56fd\u5bb6\u4ee3\u7801\/ST&#061;\u7701\u4efd\/L&#061;\u57ce\u5e02\/O&#061;\u7ec4\u7ec7\u540d\u79f0\/OU&#061;\u90e8\u95e8\u540d\u79f0\/CN&#061;\u57df\u540d\/emailAddress&#061;\u7ba1\u7406\u5458\u90ae\u7bb1<br \/>\n&#xff08;\u6ce8\u610f&#xff1a;CN \u5fc5\u987b\u4e0e\u7f51\u7ad9\u57df\u540d\u4e00\u81f4&#xff0c;\u5426\u5219\u6d4f\u89c8\u5668\u4f1a\u63d0\u793a\u8bc1\u4e66\u65e0\u6548&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u8bc1\u4e66\u67e5\u770b\u4e0e\u9a8c\u8bc1\u547d\u4ee4<br \/>\nopenssl x509&#xff08;\u5904\u7406 X.509 \u683c\u5f0f\u8bc1\u4e66&#xff09;<\/p>\n<ul>\n<li>\u529f\u80fd&#xff1a;\u67e5\u770b\u3001\u8f6c\u6362\u6216\u9a8c\u8bc1 X.509 \u683c\u5f0f\u8bc1\u4e66&#xff08;\u6700\u5e38\u7528\u7684\u8bc1\u4e66\u683c\u5f0f&#xff09;\u3002<\/li>\n<li>\u8bed\u6cd5&#xff1a;openssl x509 [\u9009\u9879] -in \u8bc1\u4e66\u6587\u4ef6<\/li>\n<li>\u5e38\u7528\u9009\u9879&#xff1a;\n<ul>\n<li>-noout&#xff1a;\u4e0d\u8f93\u51fa\u8bc1\u4e66\u539f\u59cb\u5185\u5bb9&#xff08;\u53ea\u663e\u793a\u89e3\u6790\u540e\u7684\u4fe1\u606f&#xff09;\u3002<\/li>\n<li>-text&#xff1a;\u663e\u793a\u8bc1\u4e66\u8be6\u7ec6\u4fe1\u606f&#xff08;\u5305\u62ec\u7248\u672c\u3001\u5e8f\u5217\u53f7\u3001\u9881\u53d1\u8005\u3001\u6709\u6548\u671f\u3001\u516c\u94a5\u7b49&#xff09;\u3002<\/li>\n<li>-subject&#xff1a;\u53ea\u663e\u793a\u8bc1\u4e66\u4e3b\u4f53\u4fe1\u606f&#xff08;\u5982\u57df\u540d\u3001\u7ec4\u7ec7\u7b49&#xff09;\u3002<\/li>\n<li>-issuer&#xff1a;\u53ea\u663e\u793a\u8bc1\u4e66\u9881\u53d1\u8005\u4fe1\u606f&#xff08;CA \u673a\u6784&#xff09;\u3002<\/li>\n<li>-dates&#xff1a;\u663e\u793a\u8bc1\u4e66\u6709\u6548\u671f&#xff08;notBefore \u8d77\u59cb\u65f6\u95f4&#xff0c;notAfter \u8fc7\u671f\u65f6\u95f4&#xff09;\u3002<\/li>\n<li>-fingerprint&#xff1a;\u663e\u793a\u8bc1\u4e66\u6307\u7eb9&#xff08;\u5982 SHA256 \u6307\u7eb9&#xff0c;\u7528\u4e8e\u6821\u9a8c\u8bc1\u4e66\u662f\u5426\u88ab\u7be1\u6539&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u6587\u4ef6\u52a0\u5bc6 \/ \u89e3\u5bc6\u547d\u4ee4<br \/>\nopenssl enc&#xff08;\u5bf9\u79f0\u52a0\u5bc6\u6587\u4ef6&#xff09;<\/p>\n<ul>\n<li>\u529f\u80fd&#xff1a;\u7528\u5bf9\u79f0\u52a0\u5bc6\u7b97\u6cd5&#xff08;\u5982 AES&#xff09;\u52a0\u5bc6\u6216\u89e3\u5bc6\u6587\u4ef6&#xff08;\u6bd4\u5982\u52a0\u5bc6\u654f\u611f\u6587\u6863&#xff09;\u3002<\/li>\n<li>\u8bed\u6cd5&#xff1a;openssl enc -\u7b97\u6cd5 [\u9009\u9879] -in \u8f93\u5165\u6587\u4ef6 -out \u8f93\u51fa\u6587\u4ef6<\/li>\n<li>\u5e38\u7528\u9009\u9879&#xff1a;\n<ul>\n<li>-e&#xff1a;\u52a0\u5bc6\u6a21\u5f0f&#xff08;\u9ed8\u8ba4&#xff0c;\u53ef\u7701\u7565&#xff09;\u3002<\/li>\n<li>-d&#xff1a;\u89e3\u5bc6\u6a21\u5f0f\u3002<\/li>\n<li>-aes-256-cbc\/-aes-128-gcm&#xff1a;\u6307\u5b9a\u52a0\u5bc6\u7b97\u6cd5&#xff08;GCM \u6a21\u5f0f\u6bd4 CBC \u66f4\u5b89\u5168&#xff0c;\u63a8\u8350&#xff09;\u3002<\/li>\n<li>-salt&#xff1a;\u81ea\u52a8\u6dfb\u52a0\u968f\u673a\u76d0\u503c&#xff08;\u589e\u5f3a\u52a0\u5bc6\u5f3a\u5ea6&#xff0c;\u5fc5\u987b\u5f00\u542f&#xff09;\u3002<\/li>\n<li>-k &lt;password&gt;&#xff1a;\u6307\u5b9a\u52a0\u5bc6 \/ \u89e3\u5bc6\u5bc6\u7801&#xff08;\u4e5f\u53ef\u901a\u8fc7 -pass file:\u5bc6\u7801\u6587\u4ef6 \u4ece\u6587\u4ef6\u8bfb\u53d6&#xff09;\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u683c\u5f0f\u8f6c\u6362\u547d\u4ee4<\/p>\n<li>\n<p>openssl pkcs12&#xff08;\u8f6c\u6362\u4e3a PFX\/PKCS#12 \u683c\u5f0f&#xff09;<\/p>\n<ul>\n<li>\n<p>\u529f\u80fd&#xff1a;\u5c06\u79c1\u94a5\u548c\u8bc1\u4e66\u6253\u5305\u4e3a\u5355\u4e00\u6587\u4ef6&#xff08;Windows \u7cfb\u7edf\u5e38\u7528\u6b64\u683c\u5f0f&#xff0c;\u65b9\u4fbf\u5bfc\u5165&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5&#xff1a;openssl pkcs12 -export -inkey \u79c1\u94a5\u6587\u4ef6 -in \u8bc1\u4e66\u6587\u4ef6 -name \u522b\u540d -out \u8f93\u51fa\u6587\u4ef6<\/p>\n<\/li>\n<li>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u5c06 private.key \u79c1\u94a5\u548c cert.crt \u8bc1\u4e66\u6253\u5305\u4e3a cert.pfx<\/span><br \/>\nopenssl pkcs12 <span class=\"token parameter variable\">-export<\/span> <span class=\"token parameter variable\">-inkey<\/span> private.key <span class=\"token parameter variable\">-in<\/span> cert.crt <span class=\"token parameter variable\">-name<\/span> <span class=\"token string\">&#034;mycert&#034;<\/span> <span class=\"token parameter variable\">-out<\/span> cert.pfx<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>PEM \u4e0e DER \u683c\u5f0f\u4e92\u8f6c<\/p>\n<ul>\n<li>\n<p>PEM \u662f\u6587\u672c\u683c\u5f0f&#xff08;\u4ee5&#8212;&#8211;BEGIN\u2026\u5f00\u5934&#xff09;&#xff0c;DER \u662f\u4e8c\u8fdb\u5236\u683c\u5f0f&#xff0c;\u4e24\u8005\u53ef\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u8f6c\u6362&#xff1a;<\/p>\n<p><span class=\"token comment\"># PEM \u8bc1\u4e66\u8f6c DER \u8bc1\u4e66<\/span><br \/>\nopenssl x509 <span class=\"token parameter variable\">-in<\/span> cert.pem <span class=\"token parameter variable\">-out<\/span> cert.der <span class=\"token parameter variable\">-outform<\/span> der<\/p>\n<p><span class=\"token comment\"># DER \u79c1\u94a5\u8f6c PEM \u79c1\u94a5<\/span><br \/>\nopenssl rsa <span class=\"token parameter variable\">-in<\/span> key.der <span class=\"token parameter variable\">-out<\/span> key.pem <span class=\"token parameter variable\">-inform<\/span> der<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<h6>\u751f\u6210 SSL \u8bc1\u4e66&#xff08;\u81ea\u7b7e\u540d\u8bc1\u4e66&#xff0c;\u7528\u4e8e HTTPS \u52a0\u5bc6&#xff09;<\/h6>\n<p>\u81ea\u7b7e\u540d\u8bc1\u4e66\u662f\u81ea\u5df1\u751f\u6210\u5e76\u7b7e\u540d\u7684&#xff0c;\u9002\u5408\u6d4b\u8bd5&#xff08;\u6d4f\u89c8\u5668\u4f1a\u63d0\u793a \u201c\u8bc1\u4e66\u4e0d\u53d7\u4fe1\u4efb\u201d&#xff09;&#xff1b;\u6b63\u5f0f\u73af\u5883\u9700\u8981\u7528 CA \u673a\u6784&#xff08;\u5982 Let\u2019s Encrypt&#xff09;\u9881\u53d1\u7684\u8bc1\u4e66\u3002<\/p>\n<p><span class=\"token comment\"># 1. \u751f\u6210 RSA \u79c1\u94a5<\/span><br \/>\n<span class=\"token comment\"># \u529f\u80fd&#xff1a;\u751f\u6210 2048 \u4f4d\u7684 RSA \u79c1\u94a5&#xff0c;\u4fdd\u5b58\u5230 www.key \u6587\u4ef6<\/span><br \/>\n<span class=\"token comment\"># \u8bed\u6cd5&#xff1a;openssl genrsa -out \u8f93\u51fa\u6587\u4ef6 \u5bc6\u94a5\u957f\u5ea6<\/span><br \/>\n<span class=\"token comment\"># \u8bf4\u660e&#xff1a;\u79c1\u94a5\u9700\u4fdd\u5bc6&#xff0c;\u6743\u9650\u5efa\u8bae\u8bbe\u4e3a 600&#xff08;\u53ea\u6709\u6240\u6709\u8005\u53ef\u8bfb\u5199&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># openssl genrsa -out www.key 2048  <\/span><\/p>\n<p><span class=\"token comment\"># 2. \u751f\u6210\u8bc1\u4e66\u7b7e\u540d\u8bf7\u6c42&#xff08;CSR&#xff09;<\/span><br \/>\n<span class=\"token comment\"># \u529f\u80fd&#xff1a;\u57fa\u4e8e\u79c1\u94a5\u751f\u6210 CSR \u6587\u4ef6&#xff08;\u7528\u4e8e\u5411 CA \u7533\u8bf7\u8bc1\u4e66&#xff09;<\/span><br \/>\n<span class=\"token comment\"># \u8bed\u6cd5&#xff1a;openssl req -new -key \u79c1\u94a5\u6587\u4ef6 -out CSR \u6587\u4ef6 -subj \u4e3b\u9898\u4fe1\u606f<\/span><br \/>\n<span class=\"token comment\"># \u9009\u9879\u8bf4\u660e&#xff1a;<\/span><br \/>\n<span class=\"token comment\">#   -new&#xff1a;\u751f\u6210\u65b0\u7684 CSR<\/span><br \/>\n<span class=\"token comment\">#   -key&#xff1a;\u6307\u5b9a\u79c1\u94a5\u6587\u4ef6&#xff08;\u4e0e CSR \u7ed1\u5b9a&#xff09;<\/span><br \/>\n<span class=\"token comment\">#   -out&#xff1a;\u8f93\u51fa CSR \u6587\u4ef6<\/span><br \/>\n<span class=\"token comment\">#   -subj&#xff1a;\u975e\u4ea4\u4e92\u5f0f\u6307\u5b9a\u4e3b\u9898\u4fe1\u606f&#xff08;\u907f\u514d\u624b\u52a8\u8f93\u5165&#xff09;<\/span><br \/>\n<span class=\"token comment\">#     \/C&#061;CN&#xff1a;\u56fd\u5bb6&#xff08;CN \u8868\u793a\u4e2d\u56fd&#xff09;<\/span><br \/>\n<span class=\"token comment\">#     \/ST&#061;JS&#xff1a;\u7701\u4efd&#xff08;JS \u8868\u793a\u6c5f\u82cf\u7701&#xff09;<\/span><br \/>\n<span class=\"token comment\">#     \/L&#061;NJ&#xff1a;\u57ce\u5e02&#xff08;NJ \u8868\u793a\u5357\u4eac\u5e02&#xff09;<\/span><br \/>\n<span class=\"token comment\">#     \/O&#061;LM&#xff1a;\u7ec4\u7ec7\u540d\u79f0&#xff08;\u81ea\u5b9a\u4e49&#xff09;<\/span><br \/>\n<span class=\"token comment\">#     \/OU&#061;DEVOPS&#xff1a;\u90e8\u95e8\u540d\u79f0&#xff08;\u81ea\u5b9a\u4e49&#xff09;<\/span><br \/>\n<span class=\"token comment\">#     \/CN&#061;www.bq.cloud&#xff1a;\u57df\u540d&#xff08;\u5fc5\u987b\u4e0e\u7f51\u7ad9\u57df\u540d\u4e00\u81f4&#xff09;<\/span><br \/>\n<span class=\"token comment\">#     \/emailAddress&#061;bq&#064;bq.cloud&#xff1a;\u7ba1\u7406\u5458\u90ae\u7bb1&#xff08;\u53ef\u9009&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># openssl req -new -key www.key -out www.csr -subj &#034;\/C&#061;CN\/ST&#061;JS\/L&#061;NJ\/O&#061;LM\/OU&#061;DEVOPS\/CN&#061;www.bq.cloud\/emailAddress&#061;bq&#064;bq.cloud&#034;  <\/span><\/p>\n<p><span class=\"token comment\"># 3. \u751f\u6210\u81ea\u7b7e\u540d\u8bc1\u4e66&#xff08;\u7528\u81ea\u5df1\u7684\u79c1\u94a5\u7b7e\u540d CSR&#xff09;<\/span><br \/>\n<span class=\"token comment\"># \u529f\u80fd&#xff1a;\u57fa\u4e8e CSR \u548c\u79c1\u94a5\u751f\u6210\u81ea\u7b7e\u540d\u8bc1\u4e66&#xff0c;\u6709\u6548\u671f 3650 \u5929<\/span><br \/>\n<span class=\"token comment\"># \u8bed\u6cd5&#xff1a;openssl x509 -req -days \u6709\u6548\u671f -in CSR \u6587\u4ef6 -signkey \u79c1\u94a5\u6587\u4ef6 -out \u8bc1\u4e66\u6587\u4ef6<\/span><br \/>\n<span class=\"token comment\"># \u9009\u9879\u8bf4\u660e&#xff1a;<\/span><br \/>\n<span class=\"token comment\">#   -req&#xff1a;\u8868\u793a\u8f93\u5165\u6587\u4ef6\u662f CSR<\/span><br \/>\n<span class=\"token comment\">#   -days&#xff1a;\u8bc1\u4e66\u6709\u6548\u671f&#xff08;\u5929&#xff09;<\/span><br \/>\n<span class=\"token comment\">#   -in&#xff1a;\u8f93\u5165 CSR \u6587\u4ef6<\/span><br \/>\n<span class=\"token comment\">#   -signkey&#xff1a;\u7528\u6307\u5b9a\u7684\u79c1\u94a5\u7b7e\u540d&#xff08;\u81ea\u7b7e\u540d&#xff09;<\/span><br \/>\n<span class=\"token comment\">#   -out&#xff1a;\u8f93\u51fa\u8bc1\u4e66\u6587\u4ef6&#xff08;\u7528\u4e8e\u914d\u7f6e\u5230\u670d\u52a1\u5668&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># openssl x509 -req -days 3650 -in www.csr -signkey www.key -out www.crt<\/span><\/p>\n<h6>\u914d\u7f6e Nginx \u7ad9\u70b9\u652f\u6301 HTTPS<\/h6>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u521b\u5efa\u8bc1\u4e66\u5b58\u653e\u76ee\u5f55&#xff08;\u6309\u57df\u540d\u5206\u7c7b&#xff0c;\u65b9\u4fbf\u7ba1\u7406\u591a\u4e2a\u8bc1\u4e66&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># mkdir \/etc\/ssl\/certs\/www.bq.cloud<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u5c06\u751f\u6210\u7684\u8bc1\u4e66\u6587\u4ef6&#xff08;\u79c1\u94a5\u3001CSR\u3001\u8bc1\u4e66&#xff09;\u79fb\u52a8\u5230\u4e13\u7528\u76ee\u5f55<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># mv www* \/etc\/ssl\/certs\/www.bq.cloud<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u7f16\u8f91 Nginx SSL \u914d\u7f6e\u6587\u4ef6&#xff08;\u521b\u5efa\u65b0\u6587\u4ef6\u7ba1\u7406 HTTPS \u7ad9\u70b9&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim \/etc\/nginx\/conf.d\/ssl.conf<\/span><br \/>\nserver <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\"># \u529f\u80fd&#xff1a;\u76d1\u542c 443 \u7aef\u53e3&#xff08;HTTPS \u9ed8\u8ba4\u7aef\u53e3&#xff09;&#xff0c;\u542f\u7528 SSL \u52a0\u5bc6\u548c HTTP\/2 \u534f\u8bae<\/span><br \/>\n    <span class=\"token comment\"># \u8bf4\u660e&#xff1a;HTTP\/2 \u6bd4 HTTP\/1 \u6027\u80fd\u66f4\u597d&#xff0c;\u652f\u6301\u591a\u8def\u590d\u7528<\/span><br \/>\n    listen       <span class=\"token number\">443<\/span> ssl http2 default_server<span class=\"token punctuation\">;<\/span><br \/>\n    listen       <span class=\"token punctuation\">[<\/span>::<span class=\"token punctuation\">]<\/span>:443 ssl http2 default_server<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\"># \u7ed1\u5b9a\u7684\u57df\u540d&#xff08;\u5fc5\u987b\u4e0e\u8bc1\u4e66\u7684 CN \u5b57\u6bb5\u4e00\u81f4&#xff0c;\u5426\u5219\u8bc1\u4e66\u65e0\u6548&#xff09;<\/span><br \/>\n    server_name  www.bq.cloud<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\"># \u7f51\u7ad9\u6839\u76ee\u5f55&#xff08;\u5b58\u653e\u7f51\u9875\u6587\u4ef6\u7684\u4f4d\u7f6e&#xff09;<\/span><br \/>\n    root         \/usr\/share\/nginx\/html<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\"># \u914d\u7f6e SSL \u8bc1\u4e66\u8def\u5f84&#xff08;\u516c\u94a5\u8bc1\u4e66&#xff0c;\u5ba2\u6237\u7aef\u4f1a\u9a8c\u8bc1\u6b64\u8bc1\u4e66&#xff09;<\/span><br \/>\n    ssl_certificate <span class=\"token string\">&#034;\/etc\/ssl\/certs\/www.bq.cloud\/www.crt&#034;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\"># \u914d\u7f6e SSL \u79c1\u94a5\u8def\u5f84&#xff08;\u670d\u52a1\u5668\u7528\u4e8e\u89e3\u5bc6\u5ba2\u6237\u7aef\u8bf7\u6c42&#xff0c;\u9700\u4fdd\u5bc6&#xff09;<\/span><br \/>\n    ssl_certificate_key <span class=\"token string\">&#034;\/etc\/ssl\/certs\/www.bq.cloud\/www.key&#034;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u91cd\u542f Nginx \u670d\u52a1&#xff0c;\u4f7f HTTPS \u914d\u7f6e\u751f\u6548<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl restart nginx<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u914d\u7f6e HTTP&#xff08;80 \u7aef\u53e3&#xff09;\u81ea\u52a8\u91cd\u5b9a\u5411\u5230 HTTPS&#xff08;443 \u7aef\u53e3&#xff09;<\/span><br \/>\n<span class=\"token comment\"># \u8bf4\u660e&#xff1a;\u7528\u6237\u8bbf\u95ee http:\/\/www.bq.cloud \u65f6&#xff0c;\u81ea\u52a8\u8df3\u8f6c\u5230 https:\/\/www.bq.cloud<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim \/etc\/nginx\/nginx.conf<\/span><br \/>\n    server <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token comment\"># \u76d1\u542c 80 \u7aef\u53e3&#xff08;HTTP \u9ed8\u8ba4\u7aef\u53e3&#xff09;<\/span><br \/>\n        listen       <span class=\"token number\">80<\/span> default_server<span class=\"token punctuation\">;<\/span><br \/>\n        listen       <span class=\"token punctuation\">[<\/span>::<span class=\"token punctuation\">]<\/span>:80 default_server<span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token comment\"># \u7ed1\u5b9a\u7684\u57df\u540d&#xff08;\u4e0e HTTPS \u7ad9\u70b9\u4e00\u81f4&#xff09;<\/span><br \/>\n        server_name  www.bq.cloud<span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token comment\"># \u7f51\u7ad9\u6839\u76ee\u5f55&#xff08;\u91cd\u5b9a\u5411\u573a\u666f\u4e0b\u53ef\u7701\u7565\u5b9e\u9645\u5185\u5bb9&#xff09;<\/span><br \/>\n        root         \/usr\/share\/nginx\/html<span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token comment\"># \u529f\u80fd&#xff1a;301 \u6c38\u4e45\u91cd\u5b9a\u5411&#xff0c;\u5c06\u6240\u6709 HTTP \u8bf7\u6c42\u8f6c\u53d1\u5230 HTTPS<\/span><br \/>\n        <span class=\"token comment\"># \u53d8\u91cf\u8bf4\u660e&#xff1a;<\/span><br \/>\n        <span class=\"token comment\">#   $host&#xff1a;\u5f53\u524d\u8bf7\u6c42\u7684\u57df\u540d&#xff08;\u5982 www.bq.cloud&#xff09;<\/span><br \/>\n        <span class=\"token comment\">#   $request_uri&#xff1a;\u5f53\u524d\u8bf7\u6c42\u7684\u8def\u5f84\u548c\u53c2\u6570&#xff08;\u5982 \/test?a&#061;1&#xff09;<\/span><br \/>\n        <span class=\"token builtin class-name\">return<\/span>       <span class=\"token number\">301<\/span> https:\/\/<span class=\"token variable\">$host<\/span><span class=\"token variable\">$request_uri<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u91cd\u542f Nginx \u670d\u52a1&#xff0c;\u4f7f\u91cd\u5b9a\u5411\u914d\u7f6e\u751f\u6548<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl restart nginx<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u914d\u7f6e\u9632\u706b\u5899&#xff0c;\u5141\u8bb8 HTTPS \u670d\u52a1\u901a\u8fc7&#xff08;\u9ed8\u8ba4\u7aef\u53e3 443&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># firewall-cmd &#8211;add-service&#061;https &#8211;permanent<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># firewall-cmd &#8211;reload<\/span><\/p>\n<p><span class=\"token comment\"># \u6d4b\u8bd5 HTTPS \u914d\u7f6e&#xff1a;<\/span><br \/>\n<span class=\"token comment\"># 1. \u6d4b\u8bd5 HTTP \u662f\u5426\u81ea\u52a8\u91cd\u5b9a\u5411\u5230 HTTPS&#xff08;\u5e94\u8fd4\u56de 301 \u8df3\u8f6c\u4fe1\u606f&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;client ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl http:\/\/www.bq.cloud\/<\/span><\/p>\n<p><span class=\"token comment\"># 2. \u6d4b\u8bd5 HTTPS \u8bbf\u95ee&#xff08;-k \u9009\u9879&#xff1a;\u5ffd\u7565\u81ea\u7b7e\u540d\u8bc1\u4e66\u7684\u4e0d\u4fe1\u4efb\u63d0\u793a&#xff0c;\u6b63\u5f0f\u73af\u5883\u65e0\u9700\u6b64\u9009\u9879&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;client ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl -k https:\/\/www.bq.cloud\/<\/span><\/p>\n<h5>\u914d\u7f6e Nginx \u57fa\u672c\u8ba4\u8bc1&#xff08;\u5bc6\u7801\u4fdd\u62a4\u7279\u5b9a\u76ee\u5f55&#xff09;<\/h5>\n<p>\u57fa\u672c\u8ba4\u8bc1\u662f\u901a\u8fc7 \u201c\u7528\u6237\u540d &#043; \u5bc6\u7801\u201d \u9650\u5236\u8bbf\u95ee\u7279\u5b9a\u76ee\u5f55\u7684\u529f\u80fd\u3002\u4f46\u8981\u6ce8\u610f&#xff1a;\u7528\u6237\u540d\u548c\u5bc6\u7801\u4f1a\u901a\u8fc7 HTTP \u660e\u6587\u4f20\u8f93&#xff0c;\u56e0\u6b64\u5fc5\u987b\u914d\u5408 SSL\/TLS&#xff08;HTTPS&#xff09;\u4f7f\u7528&#xff0c;\u5426\u5219\u6709\u5b89\u5168\u98ce\u9669\u3002<\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u5b89\u88c5\u751f\u6210\u5bc6\u7801\u6587\u4ef6\u7684\u5de5\u5177&#xff08;httpd-tools \u5305\u542b htpasswd \u547d\u4ee4&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># yum -y install httpd-tools<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u7f16\u8f91 Nginx SSL \u914d\u7f6e\u6587\u4ef6&#xff0c;\u6dfb\u52a0\u57fa\u672c\u8ba4\u8bc1\u89c4\u5219<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim \/etc\/nginx\/conf.d\/ssl.conf<\/span><br \/>\n<span class=\"token comment\"># \u5728 server \u5757\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e&#xff08;\u4fdd\u62a4 \/auth-basic\/ \u8def\u5f84&#xff09;<\/span><br \/>\nserver <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token punctuation\">..<\/span><span class=\"token punctuation\">..<\/span>.<br \/>\n    <span class=\"token comment\"># \u529f\u80fd&#xff1a;\u5bf9\u8bbf\u95ee \/auth-basic\/ \u8def\u5f84\u7684\u8bf7\u6c42\u542f\u7528\u57fa\u672c\u8ba4\u8bc1<\/span><br \/>\n    location \/auth-basic\/ <span class=\"token punctuation\">{<\/span><br \/>\n        auth_basic            <span class=\"token string\">&#034;Basic Auth&#034;<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u8ba4\u8bc1\u63d0\u793a\u4fe1\u606f&#xff08;\u6d4f\u89c8\u5668\u5f39\u7a97\u663e\u793a&#xff09;<\/span><br \/>\n        auth_basic_user_file  <span class=\"token string\">&#034;\/etc\/nginx\/.htpasswd&#034;<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u5bc6\u7801\u6587\u4ef6\u8def\u5f84&#xff08;\u5b58\u50a8\u7528\u6237\u540d\u548c\u52a0\u5bc6\u540e\u7684\u5bc6\u7801&#xff09;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u91cd\u542f Nginx \u670d\u52a1&#xff0c;\u4f7f\u8ba4\u8bc1\u914d\u7f6e\u751f\u6548<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl restart nginx<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u521b\u5efa\u57fa\u672c\u8ba4\u8bc1\u7684\u7528\u6237&#xff08;\u7528\u6237\u540d&#xff1a;bq&#xff09;\u548c\u5bc6\u7801\u6587\u4ef6<\/span><br \/>\n<span class=\"token comment\"># \u8bed\u6cd5&#xff1a;htpasswd -c \u5bc6\u7801\u6587\u4ef6 \u7528\u6237\u540d&#xff08;-c \u4ec5\u9996\u6b21\u521b\u5efa\u6587\u4ef6\u65f6\u4f7f\u7528&#xff0c;\u5426\u5219\u4f1a\u8986\u76d6&#xff09;<\/span><br \/>\n<span class=\"token comment\"># \u8bf4\u660e&#xff1a;\u5bc6\u7801\u4f1a\u88ab\u52a0\u5bc6\u5b58\u50a8&#xff08;\u4e0d\u662f\u660e\u6587&#xff09;&#xff0c;\u5bc6\u7801\u6587\u4ef6\u6743\u9650\u5efa\u8bae\u8bbe\u4e3a 600<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># htpasswd -c \/etc\/nginx\/.htpasswd bq<\/span><br \/>\nNew password:  <span class=\"token comment\"># \u8f93\u5165\u5bc6\u7801&#xff08;\u5982 redhat&#xff0c;\u8f93\u5165\u65f6\u4e0d\u663e\u793a&#xff09;<\/span><br \/>\nRe-type new password:  <span class=\"token comment\"># \u518d\u6b21\u8f93\u5165\u5bc6\u7801\u786e\u8ba4<\/span><br \/>\nAdding password <span class=\"token keyword\">for<\/span> user bq  <span class=\"token comment\"># \u63d0\u793a\u7528\u6237\u521b\u5efa\u6210\u529f<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u521b\u5efa\u6d4b\u8bd5\u9875\u9762&#xff08;\u7528\u4e8e\u9a8c\u8bc1\u57fa\u672c\u8ba4\u8bc1&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># mkdir \/usr\/share\/nginx\/html\/auth-basic  # \u521b\u5efa\u88ab\u4fdd\u62a4\u7684\u76ee\u5f55<\/span><br \/>\n<span class=\"token comment\"># \u521b\u5efa\u6d4b\u8bd5\u9875\u9762\u5185\u5bb9<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim \/usr\/share\/nginx\/html\/auth-basic\/index.html<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>html<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>body<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>div <span class=\"token assign-left variable\">style<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;width: 100%; font-size: 40px; font-weight: bold; text-align: center;&#034;<\/span><span class=\"token operator\">&gt;<\/span><br \/>\nTest Page <span class=\"token keyword\">for<\/span> Basic Authentication  <span class=\"token operator\">&lt;<\/span><span class=\"token operator\">!<\/span>&#8212; \u9875\u9762\u5185\u5bb9&#xff1a;\u57fa\u672c\u8ba4\u8bc1\u6d4b\u8bd5\u9875 &#8212;<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>\/div<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>\/body<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>\/html<span class=\"token operator\">&gt;<\/span><\/p>\n<p><span class=\"token comment\"># \u6d4b\u8bd5\u57fa\u672c\u8ba4\u8bc1&#xff1a;<\/span><br \/>\n<span class=\"token comment\"># 1. \u76f4\u63a5\u8bbf\u95ee\u4f1a\u63d0\u793a 401 Unauthorized&#xff08;\u672a\u6388\u6743&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;client ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl http:\/\/www.bq.cloud\/auth-basic\/<\/span><\/p>\n<p><span class=\"token comment\"># 2. \u5e26\u7528\u6237\u540d\u5bc6\u7801\u7684\u8bbf\u95ee\u547d\u4ee4&#xff08;\u6b63\u786e\u683c\u5f0f&#xff09;&#xff1a;<\/span><br \/>\n<span class=\"token comment\"># \u8bed\u6cd5&#xff1a;curl -u \u7528\u6237\u540d:\u5bc6\u7801 https:\/\/\u57df\u540d\/\u8def\u5f84 -k&#xff08;-k \u7528\u4e8e\u81ea\u7b7e\u540d\u8bc1\u4e66&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;client ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl -u bq:redhat https:\/\/www.bq.cloud\/auth-basic\/ -k<\/span><\/p>\n<h5>\u652f\u6301\u52a8\u6001\u811a\u672c<\/h5>\n<p>Nginx \u672c\u8eab\u4e0d\u80fd\u76f4\u63a5\u89e3\u6790\u52a8\u6001\u811a\u672c&#xff08;\u5982 PHP\u3001Python \u7b49&#xff09;&#xff0c;\u9700\u8981\u901a\u8fc7 FastCGI \u7b49\u65b9\u5f0f\u914d\u5408\u5bf9\u5e94\u7684\u5904\u7406\u5668&#xff08;\u5982 php-fpm \u5904\u7406 PHP\u3001fcgiwrap \u5904\u7406\u591a\u79cd\u811a\u672c&#xff09;\u6765\u5b9e\u73b0\u3002<\/p>\n<h6>\u4f7f\u7528 PHP<\/h6>\n<p>PHP \u662f\u5e38\u7528\u7684\u52a8\u6001\u7f51\u9875\u5f00\u53d1\u8bed\u8a00&#xff0c;Nginx \u901a\u8fc7 php-fpm&#xff08;PHP FastCGI \u8fdb\u7a0b\u7ba1\u7406\u5668&#xff09;\u6765\u89e3\u6790 PHP \u811a\u672c\u3002<\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u5b89\u88c5 PHP \u548c php-fpm&#xff08;php-fpm \u662f\u5904\u7406 PHP \u7684 FastCGI \u8fdb\u7a0b\u7ba1\u7406\u5668&#xff09;<\/span><br \/>\n<span class=\"token comment\"># \u8bf4\u660e&#xff1a;\u540c\u65f6\u5b89\u88c5\u5e38\u7528\u6269\u5c55&#xff08;\u5982 gd \u5904\u7406\u56fe\u7247\u3001mbstring \u5904\u7406\u591a\u5b57\u8282\u5b57\u7b26\u7b49&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># yum install -y php php-fpm<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># yum install -y php-gd php-common php-pear php-mbstring php-mcrypt<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u67e5\u770b PHP \u7248\u672c&#xff08;\u9a8c\u8bc1\u5b89\u88c5\u6210\u529f&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># php -v<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u6d4b\u8bd5 PHP \u547d\u4ee4\u884c\u8fd0\u884c\u662f\u5426\u6b63\u5e38<\/span><br \/>\n<span class=\"token comment\"># \u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684 PHP \u811a\u672c&#xff1a;\u8f93\u51fa &#034;PHP Test Page&#034; \u5e76\u6362\u884c<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># echo &#034;&lt;?php echo &#039;PHP Test Page&#039;.\\\\&#034;\\\\n\\\\&#034;; ?&gt;&#034; &gt; php_test.php <\/span><br \/>\n<span class=\"token comment\"># \u6267\u884c\u811a\u672c&#xff08;\u82e5\u8f93\u51fa &#034;PHP Test Page&#034; \u5219\u6b63\u5e38&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># php php_test.php <\/span><br \/>\nPHP Test Page<\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u51c6\u5907\u6d4b\u8bd5\u9875&#xff08;\u901a\u8fc7\u7f51\u9875\u8bbf\u95ee PHP \u4fe1\u606f&#xff09;<\/span><br \/>\n<span class=\"token comment\"># \u521b\u5efa info.php&#xff0c;\u5185\u5bb9\u4e3a phpinfo() \u51fd\u6570&#xff08;\u8f93\u51fa PHP \u8be6\u7ec6\u914d\u7f6e\u4fe1\u606f&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># echo &#034;&lt;?php phpinfo(); ?&gt;&#034; &gt; \/usr\/share\/nginx\/html\/info.php <\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u542f\u52a8 php-fpm \u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f&#xff08;\u5426\u5219 Nginx \u65e0\u6cd5\u89e3\u6790 PHP&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl enable php-fpm &#8211;now<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u914d\u7f6e Nginx \u89e3\u6790 PHP<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim \/etc\/nginx\/conf.d\/default.conf<\/span><br \/>\nserver <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token punctuation\">..<\/span>.<br \/>\n    <span class=\"token comment\"># \u6dfb\u52a0 PHP \u89e3\u6790\u89c4\u5219&#xff1a;\u5339\u914d .php \u7ed3\u5c3e\u7684\u8bf7\u6c42<\/span><br \/>\n    location ~ <span class=\"token punctuation\">\\\\<\/span>.php$ <span class=\"token punctuation\">{<\/span><br \/>\n        root           \/usr\/share\/nginx\/html<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># PHP \u6587\u4ef6\u5b58\u653e\u76ee\u5f55<\/span><br \/>\n        fastcgi_pass   <span class=\"token number\">127.0<\/span>.0.1:9000<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u8fde\u63a5 php-fpm \u8fdb\u7a0b&#xff08;\u9ed8\u8ba4\u76d1\u542c 9000 \u7aef\u53e3&#xff09;<\/span><br \/>\n        fastcgi_index  index.php<span class=\"token punctuation\">;<\/span>       <span class=\"token comment\"># \u9ed8\u8ba4 PHP \u9996\u9875<\/span><br \/>\n        <span class=\"token comment\"># \u529f\u80fd&#xff1a;\u6307\u5b9a PHP \u6587\u4ef6\u7684\u5b9e\u9645\u8def\u5f84&#xff08;\u4f9b php-fpm \u67e5\u627e\u6587\u4ef6&#xff09;<\/span><br \/>\n        <span class=\"token comment\"># \u53d8\u91cf\u8bf4\u660e&#xff1a;$document_root \u662f root \u914d\u7f6e\u7684\u76ee\u5f55&#xff0c;$fastcgi_script_name \u662f\u8bf7\u6c42\u7684 PHP \u6587\u4ef6\u540d<\/span><br \/>\n        fastcgi_param  SCRIPT_FILENAME  <span class=\"token variable\">$document_root<\/span><span class=\"token variable\">$fastcgi_script_name<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        include        fastcgi_params<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u5305\u542b FastCGI \u901a\u7528\u53c2\u6570&#xff08;\u5982\u8bf7\u6c42\u65b9\u6cd5\u3001URL \u7b49&#xff09;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u91cd\u542f Nginx \u670d\u52a1&#xff0c;\u4f7f\u914d\u7f6e\u751f\u6548<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl restart nginx<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u6d4b\u8bd5\u901a\u8fc7\u7f51\u9875\u8bbf\u95ee PHP \u9875\u9762&#xff08;\u5e94\u8f93\u51fa PHP \u914d\u7f6e\u4fe1\u606f&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;client ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl http:\/\/www.bq.cloud\/info.php<\/span><\/p>\n<h6>\u4f7f\u7528 FastCGI<\/h6>\n<p>FastCGI \u662f\u4e00\u79cd\u901a\u4fe1\u534f\u8bae&#xff0c;\u7528\u4e8e WEB \u670d\u52a1\u5668\u4e0e\u52a8\u6001\u811a\u672c\u5904\u7406\u5668\u4e4b\u95f4\u7684\u901a\u4fe1\u3002fcgiwrap \u662f\u4e00\u4e2a\u901a\u7528\u7684 FastCGI \u5904\u7406\u5668&#xff0c;\u53ef\u89e3\u6790\u591a\u79cd\u811a\u672c&#xff08;\u5982 Python\u3001Perl \u7b49&#xff09;\u3002<\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u4ece EPEL \u6e90\u5b89\u88c5 fcgiwrap&#xff08;FastCGI \u5904\u7406\u5668&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># yum install -y fcgiwrap<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u914d\u7f6e Nginx \u652f\u6301 FastCGI&#xff08;\u6307\u5b9a CGI \u811a\u672c\u5b58\u653e\u76ee\u5f55&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim \/etc\/nginx\/fcgiwrap.conf<\/span><br \/>\n<span class=\"token comment\"># \u793a\u4f8b&#xff1a;\u5141\u8bb8\u8bbf\u95ee \/cgi-bin\/ \u8def\u5f84\u4e0b\u7684 CGI \u811a\u672c<\/span><br \/>\nlocation \/cgi-bin\/ <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">gzip<\/span> off<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u5173\u95ed\u538b\u7f29&#xff08;\u907f\u514d\u4e8c\u8fdb\u5236\u6570\u636e\u538b\u7f29\u5bfc\u81f4\u89e3\u6790\u9519\u8bef&#xff09;<\/span><br \/>\n    root  \/usr\/share\/nginx<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u7f51\u7ad9\u6839\u76ee\u5f55&#xff08;\/cgi-bin\/ \u5b9e\u9645\u8def\u5f84\u4e3a \/usr\/share\/nginx\/cgi-bin\/&#xff09;<\/span><br \/>\n    fastcgi_pass  unix:\/var\/run\/fcgiwrap.socket<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u8fde\u63a5 fcgiwrap \u7684 Unix socket&#xff08;\u8fdb\u7a0b\u95f4\u901a\u4fe1\u7684\u4e00\u79cd\u65b9\u5f0f&#xff09;<\/span><br \/>\n    include \/etc\/nginx\/fastcgi_params<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u5305\u542b FastCGI \u901a\u7528\u53c2\u6570<\/span><br \/>\n    <span class=\"token comment\"># \u529f\u80fd&#xff1a;\u6307\u5b9a CGI \u811a\u672c\u7684\u5b9e\u9645\u8def\u5f84<\/span><br \/>\n    <span class=\"token comment\"># \u53d8\u91cf\u8bf4\u660e&#xff1a;$document_root \u662f root \u914d\u7f6e\u7684\u76ee\u5f55&#xff0c;$fastcgi_script_name \u662f\u8bf7\u6c42\u7684\u811a\u672c\u8def\u5f84<\/span><br \/>\n    fastcgi_param SCRIPT_FILENAME  <span class=\"token variable\">$document_root<\/span><span class=\"token variable\">$fastcgi_script_name<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u521b\u5efa CGI \u811a\u672c\u5b58\u653e\u76ee\u5f55&#xff08;\u6743\u9650\u8bbe\u4e3a 755&#xff0c;\u5141\u8bb8 Nginx \u8bbf\u95ee&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># mkdir -m 755 \/usr\/share\/nginx\/cgi-bin<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u5728 SSL \u7ad9\u70b9\u914d\u7f6e\u4e2d\u5f15\u5165 FastCGI \u89c4\u5219<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim \/etc\/nginx\/conf.d\/ssl.conf<\/span><br \/>\nserver <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token punctuation\">..<\/span><span class=\"token punctuation\">..<\/span>.<br \/>\n        include fcgiwrap.conf<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u5f15\u5165\u4e0a\u9762\u521b\u5efa\u7684 fcgiwrap \u914d\u7f6e<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u91cd\u542f Nginx \u670d\u52a1&#xff0c;\u4f7f\u914d\u7f6e\u751f\u6548<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl restart nginx<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u521b\u5efa fcgiwrap \u7684 systemd \u670d\u52a1\u6587\u4ef6&#xff08;\u7ba1\u7406 fcgiwrap \u8fdb\u7a0b&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim \/usr\/lib\/systemd\/system\/fcgiwrap.service<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>Unit<span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token assign-left variable\">Description<\/span><span class=\"token operator\">&#061;<\/span>Simple CGI Server  <span class=\"token comment\"># \u670d\u52a1\u63cf\u8ff0\u4fe1\u606f<\/span><br \/>\n<span class=\"token assign-left variable\">After<\/span><span class=\"token operator\">&#061;<\/span>nss-user-lookup.target  <span class=\"token comment\"># \u8868\u793a\u8be5\u670d\u52a1\u5728\u7528\u6237\u4fe1\u606f\u670d\u52a1\u542f\u52a8\u540e\u518d\u542f\u52a8<\/span><br \/>\n<span class=\"token assign-left variable\">Requires<\/span><span class=\"token operator\">&#061;<\/span>fcgiwrap.socket      <span class=\"token comment\"># \u4f9d\u8d56 fcgiwrap.socket \u670d\u52a1&#xff08;\u5fc5\u987b\u5148\u542f\u52a8 socket&#xff09;<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>Service<span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token assign-left variable\">EnvironmentFile<\/span><span class=\"token operator\">&#061;<\/span>\/etc\/sysconfig\/fcgiwrap  <span class=\"token comment\"># \u52a0\u8f7d\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u6587\u4ef6&#xff08;\u5b9a\u4e49\u8fdb\u7a0b\u6570\u7b49\u53c2\u6570&#xff09;<\/span><br \/>\n<span class=\"token comment\"># \u542f\u52a8 fcgiwrap \u8fdb\u7a0b&#xff0c;\u6307\u5b9a\u8fdb\u7a0b\u6570&#xff08;$DAEMON_PROCS \u4ece\u73af\u5883\u53d8\u91cf\u83b7\u53d6&#xff09;<\/span><br \/>\n<span class=\"token assign-left variable\">ExecStart<\/span><span class=\"token operator\">&#061;<\/span>\/usr\/sbin\/fcgiwrap <span class=\"token variable\">${DAEMON_OPTS}<\/span> <span class=\"token parameter variable\">-c<\/span> <span class=\"token variable\">${DAEMON_PROCS}<\/span><br \/>\n<span class=\"token assign-left variable\">User<\/span><span class=\"token operator\">&#061;<\/span>nginx  <span class=\"token comment\"># \u8fd0\u884c\u8fdb\u7a0b\u7684\u7528\u6237&#xff08;\u4e0e Nginx \u4e00\u81f4&#xff0c;\u907f\u514d\u6743\u9650\u95ee\u9898&#xff09;<\/span><br \/>\n<span class=\"token assign-left variable\">Group<\/span><span class=\"token operator\">&#061;<\/span>nginx <span class=\"token comment\"># \u8fd0\u884c\u8fdb\u7a0b\u7684\u7ec4<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>Install<span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token assign-left variable\">Also<\/span><span class=\"token operator\">&#061;<\/span>fcgiwrap.socket  <span class=\"token comment\"># \u5b89\u88c5\u65f6\u540c\u65f6\u542f\u7528 socket \u670d\u52a1<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u521b\u5efa fcgiwrap \u7684 socket \u914d\u7f6e\u6587\u4ef6&#xff08;\u5b9a\u4e49 socket \u8def\u5f84\u548c\u7c7b\u578b&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim \/usr\/lib\/systemd\/system\/fcgiwrap.socket<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>Unit<span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token assign-left variable\">Description<\/span><span class=\"token operator\">&#061;<\/span>fcgiwrap Socket  <span class=\"token comment\"># socket \u63cf\u8ff0\u4fe1\u606f<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>Socket<span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token assign-left variable\">ListenStream<\/span><span class=\"token operator\">&#061;<\/span>\/run\/fcgiwrap.socket  <span class=\"token comment\"># \u76d1\u542c\u7684 Unix socket \u8def\u5f84&#xff08;\u9700\u4e0e Nginx \u914d\u7f6e\u4e2d\u7684\u8def\u5f84\u4e00\u81f4&#xff09;<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>Install<span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token assign-left variable\">WantedBy<\/span><span class=\"token operator\">&#061;<\/span>sockets.target  <span class=\"token comment\"># \u5c5e\u4e8e sockets.target \u76ee\u6807&#xff08;\u7cfb\u7edf\u542f\u52a8\u65f6\u6fc0\u6d3b&#xff09;<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u542f\u52a8 fcgiwrap \u670d\u52a1\u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl enable &#8211;now fcgiwrap<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u82e5 SELinux \u542f\u7528&#xff0c;\u9700\u4fee\u6539\u7b56\u7565\u5141\u8bb8 Nginx \u8bbf\u95ee fcgiwrap \u7684 socket<\/span><br \/>\n<span class=\"token comment\"># \u521b\u5efa SELinux \u6a21\u5757\u6587\u4ef6&#xff08;\u5141\u8bb8 httpd_t \u57df\u5199\u5165 var_run_t \u7c7b\u578b\u7684 socket \u6587\u4ef6&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim nginx-www.te<\/span><br \/>\nmodule nginx-server <span class=\"token number\">1.0<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u6a21\u5757\u540d\u79f0\u548c\u7248\u672c<\/span><\/p>\n<p>require <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token builtin class-name\">type<\/span> httpd_t<span class=\"token punctuation\">;<\/span>       <span class=\"token comment\"># Nginx \u8fdb\u7a0b\u7684 SELinux \u57df<\/span><br \/>\n        <span class=\"token builtin class-name\">type<\/span> var_run_t<span class=\"token punctuation\">;<\/span>     <span class=\"token comment\"># \/run \u76ee\u5f55\u7684 SELinux \u7c7b\u578b<\/span><br \/>\n        class sock_file <span class=\"token function\">write<\/span><span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u5141\u8bb8\u7684\u64cd\u4f5c&#xff1a;\u5199\u5165 socket \u6587\u4ef6<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\"># \u5141\u8bb8 httpd_t \u57df\u5bf9 var_run_t \u7c7b\u578b\u7684 socket \u6587\u4ef6\u6267\u884c\u5199\u5165\u64cd\u4f5c<\/span><br \/>\nallow httpd_t var_run_t:sock_file <span class=\"token function\">write<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\"># \u7f16\u8bd1 SELinux \u6a21\u5757&#xff1a;<\/span><br \/>\n<span class=\"token comment\"># 1. \u5c06 .te \u6587\u4ef6\u8f6c\u6362\u4e3a\u4e8c\u8fdb\u5236\u6a21\u5757&#xff08;.mod&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># checkmodule -m -M -o nginx-server.mod nginx-server.te<\/span><br \/>\n<span class=\"token comment\"># 2. \u5c06 .mod \u6587\u4ef6\u6253\u5305\u4e3a\u53ef\u5b89\u88c5\u7684 .pp \u5305<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># semodule_package &#8211;outfile nginx-server.pp &#8211;module nginx-server.mod<\/span><br \/>\n<span class=\"token comment\"># 3. \u5b89\u88c5\u6a21\u5757&#xff08;\u4f7f\u7b56\u7565\u751f\u6548&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># semodule -i nginx-server.pp<\/span><\/p>\n<p>\u6d4b\u8bd5 FastCGI<\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u51c6\u5907\u6d4b\u8bd5\u811a\u672c&#xff08;\u4ee5 Python3 \u4e3a\u4f8b&#xff0c;\u653e\u5728 \/cgi-bin\/ \u76ee\u5f55\u4e0b&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim \/usr\/share\/nginx\/cgi-bin\/index.cgi<\/span><br \/>\n<span class=\"token comment\">#!\/usr\/bin\/python3  # \u6307\u5b9a\u811a\u672c\u89e3\u91ca\u5668&#xff08;Python3&#xff09;<\/span><br \/>\n<span class=\"token comment\"># CGI \u534f\u8bae\u8981\u6c42&#xff1a;\u5fc5\u987b\u5148\u8f93\u51fa Content-type \u5934\u90e8&#xff0c; followed by \u7a7a\u884c&#xff08;\u544a\u8bc9\u6d4f\u89c8\u5668\u5185\u5bb9\u7c7b\u578b&#xff09;<\/span><br \/>\nprint<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Content-type: text\/html<span class=\"token entity\" title=\"\\\\n\">\\\\n<\/span>&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\nprint<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;&lt;html&gt;<span class=\"token entity\" title=\"\\\\n\">\\\\n<\/span>&lt;body&gt;&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\nprint<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;&lt;div style&#061;<span class=\"token entity\" title=\"\\\\&#034;\">\\\\&#034;<\/span>width: 100%; font-size: 40px; font-weight: bold; text-align: center;<span class=\"token entity\" title=\"\\\\&#034;\">\\\\&#034;<\/span>&gt;&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\nprint<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;CGI Script Test Page&#034;<\/span><span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># \u9875\u9762\u5185\u5bb9&#xff1a;CGI \u6d4b\u8bd5\u9875<\/span><br \/>\nprint<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;&lt;\/div&gt;&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\nprint<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;&lt;\/body&gt;<span class=\"token entity\" title=\"\\\\n\">\\\\n<\/span>&lt;\/html&gt;&#034;<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u7ed9\u811a\u672c\u6dfb\u52a0\u6267\u884c\u6743\u9650&#xff08;\u5426\u5219\u65e0\u6cd5\u8fd0\u884c&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># chmod 755 \/usr\/share\/nginx\/cgi-bin\/index.cgi <\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u6d4b\u8bd5\u8bbf\u95ee CGI \u811a\u672c&#xff08;\u5e94\u8f93\u51fa\u6d4b\u8bd5\u9875\u9762\u5185\u5bb9&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;client ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl http:\/\/www.bq.cloud\/cgi-bin\/index.cgi<\/span><\/p>\n<h5>\u90e8\u7f72\u53cd\u5411\u4ee3\u7406<\/h5>\n<p>\u53cd\u5411\u4ee3\u7406\u7b80\u5355\u8bf4\u5c31\u662f&#xff1a;\u7528\u6237&#xff08;\u5ba2\u6237\u7aef&#xff09;\u53ea\u8bbf\u95ee\u4ee3\u7406\u670d\u52a1\u5668&#xff0c;\u4ee3\u7406\u670d\u52a1\u5668\u5077\u5077\u628a\u8bf7\u6c42\u8f6c\u53d1\u7ed9\u5185\u90e8\u7684\u771f\u5b9e\u670d\u52a1\u5668&#xff0c;\u7136\u540e\u628a\u771f\u5b9e\u670d\u52a1\u5668\u7684\u54cd\u5e94\u8fd4\u56de\u7ed9\u7528\u6237\u3002\u8fd9\u6837\u7528\u6237\u770b\u4e0d\u5230\u771f\u5b9e\u670d\u52a1\u5668\u7684 IP&#xff08;\u66f4\u5b89\u5168&#xff09;&#xff0c;\u8fd8\u80fd\u901a\u8fc7\u4ee3\u7406\u5b9e\u73b0\u8d1f\u8f7d\u5747\u8861&#xff08;\u591a\u53f0\u771f\u5b9e\u670d\u52a1\u5668\u5206\u62c5\u538b\u529b&#xff09;\u3001\u7f13\u5b58&#xff08;\u52a0\u901f\u8bbf\u95ee&#xff09;\u7b49\u529f\u80fd\u3002<\/p>\n<h6>\u89d2\u8272\u8bf4\u660e<\/h6>\n<ul>\n<li>\u4ee3\u7406\u670d\u52a1\u5668&#xff1a;IP \u4e3a 10.1.8.20&#xff08;\u7528\u6237\u76f4\u63a5\u8bbf\u95ee\u6b64\u670d\u52a1\u5668&#xff09;\u3002<\/li>\n<li>\u771f\u5b9e\u670d\u52a1\u5668&#xff1a;IP \u4e3a 10.1.8.10&#xff08;\u5b9e\u9645\u5904\u7406\u8bf7\u6c42\u7684\u670d\u52a1\u5668&#xff0c;\u5bf9\u7528\u6237\u4e0d\u53ef\u89c1&#xff09;\u3002<\/li>\n<\/ul>\n<h6>\u4ee3\u7406\u670d\u52a1\u5668\u914d\u7f6e<\/h6>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u914d\u7f6e\u57df\u540d\u89e3\u6790&#xff0c;\u4f7f\u4ee3\u7406\u670d\u52a1\u5668\u80fd\u901a\u8fc7\u57df\u540d\u8bbf\u95ee\u771f\u5b9e\u670d\u52a1\u5668<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;proxy ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># echo &#039;10.1.8.10 www.bq.cloud&#039; &gt;&gt; \/etc\/hosts<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u5b89\u88c5 Nginx&#xff08;\u4ee3\u7406\u670d\u52a1\u5668\u4e5f\u9700\u8981 Nginx \u6765\u5904\u7406\u8f6c\u53d1&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;proxy ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># yum -y install nginx<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u542f\u52a8 Nginx \u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;proxy ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl enable &#8211;now nginx<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u914d\u7f6e\u9632\u706b\u5899&#xff0c;\u5141\u8bb8 HTTP \u670d\u52a1\u901a\u8fc7<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;proxy ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># firewall-cmd &#8211;add-service&#061;http &#8211;permanent<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;proxy ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># firewall-cmd &#8211;reload<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u914d\u7f6e\u53cd\u5411\u4ee3\u7406\u89c4\u5219&#xff08;\u4fee\u6539 Nginx \u4e3b\u914d\u7f6e&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;proxy ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim \/etc\/nginx\/nginx.conf<\/span><br \/>\n<span class=\"token comment\"># \u4fee\u6539 server \u5757\u5982\u4e0b<\/span><br \/>\n    server <span class=\"token punctuation\">{<\/span><br \/>\n        listen      <span class=\"token number\">80<\/span> default_server<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u76d1\u542c 80 \u7aef\u53e3&#xff08;\u7528\u6237\u8bbf\u95ee\u7684\u7aef\u53e3&#xff09;<\/span><br \/>\n        listen      <span class=\"token punctuation\">[<\/span>::<span class=\"token punctuation\">]<\/span>:80 default_server<span class=\"token punctuation\">;<\/span><br \/>\n        server_name _<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u4e0d\u6307\u5b9a\u5177\u4f53\u57df\u540d&#xff08;\u5339\u914d\u6240\u6709\u672a\u88ab\u5176\u4ed6 server \u5339\u914d\u7684\u8bf7\u6c42&#xff09;<\/span><br \/>\n        root         \/usr\/share\/nginx\/html<span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token comment\"># \u53cd\u5411\u4ee3\u7406\u76f8\u5173\u914d\u7f6e&#xff1a;<\/span><br \/>\n        proxy_redirect      off<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># \u7981\u6b62\u81ea\u52a8\u91cd\u5b9a\u5411&#xff08;\u907f\u514d\u771f\u5b9e\u670d\u52a1\u5668\u7684\u91cd\u5b9a\u5411\u88ab\u4fee\u6539&#xff09;<\/span><br \/>\n        <span class=\"token comment\"># \u4f20\u9012\u5ba2\u6237\u7aef\u771f\u5b9e IP \u7ed9\u771f\u5b9e\u670d\u52a1\u5668&#xff08;\u771f\u5b9e\u670d\u52a1\u5668\u53ef\u901a\u8fc7 X-Real-IP \u83b7\u53d6\u7528\u6237 IP&#xff09;<\/span><br \/>\n        proxy_set_header    X-Real-IP <span class=\"token variable\">$remote_addr<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token comment\"># \u4f20\u9012\u4ee3\u7406\u94fe\u4fe1\u606f&#xff08;\u82e5\u6709\u591a\u5c42\u4ee3\u7406&#xff0c;\u771f\u5b9e\u670d\u52a1\u5668\u53ef\u901a\u8fc7 X-Forwarded-For \u83b7\u53d6\u6240\u6709\u4ee3\u7406 IP&#xff09;<\/span><br \/>\n        proxy_set_header    X-Forwarded-For <span class=\"token variable\">$proxy_add_x_forwarded_for<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token comment\"># \u4f20\u9012\u7528\u6237\u8bf7\u6c42\u7684 Host \u5934\u90e8&#xff08;\u771f\u5b9e\u670d\u52a1\u5668\u53ef\u77e5\u9053\u7528\u6237\u8bbf\u95ee\u7684\u57df\u540d&#xff09;<\/span><br \/>\n        proxy_set_header    Host <span class=\"token variable\">$http_host<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token punctuation\">..<\/span><span class=\"token punctuation\">..<\/span><span class=\"token punctuation\">..<\/span><\/p>\n<p>        <span class=\"token comment\"># \u529f\u80fd&#xff1a;\u5c06 \/proxy\/ \u8def\u5f84\u7684\u8bf7\u6c42\u8f6c\u53d1\u5230\u771f\u5b9e\u670d\u52a1\u5668<\/span><br \/>\n        location \/proxy\/ <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token comment\"># \u529f\u80fd&#xff1a;\u6307\u5b9a\u771f\u5b9e\u670d\u52a1\u5668\u5730\u5740&#xff08;www.bq.cloud \u5df2\u89e3\u6790\u5230 10.1.8.10&#xff09;<\/span><br \/>\n            <span class=\"token comment\"># \u8bf4\u660e&#xff1a;\u672b\u5c3e\u7684 \/ \u8868\u793a\u5c06 \/proxy\/ \u540e\u9762\u7684\u8def\u5f84\u62fc\u63a5\u5230\u771f\u5b9e\u670d\u52a1\u5668\u5730\u5740\u540e<\/span><br \/>\n            <span class=\"token comment\"># \u4f8b\u5982&#xff1a;\u7528\u6237\u8bbf\u95ee \/proxy\/test.html&#xff0c;\u4f1a\u8f6c\u53d1\u5230 http:\/\/www.bq.cloud\/test.html<\/span><br \/>\n            proxy_pass http:\/\/www.bq.cloud\/<span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u91cd\u542f Nginx \u670d\u52a1&#xff0c;\u4f7f\u4ee3\u7406\u914d\u7f6e\u751f\u6548<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;proxy ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl restart nginx<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u82e5 SELinux \u542f\u7528&#xff0c;\u9700\u5141\u8bb8 Nginx \u53d1\u8d77\u7f51\u7edc\u8fde\u63a5&#xff08;\u53cd\u5411\u4ee3\u7406\u9700\u8981\u8bbf\u95ee\u771f\u5b9e\u670d\u52a1\u5668&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;proxy ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># setsebool -P httpd_can_network_connect on<\/span><\/p>\n<h6>\u771f\u5b9e\u670d\u52a1\u5668\u914d\u7f6e<\/h6>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u5b89\u88c5 Nginx&#xff08;\u771f\u5b9e\u670d\u52a1\u5668\u63d0\u4f9b\u5b9e\u9645\u7684\u7f51\u9875\u5185\u5bb9&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># yum -y install nginx<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u542f\u52a8 Nginx \u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl enable &#8211;now nginx<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u914d\u7f6e\u9632\u706b\u5899&#xff0c;\u5141\u8bb8 HTTP \u670d\u52a1\u901a\u8fc7&#xff08;\u63a5\u6536\u4ee3\u7406\u670d\u52a1\u5668\u7684\u8bf7\u6c42&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># firewall-cmd &#8211;add-service&#061;http &#8211;permanent<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># firewall-cmd &#8211;reload<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u51c6\u5907\u6d4b\u8bd5\u9875&#xff08;\u4f9b\u4ee3\u7406\u670d\u52a1\u5668\u8f6c\u53d1\u8bbf\u95ee&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># echo hello bq &gt; \/usr\/share\/nginx\/html\/test.html<\/span><\/p>\n<p><span class=\"token comment\"># \u6d4b\u8bd5\u6548\u679c&#xff1a;\u7528\u6237\u8bbf\u95ee\u4ee3\u7406\u670d\u52a1\u5668\u7684 \/proxy\/test.html&#xff0c;\u5e94\u8fd4\u56de\u771f\u5b9e\u670d\u52a1\u5668\u7684\u5185\u5bb9<\/span><br \/>\n<span class=\"token comment\"># \u8bf4\u660e&#xff1a;\u7528\u6237\u7684\u5ba2\u6237\u7aef\u9700\u914d\u7f6e hosts \u4f7f www.bq.cloud \u6307\u5411\u4ee3\u7406\u670d\u52a1\u5668 IP&#xff08;10.1.8.20&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;client ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl http:\/\/www.bq.cloud\/proxy\/test.html<\/span><br \/>\n<span class=\"token comment\"># \u9884\u671f\u8f93\u51fa&#xff1a;hello bq<\/span><\/p>\n<h5>Nginx \u5e38\u7528\u8865\u5145\u547d\u4ee4<\/h5>\n<li>\n<p>\u68c0\u67e5\u914d\u7f6e\u6587\u4ef6\u8bed\u6cd5\u662f\u5426\u6b63\u786e&#xff08;\u4fee\u6539\u914d\u7f6e\u540e\u5fc5\u505a&#xff0c;\u907f\u514d\u914d\u7f6e\u9519\u8bef\u5bfc\u81f4\u670d\u52a1\u542f\u52a8\u5931\u8d25&#xff09;&#xff1a;<\/p>\n<p>nginx <span class=\"token parameter variable\">-t<\/span><\/p>\n<\/li>\n<li>\n<p>\u5e73\u6ed1\u91cd\u542f Nginx&#xff08;\u4e0d\u4e2d\u65ad\u670d\u52a1&#xff0c;\u4f7f\u914d\u7f6e\u751f\u6548&#xff0c;\u63a8\u8350\u4f7f\u7528&#xff09;&#xff1a;<\/p>\n<p>nginx <span class=\"token parameter variable\">-s<\/span> reload<\/p>\n<\/li>\n<li>\n<p>\u505c\u6b62 Nginx \u670d\u52a1&#xff1a;<\/p>\n<p>systemctl stop nginx<\/p>\n<\/li>\n<li>\n<p>\u67e5\u770b Nginx \u7248\u672c\u53ca\u7f16\u8bd1\u53c2\u6570&#xff08;\u4e86\u89e3\u670d\u52a1\u5668\u5b89\u88c5\u7684 Nginx \u7279\u6027&#xff09;&#xff1a;<\/p>\n<p>nginx <span class=\"token parameter variable\">-V<\/span><\/p>\n<\/li>\n<li>\n<p>\u67e5\u770b Nginx \u8fdb\u7a0b\u72b6\u6001&#xff08;\u68c0\u67e5\u670d\u52a1\u662f\u5426\u6b63\u5e38\u8fd0\u884c&#xff09;&#xff1a;<\/p>\n<p>systemctl status nginx<\/p>\n<\/li>\n<li>\n<p>\u67e5\u770b Nginx \u8bbf\u95ee\u65e5\u5fd7&#xff08;\u5206\u6790\u7528\u6237\u8bbf\u95ee\u60c5\u51b5&#xff0c;\u9ed8\u8ba4\u8def\u5f84&#xff1a;\/var\/log\/nginx\/access.log&#xff09;&#xff1a;<\/p>\n<p><span class=\"token function\">tail<\/span> <span class=\"token parameter variable\">-f<\/span> \/var\/log\/nginx\/access.log  <span class=\"token comment\"># \u5b9e\u65f6\u67e5\u770b\u6700\u65b0\u65e5\u5fd7<\/span><\/p>\n<\/li>\n<li>\n<p>\u67e5\u770b Nginx \u9519\u8bef\u65e5\u5fd7&#xff08;\u6392\u67e5\u670d\u52a1\u5f02\u5e38&#xff0c;\u9ed8\u8ba4\u8def\u5f84&#xff1a;\/var\/log\/nginx\/error.log&#xff09;&#xff1a;<\/p>\n<p><span class=\"token function\">tail<\/span> <span class=\"token parameter variable\">-f<\/span> \/var\/log\/nginx\/error.log<\/p>\n<\/li>\n<h3>Tomcat<\/h3>\n<h4>Tomcat \u7531\u6765<\/h4>\n<p>Tomcat \u6700\u521d\u7531 Sun \u516c\u53f8\u7684\u8a79\u59c6\u65af\u30fb\u9093\u80af\u30fb\u6234\u7ef4\u68ee\u5f00\u53d1&#xff0c;\u540e\u6765\u4ed6\u5c06\u5176\u5f00\u6e90&#xff0c;\u5e76\u7531 Sun \u8d21\u732e\u7ed9 Apache \u8f6f\u4ef6\u57fa\u91d1\u4f1a\u3002\u56e0\u4e3a\u5f53\u65f6\u5f88\u591a\u5f00\u6e90\u9879\u76ee\u7684 O\u2019Reilly \u4e66\u7c4d\u5c01\u9762\u90fd\u4f1a\u8bbe\u8ba1\u6210\u52a8\u7269\u7d20\u63cf&#xff0c;\u4ed6\u5e0c\u671b\u8fd9\u4e2a\u9879\u76ee\u80fd\u50cf \u201c\u516c\u732b&#xff08;Tomcat&#xff09;\u201d \u4e00\u6837 \u201c\u80fd\u81ea\u5df1\u7167\u987e\u81ea\u5df1\u201d&#xff08;\u7a33\u5b9a\u8fd0\u884c&#xff09;&#xff0c;\u56e0\u6b64\u547d\u540d\u4e3a Tomcat\u3002O\u2019Reilly \u51fa\u7248\u7684 Tomcat \u4e66\u7c4d\u5c01\u9762\u4e5f\u7528\u4e86\u516c\u732b\u5f62\u8c61&#xff0c;Tomcat \u7684 Logo \u548c\u5409\u7965\u7269\u4e5f\u968f\u4e4b\u5b9a\u4e3a\u4e00\u53ea\u516c\u732b\u3002<\/p>\n<h4>Tomcat \u4ecb\u7ecd<\/h4>\n<p>Tomcat \u662f\u4e00\u6b3e\u514d\u8d39\u5f00\u6e90\u7684 Web \u5e94\u7528\u670d\u52a1\u5668&#xff0c;\u5c5e\u4e8e\u8f7b\u91cf\u7ea7\u670d\u52a1\u5668&#xff0c;\u9002\u5408\u4e2d\u5c0f\u578b\u7cfb\u7edf\u548c\u5e76\u53d1\u8bbf\u95ee\u91cf\u4e0d\u9ad8\u7684\u573a\u666f&#xff0c;\u662f\u5f00\u53d1\u548c\u8c03\u8bd5 JSP \u7a0b\u5e8f\u7684\u9996\u9009\u5de5\u5177\u3002\u5b83\u6280\u672f\u5148\u8fdb\u3001\u6027\u80fd\u7a33\u5b9a\u4e14\u514d\u8d39&#xff0c;\u6df1\u53d7 Java \u5f00\u53d1\u8005\u559c\u7231&#xff0c;\u6210\u4e3a\u6d41\u884c\u7684 Web \u5e94\u7528\u670d\u52a1\u5668\u3002<\/p>\n<p>Tomcat \u4e0d\u4ec5\u662f Java \u5bb9\u5668&#xff08;\u8fd0\u884c Java \u7a0b\u5e8f&#xff09;&#xff0c;\u4e5f\u80fd\u5904\u7406 HTML \u7b49\u9759\u6001\u9875\u9762&#xff0c;\u4f46\u548c Apache\u3001Nginx \u76f8\u6bd4&#xff0c;\u5904\u7406\u9759\u6001\u9875\u9762\u7684\u6548\u7387\u8f83\u4f4e\u3002\u56e0\u6b64&#xff0c;\u5b9e\u9645\u4e2d\u5e38\u5c06 Tomcat \u548c Apache\/Nginx \u914d\u5408\u4f7f\u7528&#xff1a;\u8ba9 Apache\/Nginx \u5904\u7406\u9759\u6001 HTML&#xff0c;Tomcat \u5904\u7406 JSP \u548c Java \u7a0b\u5e8f&#xff08;\u5206\u5de5\u5408\u4f5c&#xff0c;\u63d0\u9ad8\u6548\u7387&#xff09;\u3002<\/p>\n<p>JSP&#xff08;Java Server Pages&#xff09; \u662f\u4e00\u79cd\u52a8\u6001\u7f51\u9875\u6280\u672f&#xff1a;\u5728\u4f20\u7edf HTML \u4e2d\u63d2\u5165 Java \u7a0b\u5e8f\u6bb5\u548c JSP \u6807\u8bb0&#xff0c;\u5f62\u6210 .jsp \u6587\u4ef6\u3002\u7528 JSP \u5f00\u53d1\u7684 Web \u5e94\u7528\u662f\u8de8\u5e73\u53f0\u7684&#xff0c;\u65e2\u80fd\u5728 Linux \u4e0a\u8fd0\u884c&#xff0c;\u4e5f\u80fd\u5728\u5176\u4ed6\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u8fd0\u884c\u3002<\/p>\n<p>\u5b98\u65b9\u7f51\u7ad9&#xff1a;http:\/\/tomcat.apache.org\/<\/p>\n<p>Tomcat \u867d\u7136\u80fd\u8fd0\u884c JSP \u7f51\u9875&#xff0c;\u4f46\u901a\u5e38\u4e0d\u5355\u72ec\u4f5c\u4e3a Web \u670d\u52a1\u5668&#xff0c;\u800c\u662f\u4f5c\u4e3a\u4e2d\u95f4\u4ef6&#xff08;\u4e13\u6ce8\u5904\u7406 Java \u7a0b\u5e8f&#xff09;\u3002<\/p>\n<h4>Tomcat \u76f8\u5173\u5b9e\u9a8c\u6d41\u7a0b<\/h4>\n<h5>1. Tomcat \u90e8\u7f72<\/h5>\n<li>\u5b89\u88c5 Tomcat&#xff08;\u4f1a\u81ea\u52a8\u5b89\u88c5\u76f8\u5173 Java \u73af\u5883&#xff09;<\/li>\n<li>\u9a8c\u8bc1 Java \u7248\u672c<\/li>\n<li>\u542f\u52a8 Tomcat \u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f<\/li>\n<li>\u51c6\u5907 JSP \u6d4b\u8bd5\u9875\u9762&#xff08;\u653e\u5728\u9ed8\u8ba4\u53d1\u5e03\u76ee\u5f55\u4e0b&#xff09;<\/li>\n<li>\u6d4b\u8bd5\u8bbf\u95ee JSP \u9875\u9762<\/li>\n<h5>2. \u914d\u7f6e\u7ba1\u7406\u754c\u9762<\/h5>\n<li>\u5b89\u88c5\u7ba1\u7406\u9875\u9762\u53ca\u53ef\u9009\u7684\u5728\u7ebf\u6587\u6863<\/li>\n<li>\u6dfb\u52a0\u7ba1\u7406\u5458\u7528\u6237&#xff08;\u914d\u7f6e tomcat-users.xml \u6587\u4ef6&#xff09;<\/li>\n<li>\u91cd\u542f Tomcat \u670d\u52a1\u5668<\/li>\n<li>\u4ece\u672c\u5730\u8bbf\u95ee\u7ba1\u7406\u754c\u9762<\/li>\n<h5>3. \u9879\u76ee\u5b9e\u6218&#xff08;Nginx \u53cd\u5411\u4ee3\u7406 Tomcat&#xff09;<\/h5>\n<li>\u5728\u5ba2\u6237\u7aef&#xff08;\u4f5c\u4e3a Nginx \u53cd\u5411\u4ee3\u7406&#xff09;\u5b89\u88c5 Nginx<\/li>\n<li>\u914d\u7f6e Nginx \u53cd\u5411\u4ee3\u7406\u89c4\u5219&#xff08;\u8bbe\u7f6e upstream \u6307\u5411 Tomcat \u670d\u52a1\u5668&#xff0c;\u6dfb\u52a0\u4ee3\u7406\u76f8\u5173\u53c2\u6570\u53ca\u8f6c\u53d1\u8def\u5f84&#xff09;<\/li>\n<li>\u91cd\u542f Nginx \u670d\u52a1<\/li>\n<li>\u51c6\u5907 Nginx \u6d4b\u8bd5\u9875\u9762<\/li>\n<li>\u5ba2\u6237\u7aef\u901a\u8fc7\u7f51\u9875\u6d4f\u89c8\u6d4b\u8bd5\u4e0d\u540c\u8def\u5f84\u7684\u8bbf\u95ee\u6548\u679c<\/li>\n<h4>Tomcat\u5b9e\u9a8c\u64cd\u4f5c<\/h4>\n<h5>Tomcat \u90e8\u7f72<\/h5>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u5b89\u88c5 tomcat&#xff0c;\u4f1a\u81ea\u52a8\u5b89\u88c5\u4f9d\u8d56\u7684 Java \u73af\u5883&#xff08;java-1.8.0-openjdk-headless&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># yum install -y tomcat<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u9a8c\u8bc1 Java \u73af\u5883\u662f\u5426\u5b89\u88c5\u6210\u529f&#xff08;Tomcat \u4f9d\u8d56 Java \u8fd0\u884c&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># java -version<\/span><br \/>\nopenjdk version <span class=\"token string\">&#034;1.8.0_412&#034;<\/span><br \/>\nOpenJDK Runtime Environment <span class=\"token punctuation\">(<\/span>build <span class=\"token number\">1.8<\/span>.0_412-b08<span class=\"token punctuation\">)<\/span><br \/>\nOpenJDK <span class=\"token number\">64<\/span>-Bit Server VM <span class=\"token punctuation\">(<\/span>build <span class=\"token number\">25.412<\/span>-b08, mixed mode<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u542f\u52a8 tomcat \u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl enable &#8211;now tomcat.service<\/span><\/p>\n<p><span class=\"token comment\"># \u8bf4\u660e&#xff1a;Tomcat \u9ed8\u8ba4\u53d1\u5e03\u76ee\u5f55\u662f \/var\/lib\/tomcat\/webapps&#xff08;\u7f51\u9875\u6587\u4ef6\u5b58\u653e\u5728\u8fd9\u91cc&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># grep ^TOMCATS_BASE \/etc\/tomcat\/tomcat.conf  # \u67e5\u770b\u57fa\u7840\u76ee\u5f55<\/span><br \/>\n<span class=\"token assign-left variable\">TOMCATS_BASE<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;\/var\/lib\/tomcats\/&#034;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># grep appBase \/etc\/tomcat\/server.xml  # \u67e5\u770b\u5e94\u7528\u53d1\u5e03\u76ee\u5f55<\/span><br \/>\n      <span class=\"token operator\">&lt;<\/span>Host <span class=\"token assign-left variable\">name<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;localhost&#034;<\/span>  <span class=\"token assign-left variable\">appBase<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;webapps&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u51c6\u5907\u6d4b\u8bd5\u9875\u9762&#xff08;JSP \u9875\u9762&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># cd \/var\/lib\/tomcat\/webapps\/  # \u8fdb\u5165\u53d1\u5e03\u76ee\u5f55<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server webapps<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># mkdir test  # \u521b\u5efa\u6d4b\u8bd5\u76ee\u5f55<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server webapps<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim test\/index.jsp  # \u521b\u5efa JSP \u6d4b\u8bd5\u9875<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>html<span class=\"token operator\">&gt;<\/span><br \/>\n    <span class=\"token operator\">&lt;<\/span>head<span class=\"token operator\">&gt;<\/span><br \/>\n           <span class=\"token operator\">&lt;<\/span>title<span class=\"token operator\">&gt;<\/span>\u7b2c\u4e00\u4e2a JSP \u7a0b\u5e8f<span class=\"token operator\">&lt;<\/span>\/title<span class=\"token operator\">&gt;<\/span>  <span class=\"token operator\">&lt;<\/span><span class=\"token operator\">!<\/span>&#8212; \u9875\u9762\u6807\u9898 &#8212;<span class=\"token operator\">&gt;<\/span><br \/>\n    <span class=\"token operator\">&lt;<\/span>\/head<span class=\"token operator\">&gt;<\/span><br \/>\n    <span class=\"token operator\">&lt;<\/span>body<span class=\"token operator\">&gt;<\/span><br \/>\n           <span class=\"token operator\">&lt;<\/span>%<br \/>\n                  out.println<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Hello World!&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>  \/\/ Java \u4ee3\u7801&#xff1a;\u8f93\u51fa Hello World<span class=\"token operator\">!<\/span><br \/>\n           %<span class=\"token operator\">&gt;<\/span><br \/>\n    <span class=\"token operator\">&lt;<\/span>\/body<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>\/html<span class=\"token operator\">&gt;<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u6d4b\u8bd5\u8bbf\u95ee JSP \u9875\u9762&#xff08;Tomcat \u9ed8\u8ba4\u7aef\u53e3 8080&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl http:\/\/www.laoma.cloud:8080\/test\/index.jsp<\/span><\/p>\n<h5>\u7ba1\u7406\u754c\u9762<\/h5>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u5b89\u88c5 Tomcat \u7ba1\u7406\u9875\u9762&#xff08;webapps \u5305\u542b\u9ed8\u8ba4\u5e94\u7528&#xff0c;admin-webapps \u5305\u542b\u7ba1\u7406\u754c\u9762&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># yum install -y tomcat-webapps tomcat-admin-webapps<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u5b89\u88c5\u5728\u7ebf\u6587\u6863&#xff08;\u53ef\u9009&#xff0c;\u65b9\u4fbf\u67e5\u9605\u4f7f\u7528\u8bf4\u660e&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># yum install -y tomcat-docs-webapp<\/span><\/p>\n<p>\u5982\u679c\u670d\u52a1\u5668\u6ca1\u6709\u56fe\u5f62\u5316\u754c\u9762&#xff0c;\u9700\u5b89\u88c5\u4ee5\u4e0b\u8f6f\u4ef6\u5305\u624d\u80fd\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u7ba1\u7406\u754c\u9762&#xff1a;<\/p>\n<p>yum <span class=\"token function\">install<\/span> <span class=\"token parameter variable\">-y<\/span> mesa-dri-drivers libglvnd-glx xorg-x11-xauth firefox<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813234443-689d236b2eb6b.png\" alt=\"image-20240807224659327\" \/><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u6dfb\u52a0\u7ba1\u7406\u5458\u7528\u6237&#xff08;\u7528\u4e8e\u767b\u5f55\u7ba1\u7406\u754c\u9762&#xff09;<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim \/etc\/tomcat\/tomcat-users.xml <\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>?xml <span class=\"token assign-left variable\">version<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;1.0&#039;<\/span> <span class=\"token assign-left variable\">encoding<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;utf-8&#039;<\/span>?<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token punctuation\">..<\/span><span class=\"token punctuation\">..<\/span><span class=\"token punctuation\">..<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>role <span class=\"token assign-left variable\">rolename<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;manager-gui&#034;<\/span>\/<span class=\"token operator\">&gt;<\/span>  <span class=\"token operator\">&lt;<\/span><span class=\"token operator\">!<\/span>&#8212; \u5b9a\u4e49 manager \u7ba1\u7406\u754c\u9762\u7684\u89d2\u8272 &#8212;<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>role <span class=\"token assign-left variable\">rolename<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;admin-gui&#034;<\/span>\/<span class=\"token operator\">&gt;<\/span>    <span class=\"token operator\">&lt;<\/span><span class=\"token operator\">!<\/span>&#8212; \u5b9a\u4e49 admin \u7ba1\u7406\u754c\u9762\u7684\u89d2\u8272 &#8212;<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span><span class=\"token operator\">!<\/span>&#8212; \u521b\u5efa\u7528\u6237&#xff1a;\u7528\u6237\u540d root&#xff0c;\u5bc6\u7801 root&#xff0c;\u62e5\u6709\u4e24\u4e2a\u7ba1\u7406\u89d2\u8272 &#8212;<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>user <span class=\"token assign-left variable\">username<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;root&#034;<\/span> <span class=\"token assign-left variable\">password<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;root&#034;<\/span> <span class=\"token assign-left variable\">roles<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;manager-gui,admin-gui&#034;<\/span>\/<span class=\"token operator\">&gt;<\/span><br \/>\n<span class=\"token operator\">&lt;<\/span>\/tomcat-users<span class=\"token operator\">&gt;<\/span><\/p>\n<p><span class=\"token comment\"># \u529f\u80fd&#xff1a;\u91cd\u542f tomcat \u670d\u52a1\u5668&#xff0c;\u4f7f\u7528\u6237\u914d\u7f6e\u751f\u6548<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;server tomcat<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># systemctl restart tomcat<\/span><\/p>\n<p>\u8fdb\u5165\u7ba1\u7406\u754c\u9762<\/p>\n<p>\u7ba1\u7406\u754c\u9762\u9ed8\u8ba4\u53ea\u80fd\u4ece Tomcat \u672c\u5730\u8bbf\u95ee&#xff08;http:\/\/localhost:8080&#xff09;\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813234443-689d236b947d2.png\" alt=\"image-20250811225051242\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813234443-689d236bd62d7.png\" alt=\"image-20250811225059739\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813234444-689d236c1ce3d.png\" alt=\"image-20250811225105253\" \/><\/p>\n<p>\u9879\u76ee\u5b9e\u6218:<\/p>\n<p><span class=\"token comment\"># \u573a\u666f&#xff1a;server \u4f5c\u4e3a tomcat \u670d\u52a1\u5668&#xff0c;client \u4f5c\u4e3a nginx \u53cd\u5411\u4ee3\u7406&#xff08;\u7528\u6237\u8bbf\u95ee client&#xff0c;\u7531 client \u8f6c\u53d1\u5230 server \u7684 tomcat&#xff09;<\/span><\/p>\n<p><span class=\"token comment\"># client&#xff08;\u4ee3\u7406\u670d\u52a1\u5668&#xff09;\u64cd\u4f5c&#xff1a;<\/span><br \/>\n<span class=\"token comment\"># 1. \u5b89\u88c5 nginx<\/span><br \/>\nyum <span class=\"token function\">install<\/span> <span class=\"token parameter variable\">-y<\/span> nginx<\/p>\n<p><span class=\"token comment\"># 2. \u914d\u7f6e nginx \u53cd\u5411\u4ee3\u7406\u5230 tomcat<\/span><br \/>\n<span class=\"token function\">vim<\/span> \/etc\/nginx\/nginx.conf<\/p>\n<p>http <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token punctuation\">..<\/span><span class=\"token punctuation\">..<\/span><span class=\"token punctuation\">..<\/span><br \/>\n    <span class=\"token comment\"># \u5b9a\u4e49\u4e0a\u6e38\u670d\u52a1\u5668&#xff08;tomcat \u670d\u52a1\u5668&#xff09;<\/span><br \/>\n    upstream tomcat <span class=\"token punctuation\">{<\/span><br \/>\n        server www.laoma.cloud:8080<span class=\"token punctuation\">;<\/span>  <span class=\"token comment\"># tomcat \u670d\u52a1\u5668\u7684\u5730\u5740\u548c\u7aef\u53e3<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token punctuation\">..<\/span><span class=\"token punctuation\">..<\/span><span class=\"token punctuation\">..<\/span><br \/>\n    server <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token punctuation\">..<\/span><span class=\"token punctuation\">..<\/span><span class=\"token punctuation\">..<\/span><\/p>\n<p>        <span class=\"token comment\"># \u53cd\u5411\u4ee3\u7406\u76f8\u5173\u914d\u7f6e&#xff08;\u4f20\u9012\u7528\u6237\u771f\u5b9e\u4fe1\u606f\u7ed9 tomcat&#xff09;<\/span><br \/>\n        proxy_redirect      off<span class=\"token punctuation\">;<\/span><br \/>\n        proxy_set_header    X-Real-IP <span class=\"token variable\">$remote_addr<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        proxy_set_header    X-Forwarded-For <span class=\"token variable\">$proxy_add_x_forwarded_for<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        proxy_set_header    Host <span class=\"token variable\">$http_host<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token comment\"># \u5c06 \/tomcat\/ \u8def\u5f84\u7684\u8bf7\u6c42\u8f6c\u53d1\u5230 tomcat \u670d\u52a1\u5668<\/span><br \/>\n        location \/tomcat\/ <span class=\"token punctuation\">{<\/span><br \/>\n            proxy_pass http:\/\/tomcat\/<span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n     <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span>     <\/p>\n<p><span class=\"token comment\"># 3. \u91cd\u542f nginx \u670d\u52a1&#xff0c;\u4f7f\u914d\u7f6e\u751f\u6548<\/span><br \/>\nsystemctl restart nginx.service <\/p>\n<p><span class=\"token comment\"># 4. \u51c6\u5907\u9759\u6001\u9875\u9762&#xff08;\u6d4b\u8bd5 nginx \u81ea\u8eab\u529f\u80fd&#xff09;<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> hello world <span class=\"token operator\">&gt;<\/span> \/usr\/share\/nginx\/html\/index.html  <span class=\"token comment\"># \u6839\u76ee\u5f55\u9875\u9762<\/span><br \/>\n<span class=\"token function\">mkdir<\/span> \/usr\/share\/nginx\/html\/web1  <span class=\"token comment\"># \u521b\u5efa web1 \u76ee\u5f55<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> hello WEB1 <span class=\"token operator\">&gt;<\/span> \/usr\/share\/nginx\/html\/web1\/index.html  <span class=\"token comment\"># web1 \u9875\u9762<\/span><\/p>\n<p><span class=\"token comment\"># \u7528\u6237\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u6d4b\u8bd5&#xff1a;<\/span><br \/>\n<span class=\"token comment\"># 1. \u8bbf\u95ee nginx \u81ea\u8eab\u7684\u9759\u6001\u9875\u9762<\/span><br \/>\nhttp:\/\/www.bq.cloud<br \/>\n<span class=\"token comment\"># 2. \u8bbf\u95ee nginx \u7684 web1 \u76ee\u5f55<\/span><br \/>\nhttp:\/\/www.bq.cloud\/web1<br \/>\n<span class=\"token comment\"># 3. \u8bbf\u95ee\u4ee3\u7406\u8f6c\u53d1\u7684 tomcat \u9875\u9762<\/span><br \/>\nhttp:\/\/www.bq.cloud\/tomcat\/test\/index.jsp<\/p>\n<p>\u5982\u6d89\u53ca\u7248\u6743\u95ee\u9898\u8bf7\u8054\u7cfb\u4f5c\u8005\u5904\u7406&#xff01;&#xff01;&#xff01;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb857\u6b21\uff0c\u70b9\u8d5e19\u6b21\uff0c\u6536\u85cf27\u6b21\u3002\u672c\u6587\u6458\u8981\uff1a\u672c\u6587\u4ecb\u7ecd\u4e86Nginx\u670d\u52a1\u5668\u7684\u5b89\u88c5\u914d\u7f6e\u4e0e\u529f\u80fd\u5b9e\u73b0\u3002Nginx\u4f5c\u4e3a\u9ad8\u6027\u80fdWEB\u670d\u52a1\u5668\uff0c\u652f\u63015\u4e07\u5e76\u53d1\u8fde\u63a5\u4e14\u8d44\u6e90\u6d88\u8017\u4f4e\u3002\u4e3b\u8981\u5185\u5bb9\u5305\u62ec\uff1a1)\u57fa\u7840\u5b89\u88c5\u4e0e\u9996\u9875\u914d\u7f6e\uff1b2)UserDir\u529f\u80fd\u5b9e\u73b0\uff0c\u5141\u8bb8\u7528\u6237\u901a\u8fc7\/~\u7528\u6237\u540d\u8bbf\u95ee\u4e2a\u4eba\u7f51\u9875\uff1b3)\u865a\u62df\u4e3b\u673a\u914d\u7f6e\uff08\u57fa\u4e8e\u57df\u540d\u548c\u7aef\u53e3\uff09\uff1b4)SSL\/TLS\u8bc1\u4e66\u914d\u7f6e\u5b9e\u73b0HTTPS\uff1b5)\u76ee\u5f55\u5bc6\u7801\u4fdd\u62a4\uff1b6)\u52a8\u6001\u811a\u672c\u652f\u6301\uff08PHP\u548cFastCGI\uff09\uff1b7)\u53cd\u5411\u4ee3\u7406\u90e8\u7f72\u3002\u6bcf\u4e2a\u529f\u80fd\u90fd\u63d0\u4f9b\u4e86\u8be6\u7ec6\u7684\u547d\u4ee4\u884c\u64cd\u4f5c\u6b65\u9aa4\uff0c\u6db5\u76d6\u9632\u706b\u5899\u3001SELinux\u7b49\u5b89\u5168\u8bbe\u7f6e\uff0c\u9002\u5408\u4f5c\u4e3aNginx\u670d\u52a1\u5668\u914d\u7f6e\u7684\u5b9e\u7528\u53c2\u8003\u6307\u5357\u3002<\/p>\n","protected":false},"author":2,"featured_media":55748,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[965,5499,87,43],"topic":[],"class_list":["post-55752","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-firefox","tag-linux","tag-87","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>18.WEB \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/55752.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"18.WEB \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb857\u6b21\uff0c\u70b9\u8d5e19\u6b21\uff0c\u6536\u85cf27\u6b21\u3002\u672c\u6587\u6458\u8981\uff1a\u672c\u6587\u4ecb\u7ecd\u4e86Nginx\u670d\u52a1\u5668\u7684\u5b89\u88c5\u914d\u7f6e\u4e0e\u529f\u80fd\u5b9e\u73b0\u3002Nginx\u4f5c\u4e3a\u9ad8\u6027\u80fdWEB\u670d\u52a1\u5668\uff0c\u652f\u63015\u4e07\u5e76\u53d1\u8fde\u63a5\u4e14\u8d44\u6e90\u6d88\u8017\u4f4e\u3002\u4e3b\u8981\u5185\u5bb9\u5305\u62ec\uff1a1)\u57fa\u7840\u5b89\u88c5\u4e0e\u9996\u9875\u914d\u7f6e\uff1b2)UserDir\u529f\u80fd\u5b9e\u73b0\uff0c\u5141\u8bb8\u7528\u6237\u901a\u8fc7\/~\u7528\u6237\u540d\u8bbf\u95ee\u4e2a\u4eba\u7f51\u9875\uff1b3)\u865a\u62df\u4e3b\u673a\u914d\u7f6e\uff08\u57fa\u4e8e\u57df\u540d\u548c\u7aef\u53e3\uff09\uff1b4)SSL\/TLS\u8bc1\u4e66\u914d\u7f6e\u5b9e\u73b0HTTPS\uff1b5)\u76ee\u5f55\u5bc6\u7801\u4fdd\u62a4\uff1b6)\u52a8\u6001\u811a\u672c\u652f\u6301\uff08PHP\u548cFastCGI\uff09\uff1b7)\u53cd\u5411\u4ee3\u7406\u90e8\u7f72\u3002\u6bcf\u4e2a\u529f\u80fd\u90fd\u63d0\u4f9b\u4e86\u8be6\u7ec6\u7684\u547d\u4ee4\u884c\u64cd\u4f5c\u6b65\u9aa4\uff0c\u6db5\u76d6\u9632\u706b\u5899\u3001SELinux\u7b49\u5b89\u5168\u8bbe\u7f6e\uff0c\u9002\u5408\u4f5c\u4e3aNginx\u670d\u52a1\u5668\u914d\u7f6e\u7684\u5b9e\u7528\u53c2\u8003\u6307\u5357\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/55752.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-13T23:44:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813234443-689d236b2eb6b.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"18 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/55752.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/55752.html\",\"name\":\"18.WEB \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-13T23:44:45+00:00\",\"dateModified\":\"2025-08-13T23:44:45+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/55752.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/55752.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/55752.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"18.WEB \u670d\u52a1\u5668\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"18.WEB \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/55752.html","og_locale":"zh_CN","og_type":"article","og_title":"18.WEB \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb857\u6b21\uff0c\u70b9\u8d5e19\u6b21\uff0c\u6536\u85cf27\u6b21\u3002\u672c\u6587\u6458\u8981\uff1a\u672c\u6587\u4ecb\u7ecd\u4e86Nginx\u670d\u52a1\u5668\u7684\u5b89\u88c5\u914d\u7f6e\u4e0e\u529f\u80fd\u5b9e\u73b0\u3002Nginx\u4f5c\u4e3a\u9ad8\u6027\u80fdWEB\u670d\u52a1\u5668\uff0c\u652f\u63015\u4e07\u5e76\u53d1\u8fde\u63a5\u4e14\u8d44\u6e90\u6d88\u8017\u4f4e\u3002\u4e3b\u8981\u5185\u5bb9\u5305\u62ec\uff1a1)\u57fa\u7840\u5b89\u88c5\u4e0e\u9996\u9875\u914d\u7f6e\uff1b2)UserDir\u529f\u80fd\u5b9e\u73b0\uff0c\u5141\u8bb8\u7528\u6237\u901a\u8fc7\/~\u7528\u6237\u540d\u8bbf\u95ee\u4e2a\u4eba\u7f51\u9875\uff1b3)\u865a\u62df\u4e3b\u673a\u914d\u7f6e\uff08\u57fa\u4e8e\u57df\u540d\u548c\u7aef\u53e3\uff09\uff1b4)SSL\/TLS\u8bc1\u4e66\u914d\u7f6e\u5b9e\u73b0HTTPS\uff1b5)\u76ee\u5f55\u5bc6\u7801\u4fdd\u62a4\uff1b6)\u52a8\u6001\u811a\u672c\u652f\u6301\uff08PHP\u548cFastCGI\uff09\uff1b7)\u53cd\u5411\u4ee3\u7406\u90e8\u7f72\u3002\u6bcf\u4e2a\u529f\u80fd\u90fd\u63d0\u4f9b\u4e86\u8be6\u7ec6\u7684\u547d\u4ee4\u884c\u64cd\u4f5c\u6b65\u9aa4\uff0c\u6db5\u76d6\u9632\u706b\u5899\u3001SELinux\u7b49\u5b89\u5168\u8bbe\u7f6e\uff0c\u9002\u5408\u4f5c\u4e3aNginx\u670d\u52a1\u5668\u914d\u7f6e\u7684\u5b9e\u7528\u53c2\u8003\u6307\u5357\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/55752.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-13T23:44:45+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813234443-689d236b2eb6b.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"18 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/55752.html","url":"https:\/\/www.wsisp.com\/helps\/55752.html","name":"18.WEB \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-13T23:44:45+00:00","dateModified":"2025-08-13T23:44:45+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/55752.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/55752.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/55752.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"18.WEB \u670d\u52a1\u5668"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/55752","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=55752"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/55752\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/55748"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=55752"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=55752"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=55752"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=55752"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}