{"id":1559,"date":"2025-02-08T13:55:35","date_gmt":"2025-02-08T05:55:35","guid":{"rendered":"http:\/\/www.liujh168.com\/?p=1532"},"modified":"2025-02-08T13:55:35","modified_gmt":"2025-02-08T05:55:35","slug":"automovewp-2-2","status":"publish","type":"post","link":"https:\/\/www.liujh168.com\/index.php\/2025\/02\/08\/automovewp-2-2\/","title":{"rendered":"ECS\u4e2dWordPress\u81ea\u52a8\u5316\u8fc1\u79fb\u811a\u672c"},"content":{"rendered":"<p>\u901a\u8fc7\u7f16\u5199 Shell \u811a\u672c\u5b9e\u73b0\u5c06 WordPress \u6570\u636e\u8fc1\u79fb\u8fc7\u7a0b\u81ea\u52a8\u5316\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u81ea\u52a8\u5316\u8fc1\u79fb\u811a\u672c\u7684\u793a\u4f8b\uff0c\u6db5\u76d6\u4ece\u5907\u4efd\u5230\u6062\u590d\u7684\u5b8c\u6574\u6d41\u7a0b\u3002<\/p>\n<h3>\u81ea\u52a8\u5316\u8fc1\u79fb\u811a\u672c<\/h3>\n<h4>1. \u5728\u6e90\u670d\u52a1\u5668\u4e0a\u8fd0\u884c\u7684\u811a\u672c\uff08<code>migrate_source.sh<\/code>\uff09<\/h4>\n<p><!--more--><\/p>\n<pre><code>#!\/bin\/bash\n# \u914d\u7f6e\u53d8\u91cf\nDB_NAME=\"wordpress_db\"\nDB_USER=\"wordpress_user\"\nDB_PASSWORD=\"your_password\"\nBACKUP_DIR=\"\/path\/to\/backup\"\nWP_DIR=\"\/var\/www\/html\"\nTARGET_USER=\"user\"\nTARGET_SERVER=\"target-server\"\n# \u521b\u5efa\u5907\u4efd\u76ee\u5f55\nmkdir -p $BACKUP_DIR\n\n# \u5907\u4efd WordPress \u6587\u4ef6\necho \"\u5907\u4efd WordPress \u6587\u4ef6...\"\ntar -czvf $BACKUP_DIR\/wordpress_backup.tar.gz -C $WP_DIR .\n\n# \u5907\u4efd\u6570\u636e\u5e93\necho \"\u5907\u4efd\u6570\u636e\u5e93...\"\nmysqldump -u $DB_USER -p$DB_PASSWORD --databases $DB_NAME &gt; $BACKUP_DIR\/wordpress_db.sql\n\n# \u4f20\u8f93\u5907\u4efd\u6587\u4ef6\u5230\u76ee\u6807\u670d\u52a1\u5668\necho \"\u4f20\u8f93\u5907\u4efd\u6587\u4ef6\u5230\u76ee\u6807\u670d\u52a1\u5668...\"\nscp $BACKUP_DIR\/wordpress_backup.tar.gz $TARGET_USER@$TARGET_SERVER:\/tmp\/\nscp $BACKUP_DIR\/wordpress_db.sql $TARGET_USER@$TARGET_SERVER:\/tmp\/\n\necho \"\u6e90\u670d\u52a1\u5668\u5907\u4efd\u548c\u4f20\u8f93\u5b8c\u6210\uff01\"\n<\/code><\/pre>\n<h4>2. \u5728\u76ee\u6807\u670d\u52a1\u5668\u4e0a\u8fd0\u884c\u7684\u811a\u672c\uff08<code>migrate_target.sh<\/code>\uff09<\/h4>\n<p><!--more--><\/p>\n<pre><code>#!\/bin\/bash\n\n# \u914d\u7f6e\u53d8\u91cf\nDB_NAME=\"wordpress_db\"\nDB_USER=\"wordpress_user\"\nDB_PASSWORD=\"your_password\"\nWP_DIR=\"\/var\/www\/html\"\nBACKUP_DIR=\"\/tmp\"\n\n<!--more-->\n# \u5b89\u88c5 MySQL 8.0 \u548c Apache\necho \"\u5b89\u88c5 MySQL 8.0 \u548c Apache...\"\nsudo apt update\nsudo apt install -y mysql-server apache2 php libapache2-mod-php php-mysql\n\n# \u914d\u7f6e MySQL\necho \"\u914d\u7f6e MySQL...\"\nsudo mysql_secure_installation &lt;<\/code><\/pre>\n<h3>3. \u4f7f\u7528\u6b65\u9aa4<\/h3>\n<ol>\n<li><strong>\u5728\u6e90\u670d\u52a1\u5668\u4e0a\u8fd0\u884c <code>migrate_source.sh<\/code><\/strong>\uff1a\n<ul>\n<li>\u5c06\u811a\u672c\u4fdd\u5b58\u4e3a <code>migrate_source.sh<\/code>\uff0c\u5e76\u8d4b\u4e88\u6267\u884c\u6743\u9650\uff1a\n<pre><code>chmod +x migrate_source.sh<\/code><\/pre>\n<\/li>\n<li>\u8fd0\u884c\u811a\u672c\uff1a\n<pre><code>.\/migrate_source.sh<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u5728\u76ee\u6807\u670d\u52a1\u5668\u4e0a\u8fd0\u884c <code>migrate_target.sh<\/code><\/strong>\uff1a\n<ul>\n<li>\u5c06\u811a\u672c\u4fdd\u5b58\u4e3a <code>migrate_target.sh<\/code>\uff0c\u5e76\u8d4b\u4e88\u6267\u884c\u6743\u9650\uff1a\n<pre><code>chmod +x migrate_target.sh<\/code><\/pre>\n<\/li>\n<li>\u8fd0\u884c\u811a\u672c\uff1a\n<pre><code>.\/migrate_target.sh<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><!--more--><\/p>\n<h3>4. \u811a\u672c\u529f\u80fd\u8bf4\u660e<\/h3>\n<ul>\n<li><strong><code>migrate_source.sh<\/code><\/strong>\uff1a\n<ul>\n<li>\u5907\u4efd WordPress \u6587\u4ef6\u548c\u6570\u636e\u5e93\u3002<\/li>\n<li>\u5c06\u5907\u4efd\u6587\u4ef6\u4f20\u8f93\u5230\u76ee\u6807\u670d\u52a1\u5668\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong><code>migrate_target.sh<\/code><\/strong>\uff1a\n<ul>\n<li>\u5b89\u88c5 MySQL 8.0 \u548c Apache\u3002<\/li>\n<li>\u914d\u7f6e MySQL \u5e76\u521b\u5efa WordPress \u6570\u636e\u5e93\u548c\u7528\u6237\u3002<\/li>\n<li>\u5bfc\u5165\u6570\u636e\u5e93\u5e76\u89e3\u538b WordPress \u6587\u4ef6\u3002<\/li>\n<li>\u914d\u7f6e WordPress \u5e76\u8bbe\u7f6e\u6587\u4ef6\u6743\u9650\u3002<\/li>\n<li>\u91cd\u542f\u670d\u52a1\u4ee5\u5e94\u7528\u66f4\u6539\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>5. \u6ce8\u610f\u4e8b\u9879<\/h3>\n<ol>\n<li><strong>\u5bc6\u7801\u5b89\u5168<\/strong>\uff1a\n<ul>\n<li>\u811a\u672c\u4e2d\u5305\u542b\u6570\u636e\u5e93\u5bc6\u7801\uff0c\u5efa\u8bae\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528\u66f4\u5b89\u5168\u7684\u65b9\u5f0f\u7ba1\u7406\u5bc6\u7801\uff08\u5982\u73af\u5883\u53d8\u91cf\u6216\u5bc6\u94a5\u7ba1\u7406\u5de5\u5177\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u7f51\u7edc\u8fde\u63a5<\/strong>\uff1a\n<ul>\n<li>\u786e\u4fdd\u6e90\u670d\u52a1\u5668\u548c\u76ee\u6807\u670d\u52a1\u5668\u4e4b\u95f4\u53ef\u4ee5\u901a\u8fc7 SSH \u548c SCP \u901a\u4fe1\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u6d4b\u8bd5\u73af\u5883<\/strong>\uff1a\n<ul>\n<li>\u5728\u6b63\u5f0f\u8fc1\u79fb\u524d\uff0c\u5efa\u8bae\u5728\u6d4b\u8bd5\u73af\u5883\u4e2d\u8fd0\u884c\u811a\u672c\uff0c\u9a8c\u8bc1\u5176\u529f\u80fd\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u9519\u8bef\u5904\u7406<\/strong>\uff1a\n<ul>\n<li>\u811a\u672c\u4e2d\u672a\u5305\u542b\u8be6\u7ec6\u7684\u9519\u8bef\u5904\u7406\u903b\u8f91\uff0c\u5efa\u8bae\u6839\u636e\u5b9e\u9645\u9700\u6c42\u6dfb\u52a0\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3>\u603b\u7ed3<\/h3>\n<p>\u901a\u8fc7\u4e0a\u8ff0\u811a\u672c\uff0c\u53ef\u4ee5\u81ea\u52a8\u5316\u5b8c\u6210 WordPress \u6570\u636e\u4ece <strong>Ubuntu 18.04 + MySQL 5.7<\/strong> \u5230 <strong>Ubuntu 22.04 + MySQL 8.0<\/strong> \u7684\u8fc1\u79fb\u3002\u811a\u672c\u8986\u76d6\u4e86\u4ece\u5907\u4efd\u5230\u6062\u590d\u7684\u5b8c\u6574\u6d41\u7a0b\uff0c\u786e\u4fdd\u6570\u636e\u5b8c\u6574\u6027\u548c\u517c\u5bb9\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u901a\u8fc7\u7f16\u5199 Shell \u811a\u672c\u5b9e\u73b0\u5c06 WordPress \u6570\u636e\u8fc1\u79fb\u8fc7\u7a0b\u81ea\u52a8\u5316\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u81ea\u52a8\u5316\u8fc1\u79fb\u811a\u672c\u7684\u793a\u4f8b\uff0c\u6db5\u76d6 &hellip; <a href=\"https:\/\/www.liujh168.com\/index.php\/2025\/02\/08\/automovewp-2-2\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cECS\u4e2dWordPress\u81ea\u52a8\u5316\u8fc1\u79fb\u811a\u672c\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41,1],"tags":[],"class_list":["post-1559","post","type-post","status-publish","format-standard","hentry","category-uncategorized","category-unknown"],"_links":{"self":[{"href":"https:\/\/www.liujh168.com\/index.php\/wp-json\/wp\/v2\/posts\/1559","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.liujh168.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.liujh168.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.liujh168.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.liujh168.com\/index.php\/wp-json\/wp\/v2\/comments?post=1559"}],"version-history":[{"count":0,"href":"https:\/\/www.liujh168.com\/index.php\/wp-json\/wp\/v2\/posts\/1559\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.liujh168.com\/index.php\/wp-json\/wp\/v2\/media?parent=1559"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.liujh168.com\/index.php\/wp-json\/wp\/v2\/categories?post=1559"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.liujh168.com\/index.php\/wp-json\/wp\/v2\/tags?post=1559"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}