{"id":145,"date":"2025-03-07T21:19:00","date_gmt":"2025-03-08T05:19:00","guid":{"rendered":"https:\/\/breakfastberry.live\/?p=145"},"modified":"2025-03-07T09:22:27","modified_gmt":"2025-03-07T17:22:27","slug":"linux_vm_wordpress_nextcloud_outside_access","status":"publish","type":"post","link":"https:\/\/breakfastberry.live\/?p=145","title":{"rendered":"\u5982\u4f55\u914d\u7f6e\u670d\u52a1\u5668\u4ee5\u652f\u6301 WordPress \u548c Nextcloud \u7684\u5916\u90e8\u8bbf\u95ee"},"content":{"rendered":"\n<p>\u8fd9\u4e2a\u5468\u672b\u8f6c\u8fd0\u7684 4T \u786c\u76d8\u5230\u4e86\uff0c\u4e8e\u662f\u628a\u4e4b\u524d\u8fd0\u884c Ubuntu Server \u7684\u8ff7\u4f60\u4e3b\u673a\u6362\u6210\u4e86 Fedora Server\u3002\u6ca1\u60f3\u5230\u81ea\u5e26\u7684 Cockpit WebUI \u975e\u5e38\u597d\u7528\uff0c\u53ef\u4ee5\u7ba1\u7406\u8fd0\u884c\u865a\u62df\u673a\u3002\u6240\u4ee5\u542f\u52a8\u4e86\u4e24\u4e2a CentOS \u7684\u865a\u62df\u673a\uff0c\u4e00\u8fb9\u5b66\u4e60\u7cfb\u7edf\u7ba1\u7406\uff0c\u4e00\u8fb9\u628a\u81ea\u5df1\u7684 Nextcloud \u7f51\u76d8\u6269\u5927\u5230 4TB\u3002\u7b80\u7565\u8bb0\u5f55\u4e00\u4e0b\u8fc7\u7a0b\u548c\u9047\u5230\u7684\u95ee\u9898\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u6458\u8981<\/h2>\n\n\n\n<p>\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u914d\u7f6e Fedora \u670d\u52a1\u5668\u548c CentOS \u865a\u62df\u673a\uff0c\u4ee5\u4fbf\u4ece\u5916\u90e8\u7f51\u7edc\u8bbf\u95ee\u8fd0\u884c\u5728\u5176\u4e0a\u7684 WordPress \u548c Nextcloud \u670d\u52a1\u3002\u6211\u4eec\u4ece\u7f51\u7edc\u8bbe\u7f6e\u3001SSL \u914d\u7f6e\u3001\u53cd\u5411\u4ee3\u7406\u914d\u7f6e\u5165\u624b\uff0c\u9010\u6b65\u89e3\u51b3\u4e86\u914d\u7f6e\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u9047\u5230\u7684\u5e38\u89c1\u95ee\u9898\uff0c\u5982 502 \u9519\u8bef\u3001cURL \u9519\u8bef\u3001\u5185\u5b58\u9650\u5236\u4e0d\u8db3\u4ee5\u53ca\u6587\u4ef6\u4e0a\u4f20\u95ee\u9898\u3002\u901a\u8fc7\u4f7f\u7528 Nginx \u4f5c\u4e3a\u53cd\u5411\u4ee3\u7406\u3001Let&#8217;s Encrypt \u914d\u7f6e SSL \u8bc1\u4e66\uff0c\u5e76\u8c03\u6574 PHP \u548c Web \u670d\u52a1\u5668\u7684\u914d\u7f6e\uff0c\u6211\u4eec\u6210\u529f\u5b9e\u73b0\u4e86\u670d\u52a1\u7684\u7a33\u5b9a\u8fd0\u884c\u548c\u5916\u90e8\u8bbf\u95ee\u3002\u672c\u6587\u8fd8\u5206\u4eab\u4e86\u5982\u4f55\u901a\u8fc7 Cockpit WebUI \u7ba1\u7406\u865a\u62df\u673a\uff0c\u4ee5\u53ca\u5982\u4f55\u6269\u5c55 Nextcloud \u7f51\u76d8\u81f3 4TB \u7684\u5b9e\u8df5\u7ecf\u9a8c\u3002\u5e0c\u671b\u672c\u6587\u80fd\u4e3a\u6709\u7c7b\u4f3c\u9700\u6c42\u7684\u8bfb\u8005\u63d0\u4f9b\u53c2\u8003\u548c\u5e2e\u52a9\u3002<\/p>\n\n\n\n<p><strong>\u5173\u952e\u8bcd<\/strong>\uff1aFedora Server, CentOS, WordPress, Nextcloud, Nginx, SSL, \u53cd\u5411\u4ee3\u7406, \u6545\u969c\u6392\u9664, Cockpit, \u6587\u4ef6\u4e0a\u4f20<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. \u7f51\u7edc\u8bbe\u7f6e<\/h2>\n\n\n\n<p>\u6211\u4eec\u6709\u4ee5\u4e0b\u73af\u5883\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Fedora \u670d\u52a1\u5668<\/strong>\uff1aIP \u5730\u5740\u4e3a <code>192.168.0.155<\/code>\uff0c\u8fde\u63a5\u5230\u8def\u7531\u5668\u3002<\/li>\n\n\n\n<li><strong>CentOS \u865a\u62df\u673a 1<\/strong>\uff1a\u8fd0\u884c WordPress\uff0cIP \u5730\u5740\u4e3a <code>192.168.0.170<\/code>\uff0c\u4f7f\u7528 Apache2\u3002<\/li>\n\n\n\n<li><strong>CentOS \u865a\u62df\u673a 2<\/strong>\uff1a\u8fd0\u884c Nextcloud\uff0cIP \u5730\u5740\u4e3a <code>192.168.0.209<\/code>\uff0c\u4f7f\u7528 Apache2\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u4e3a\u4e86\u4f7f\u8fd9\u4e9b\u670d\u52a1\u53ef\u4ee5\u4ece\u5916\u90e8\u8bbf\u95ee\uff0c\u6211\u4eec\u9700\u8981\u8fdb\u884c\u4ee5\u4e0b\u914d\u7f6e\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u7aef\u53e3\u8f6c\u53d1<\/strong>\uff1a\u5728\u8def\u7531\u5668\u4e0a\u8bbe\u7f6e\u7aef\u53e3\u8f6c\u53d1\u89c4\u5219\uff0c\u5c06\u5916\u90e8\u6d41\u91cf\u8f6c\u53d1\u5230 Fedora \u670d\u52a1\u5668\u3002<\/li>\n\n\n\n<li><strong>\u9632\u706b\u5899\u914d\u7f6e<\/strong>\uff1a\u786e\u4fdd Fedora \u670d\u52a1\u5668\u548c CentOS \u865a\u62df\u673a\u7684\u9632\u706b\u5899\u5141\u8bb8 HTTP\uff08\u7aef\u53e3 80\uff09\u548c HTTPS\uff08\u7aef\u53e3 443\uff09\u6d41\u91cf\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">2. \u914d\u7f6e\u53cd\u5411\u4ee3\u7406<\/h2>\n\n\n\n<p>\u4e3a\u4e86\u7b80\u5316\u5916\u90e8\u8bbf\u95ee\uff0c\u6211\u4eec\u53ef\u4ee5\u5728 Fedora \u670d\u52a1\u5668\u4e0a\u914d\u7f6e Nginx \u4f5c\u4e3a\u53cd\u5411\u4ee3\u7406\u3002\u53cd\u5411\u4ee3\u7406\u5c06\u6839\u636e\u57df\u540d\u5c06\u6d41\u91cf\u8f6c\u53d1\u5230\u76f8\u5e94\u7684\u865a\u62df\u673a\u3002<\/p>\n\n\n\n<p><strong>Nginx \u914d\u7f6e\u793a\u4f8b\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>server {\n    listen 80;\n    server_name breakfastberry.live;\n\n    return 301 https:\/\/$host$request_uri;\n}\n\nserver {\n    listen 443 ssl;\n    server_name breakfastberry.live;\n\n    ssl_certificate \/etc\/letsencrypt\/live\/breakfastberry.live\/fullchain.pem;\n    ssl_certificate_key \/etc\/letsencrypt\/live\/breakfastberry.live\/privkey.pem;\n\n    location \/ {\n        proxy_pass http:\/\/192.168.0.170:80;\n        proxy_set_header Host $host;\n        proxy_set_header X-Real-IP $remote_addr;\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n        proxy_set_header X-Forwarded-Proto $scheme;\n    }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">3. \u914d\u7f6e SSL<\/h2>\n\n\n\n<p>\u4e3a\u4e86\u786e\u4fdd\u6570\u636e\u4f20\u8f93\u7684\u5b89\u5168\u6027\uff0c\u6211\u4eec\u4f7f\u7528 Let&#8217;s Encrypt \u4e3a\u57df\u540d\u914d\u7f6e SSL \u8bc1\u4e66\u3002<\/p>\n\n\n\n<p><strong>\u4f7f\u7528 Certbot \u83b7\u53d6 SSL \u8bc1\u4e66\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo certbot --nginx -d breakfastberry.live -d www.breakfastberry.live<\/code><\/pre>\n\n\n\n<p>Certbot \u4f1a\u81ea\u52a8\u914d\u7f6e Nginx \u4ee5\u4f7f\u7528 SSL\uff0c\u5e76\u8bbe\u7f6e HTTP \u5230 HTTPS \u7684\u91cd\u5b9a\u5411\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. \u68c0\u67e5\u9632\u706b\u5899\u662f\u5426\u5141\u8bb8 HTTPS \u6d41\u91cf<\/h2>\n\n\n\n<p>\u4e3a\u4e86\u786e\u4fdd\u5916\u90e8\u7528\u6237\u53ef\u4ee5\u8bbf\u95ee HTTPS \u670d\u52a1\uff0c\u5fc5\u987b\u786e\u4fdd\u9632\u706b\u5899\u5141\u8bb8 HTTPS \u6d41\u91cf\uff08\u7aef\u53e3 443\uff09\u3002\u4ee5\u4e0b\u662f\u68c0\u67e5\u548c\u914d\u7f6e\u9632\u706b\u5899\u7684\u6b65\u9aa4\uff1a<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5bf9\u4e8e firewalld\uff1a<\/h3>\n\n\n\n<p><strong>\u68c0\u67e5\u5f53\u524d\u9632\u706b\u5899\u89c4\u5219\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo firewall-cmd --list-all<\/code><\/pre>\n\n\n\n<p><strong>\u5982\u679c HTTPS \u670d\u52a1\u672a\u542f\u7528\uff0c\u6dfb\u52a0 HTTPS \u670d\u52a1\u5e76\u91cd\u65b0\u52a0\u8f7d\u9632\u706b\u5899\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo firewall-cmd --permanent --add-service=https\nsudo firewall-cmd --reload<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5bf9\u4e8e ufw\uff1a<\/h3>\n\n\n\n<p><strong>\u68c0\u67e5\u5f53\u524d\u9632\u706b\u5899\u89c4\u5219\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ufw status<\/code><\/pre>\n\n\n\n<p><strong>\u5982\u679c\u7aef\u53e3 443 \u672a\u5f00\u653e\uff0c\u5141\u8bb8 HTTPS \u6d41\u91cf\u5e76\u91cd\u65b0\u52a0\u8f7d\u9632\u706b\u5899\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo ufw allow 443\/tcp\nsudo ufw reload<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">5. \u89e3\u51b3\u5e38\u89c1\u95ee\u9898<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u95ee\u9898 1\uff1a502 Bad Gateway \u9519\u8bef<\/strong><\/h3>\n\n\n\n<p><strong>\u539f\u56e0<\/strong>\uff1aNginx \u65e0\u6cd5\u8fde\u63a5\u5230\u540e\u7aef\u670d\u52a1\u5668\u3002<\/p>\n\n\n\n<p><strong>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u68c0\u67e5\u540e\u7aef\u670d\u52a1\uff08\u5982 Apache\uff09\u662f\u5426\u6b63\u5728\u8fd0\u884c\u3002<\/li>\n\n\n\n<li>\u786e\u4fdd\u9632\u706b\u5899\u5141\u8bb8\u6d41\u91cf\u901a\u8fc7\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u4f7f\u7528 SELinux\uff0c\u542f\u7528 <code>httpd_can_network_connect<\/code> \u5e03\u5c14\u503c\uff1a <code>sudo setsebool -P httpd_can_network_connect 1<\/code><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u95ee\u9898 2\uff1acURL \u9519\u8bef 7\uff08\u65e0\u6cd5\u8fde\u63a5\u5230\u670d\u52a1\u5668\uff09<\/strong><\/h3>\n\n\n\n<p><strong>\u539f\u56e0<\/strong>\uff1a\u670d\u52a1\u5668\u65e0\u6cd5\u89e3\u6790\u57df\u540d\u6216 SSL \u914d\u7f6e\u9519\u8bef\u3002<\/p>\n\n\n\n<p><strong>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u68c0\u67e5 DNS \u8bb0\u5f55\u662f\u5426\u6b63\u786e\u3002<\/li>\n\n\n\n<li>\u786e\u4fdd SSL \u8bc1\u4e66\u6709\u6548\u5e76\u6b63\u786e\u914d\u7f6e\u3002<\/li>\n\n\n\n<li>\u68c0\u67e5\u9632\u706b\u5899\u662f\u5426\u5141\u8bb8 HTTPS \u6d41\u91cf\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u95ee\u9898 3\uff1a\u5185\u5b58\u9650\u5236\u4e0d\u8db3 \/ \u4e0a\u4f20\u8f83\u5927\u6587\u4ef6\uff08\u5927\u4e8e 75MB\uff09\u65f6\u62a5\u9519<\/strong><\/h3>\n\n\n\n<p><strong>\u539f\u56e0<\/strong>\uff1aPHP \u5185\u5b58\u9650\u5236\u6216 Web \u670d\u52a1\u5668\u6587\u4ef6\u4e0a\u4f20\u9650\u5236\u8fc7\u4f4e\u3002<\/p>\n\n\n\n<p><strong>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u589e\u52a0 PHP \u5185\u5b58\u9650\u5236<\/strong> \u7f16\u8f91 <code>php.ini<\/code> \u6587\u4ef6\uff0c\u589e\u52a0\u5185\u5b58\u9650\u5236\uff1a <code>memory_limit = 512M upload_max_filesize = 256M post_max_size = 256M<\/code> <strong>\u91cd\u542f Web \u670d\u52a1\u5668\u4ee5\u5e94\u7528\u66f4\u6539\uff1a<\/strong> <code>sudo systemctl restart httpd # \u5bf9\u4e8e Apache sudo systemctl restart php-fpm &amp;&amp; sudo systemctl restart nginx # \u5bf9\u4e8e Nginx + PHP-FPM<\/code><\/li>\n\n\n\n<li><strong>\u589e\u52a0 Nginx \u6587\u4ef6\u4e0a\u4f20\u9650\u5236<\/strong> \u7f16\u8f91 Nginx \u914d\u7f6e\u6587\u4ef6\uff0c\u6dfb\u52a0\uff1a <code>client_max_body_size 256M;<\/code> <strong>\u91cd\u65b0\u52a0\u8f7d Nginx\uff1a<\/strong> <code>sudo systemctl reload nginx<\/code><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">6. \u603b\u7ed3<\/h2>\n\n\n\n<p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u6211\u4eec\u6210\u529f\u914d\u7f6e\u4e86 Fedora \u670d\u52a1\u5668\u548c CentOS \u865a\u62df\u673a\uff0c\u4f7f\u5176\u80fd\u591f\u4ece\u5916\u90e8\u7f51\u7edc\u8bbf\u95ee\u3002\u6211\u4eec\u8fd8\u89e3\u51b3\u4e86\u914d\u7f6e\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u9047\u5230\u7684\u5e38\u89c1\u95ee\u9898\uff0c\u5982 502 \u9519\u8bef\u3001cURL \u9519\u8bef\u3001\u5185\u5b58\u9650\u5236\u4e0d\u8db3\u4ee5\u53ca\u6587\u4ef6\u4e0a\u4f20\u95ee\u9898\u3002\u5e0c\u671b\u672c\u6587\u5bf9\u60a8\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u4e2a\u5468\u672b\u8f6c\u8fd0\u7684 4T \u786c\u76d8\u5230\u4e86\uff0c\u4e8e\u662f\u628a\u4e4b\u524d\u8fd0\u884c Ubuntu Server \u7684\u8ff7\u4f60\u4e3b\u673a\u6362\u6210\u4e86 Fedora Server\u3002\u6ca1\u60f3\u5230\u81ea\u5e26\u7684 Cockpit WebU&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/breakfastberry.live\/?p=145\">\u9605\u8bfb\u5168\u6587<span class=\"screen-reader-text\">\u5982\u4f55\u914d\u7f6e\u670d\u52a1\u5668\u4ee5\u652f\u6301 WordPress \u548c Nextcloud \u7684\u5916\u90e8\u8bbf\u95ee<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","_sitemap_exclude":false,"_sitemap_priority":"","_sitemap_frequency":"","iawp_total_views":2,"footnotes":""},"categories":[3],"tags":[5,19,17,18],"class_list":["post-145","post","type-post","status-publish","format-standard","hentry","category-linux","tag-linux","tag-nextcloud","tag-server","tag-wordpress","entry"],"_links":{"self":[{"href":"https:\/\/breakfastberry.live\/index.php?rest_route=\/wp\/v2\/posts\/145","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/breakfastberry.live\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/breakfastberry.live\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/breakfastberry.live\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/breakfastberry.live\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=145"}],"version-history":[{"count":1,"href":"https:\/\/breakfastberry.live\/index.php?rest_route=\/wp\/v2\/posts\/145\/revisions"}],"predecessor-version":[{"id":146,"href":"https:\/\/breakfastberry.live\/index.php?rest_route=\/wp\/v2\/posts\/145\/revisions\/146"}],"wp:attachment":[{"href":"https:\/\/breakfastberry.live\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/breakfastberry.live\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/breakfastberry.live\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}