{"id":829,"date":"2025-09-04T21:23:59","date_gmt":"2025-09-04T13:23:59","guid":{"rendered":"https:\/\/www.zhzxs.site\/?p=829"},"modified":"2025-09-04T21:28:15","modified_gmt":"2025-09-04T13:28:15","slug":"1756992281","status":"publish","type":"post","link":"https:\/\/www.zhzxs.site\/index.php\/2025\/09\/04\/1756992281\/","title":{"rendered":"\u5728\u670d\u52a1\u5668\u4e0a\u7528 Docker + Apache \u90e8\u7f72 Nextcloud"},"content":{"rendered":"\n<p>\u672c\u6587\u8bb0\u5f55\u4e86\u5982\u4f55\u4f7f\u7528 <strong>Docker + Apache \u53cd\u5411\u4ee3\u7406<\/strong> \u90e8\u7f72 Nextcloud\uff0c\u5e76\u914d\u7f6e HTTPS \u8bbf\u95ee\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e00\u3001\u521b\u5efa\u76ee\u5f55<\/h2>\n\n\n\n<p>\u9996\u5148\u5728\u670d\u52a1\u5668\u4e0a\u521b\u5efa\u4e00\u4e2a\u76ee\u5f55\u6765\u5b58\u653e\u914d\u7f6e\u6587\u4ef6\u548c\u6570\u636e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir -p ~\/nextcloud-docker\ncd ~\/nextcloud-docker\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3001\u521b\u5efa <code>docker-compose.yml<\/code><\/h2>\n\n\n\n<p>\u5728 <code>~\/nextcloud-docker\/<\/code> \u4e0b\u65b0\u5efa\u4e00\u4e2a <code>docker-compose.yml<\/code> \u6587\u4ef6\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>version: '3'\n\nservices:\n  db:\n    image: mariadb:10.6\n    container_name: nextcloud-db\n    restart: always\n    environment:\n      MYSQL_ROOT_PASSWORD: yZaishandsOme.34\n      MYSQL_DATABASE: nextcloud\n      MYSQL_USER: nextcloud\n      MYSQL_PASSWORD: yZaishandsOme.34\n    volumes:\n      - db_data:\/var\/lib\/mysql\n\n  app:\n    image: nextcloud\n    container_name: nextcloud-app\n    restart: always\n    ports:\n      - 13243:80\n    links:\n      - db\n    environment:\n      MYSQL_HOST: db\n      MYSQL_DATABASE: nextcloud\n      MYSQL_USER: nextcloud\n      MYSQL_PASSWORD: yZaishandsOme.34\n    volumes:\n      - nextcloud_data:\/var\/www\/html\n\nvolumes:\n  db_data:\n  nextcloud_data:\n<\/code><\/pre>\n\n\n\n<p>\u26a0\ufe0f <strong>\u6ce8\u610f\uff1a\u8bf7\u4fee\u6539 <code>MYSQL_ROOT_PASSWORD<\/code> \u548c <code>MYSQL_PASSWORD<\/code>\uff0c\u4e0d\u8981\u76f4\u63a5\u4f7f\u7528\u793a\u4f8b\u4e2d\u7684\u5bc6\u7801\uff01<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u3001\u542f\u52a8\u5bb9\u5668<\/h2>\n\n\n\n<p>\u5728 <code>docker-compose.yml<\/code> \u6587\u4ef6\u6240\u5728\u76ee\u5f55\u6267\u884c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker compose up -d\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u56db\u3001\u8bbf\u95ee Nextcloud<\/h2>\n\n\n\n<p>\u6d4f\u89c8\u5668\u8bbf\u95ee\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:&#47;&#47;\u4f60\u7684\u670d\u52a1\u5668IP:13243\n<\/code><\/pre>\n\n\n\n<p>\u9996\u6b21\u6253\u5f00\u4f1a\u63d0\u793a\u8bbe\u7f6e\u7ba1\u7406\u5458\u8d26\u53f7\uff0c\u6570\u636e\u5e93\u4fe1\u606f\u5df2\u5728 compose \u6587\u4ef6\u4e2d\u914d\u7f6e\u597d\uff0c\u76f4\u63a5\u4e0b\u4e00\u6b65\u5373\u53ef\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e94\u3001\u914d\u7f6e Apache \u53cd\u5411\u4ee3\u7406<\/h2>\n\n\n\n<p>\u5047\u8bbe\u4f60\u4f7f\u7528 <strong>Apache<\/strong> \u4f5c\u4e3a\u53cd\u5411\u4ee3\u7406\uff0c\u57df\u540d\u4e3a <code>cloud.example.com<\/code>\uff0cNextcloud \u5bb9\u5668\u76d1\u542c <code>13243<\/code> \u7aef\u53e3\u3002<\/p>\n\n\n\n<p>\u5148\u5b89\u88c5apache (\u5982\u679c\u6ca1\u5b89\u88c5)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install apache2 -y<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u542f\u7528\u4ee3\u7406\u6a21\u5757<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo a2enmod proxy\nsudo a2enmod proxy_http\nsudo a2enmod headers\nsudo a2enmod ssl\nsudo systemctl restart apache2\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u914d\u7f6e\u865a\u62df\u4e3b\u673a\uff08HTTP \u793a\u4f8b\uff09<\/h3>\n\n\n\n<p>\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vim \/etc\/apache2\/sites-available\/nextcloud.conf\n<\/code><\/pre>\n\n\n\n<p>\u5199\u5165\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;VirtualHost *:80&gt;\n    ServerName cloud.example.com\n\n    ProxyPreserveHost On\n    ProxyRequests Off\n    ProxyPass \/ http:\/\/127.0.0.1:13243\/\n    ProxyPassReverse \/ http:\/\/127.0.0.1:13243\/\n\n    &lt;Location \/&gt;\n        Require all granted\n    &lt;\/Location&gt;\n&lt;\/VirtualHost&gt;\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u542f\u7528\u7ad9\u70b9\u5e76\u91cd\u542f Apache<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo a2ensite nextcloud.conf\nsudo systemctl reload apache2\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. \u6d4b\u8bd5\u8bbf\u95ee<\/h3>\n\n\n\n<p>\u73b0\u5728\u76f4\u63a5\u8bbf\u95ee\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http:&#47;&#47;cloud.example.com\n<\/code><\/pre>\n\n\n\n<p>\u5c31\u4f1a\u901a\u8fc7 Apache \u53cd\u5411\u4ee3\u7406\u5230 Docker \u91cc\u7684 Nextcloud\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u516d\u3001\u914d\u7f6e HTTPS\uff08Let\u2019s Encrypt\uff09<\/h2>\n\n\n\n<p>\u5b89\u88c5 Certbot \u548c Apache \u63d2\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install certbot python3-certbot-apache -y\n<\/code><\/pre>\n\n\n\n<p>\u83b7\u53d6\u8bc1\u4e66\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo certbot --apache\n<\/code><\/pre>\n\n\n\n<p>\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u5c31\u53ef\u4ee5\u901a\u8fc7 <code>https:\/\/cloud.example.com<\/code> \u8bbf\u95ee\u4e86\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e03\u3001\u4fee\u6539 Nextcloud \u914d\u7f6e<\/h2>\n\n\n\n<p>\u5982\u679c\u51fa\u73b0 <strong>\u767b\u5f55\u8f6c\u5708\u5708<\/strong> \u6216 <strong>\u57df\u540d\u4e0d\u53d7\u4fe1\u4efb<\/strong> \u7684\u95ee\u9898\uff0c\u9700\u8981\u4fee\u6539 Nextcloud \u7684\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u67e5\u770b Docker \u5377<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo docker volume ls\n<\/code><\/pre>\n\n\n\n<p>\u8f93\u51fa\u793a\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DRIVER    VOLUME NAME\nlocal     nextcloud_data\nlocal     db_data\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u7f16\u8f91 <code>config.php<\/code><\/h3>\n\n\n\n<p>\u627e\u5230\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vim \/var\/lib\/docker\/volumes\/nextcloud_data\/_data\/config\/config.php\n<\/code><\/pre>\n\n\n\n<p>\u5728\u914d\u7f6e\u4e2d\u52a0\u5165\u4ee5\u4e0b\u5185\u5bb9\uff08\u6839\u636e\u5b9e\u9645\u57df\u540d\u4fee\u6539\uff09\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>'trusted_proxies' =&gt; &#91;'127.0.0.1', '144.24.55.199'],\n'forwarded_for_headers' =&gt; &#91;'HTTP_X_FORWARDED_FOR'],\n'overwrite.cli.url' =&gt; 'https:\/\/cloud.zhzxs.xyz',\n'overwritehost' =&gt; 'cloud.zhzxs.xyz',\n'overwriteprotocol' =&gt; 'https',\n'overwritewebroot' =&gt; '\/',\n<\/code><\/pre>\n\n\n\n<p>\u540c\u65f6\uff0c\u628a\u4f60\u7684\u57df\u540d\u52a0\u5165 <code>trusted_domains<\/code>\uff0c\u9632\u6b62\u65e0\u6cd5\u767b\u5f55\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u2705 \u81f3\u6b64\uff0cNextcloud \u5df2\u7ecf\u901a\u8fc7 <strong>Docker + Apache + HTTPS<\/strong> \u6210\u529f\u90e8\u7f72\u5e76\u53ef\u4ee5\u6b63\u5e38\u8bbf\u95ee\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u8bb0\u5f55\u4e86\u5982\u4f55\u4f7f\u7528 Docker + Apache \u53cd\u5411\u4ee3\u7406 \u90e8\u7f72 Nextcloud\uff0c\u5e76\u914d\u7f6e HTTPS \u8bbf [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":90,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[63,64],"class_list":["post-829","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-2","tag-nextcloud","tag-64"],"_links":{"self":[{"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/posts\/829","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/comments?post=829"}],"version-history":[{"count":10,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/posts\/829\/revisions"}],"predecessor-version":[{"id":839,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/posts\/829\/revisions\/839"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/media\/90"}],"wp:attachment":[{"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/media?parent=829"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/categories?post=829"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/tags?post=829"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}