{"id":373,"date":"2024-03-01T08:30:00","date_gmt":"2024-03-01T00:30:00","guid":{"rendered":"https:\/\/readu.com\/?p=373"},"modified":"2024-03-01T08:56:17","modified_gmt":"2024-03-01T00:56:17","slug":"%e9%98%bf%e9%87%8c%e4%ba%91ecs%e9%83%a8%e7%bd%b2wordpress","status":"publish","type":"post","link":"https:\/\/readu.com\/?p=373","title":{"rendered":"\u963f\u91cc\u4e91ECS\u90e8\u7f72WordPress"},"content":{"rendered":"\n<p>\u65e0\u8c13\u56e0\u679c\uff0c\u5148\u5206\u4eab\u4e0b\u5efa\u7ad9\u7684\u8fc7\u7a0b\u5427\u3002 \u56e0\u4e3a\u5e73\u65f6\u63a5\u89e6\u7684\u5c11\uff0c\u7f51\u4e0a\u7814\u7a76\u4e86\u4e00\u4e0b\uff0c\u51b3\u5b9a\u4f7f\u7528WordPress\u3002\u8d77\u521d\u60f3\u4f7f\u7528\u7fa4\u6656\u63d0\u4f9b\u7684WordPress\u5728\u7fa4\u6656\u4e0a\u642d\u5efa\uff0c\u56e0\u4e3a\u4e4b\u524d\u6ca1\u6709\u4f7f\u7528WordPress\u7684\u7ecf\u9a8c\uff0c\u6015\u6298\u817e\u7684\u4e71\u4e03\u516b\u7cdf\uff0c\u800c\u624b\u5934\u6b63\u597d\u6709\u4e00\u4e2a\u95f2\u7f6e\u51e0\u5e74\u7684\u963f\u91cc\u4e91ECS\uff0c\u867d\u7136\u914d\u7f6e\u4e0d\u9ad8\uff0c\u611f\u89c9\u5e94\u8be5\u8fd8\u884c\uff0c\u4e4b\u524d\u5173\u8054\u4e86\u57df\u540d\u5907\u6848\uff0c\u4f7f\u7528\u65b9\u4fbf\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8f6f\u786c\u4ef6\u73af\u5883\uff1a<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5e73\u53f0\uff1a\u963f\u91cc\u4e91\u670d\u52a1\u5668ECS<\/li>\n\n\n\n<li>\u7cfb\u7edf\uff1aUbuntu 22.04 64\u4f4d UEFI\u7248<\/li>\n\n\n\n<li>\u8f6f\u4ef6\uff1aWordPress\u3001MariaDB\u3001Nginx\u3001PHP<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u7b80\u8981\u6d41\u7a0b:<\/h2>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code># \u8fdc\u7a0b\u767b\u5f55ECS\nssh \u7528\u6237\u540d@ECS\u57df\u540d\u6216IP\n\n# \u5b89\u88c5Nginx\nsudo apt install nginx\n\n# \u5b89\u88c5PHP\u53ca\u76f8\u5e94\u6a21\u5757\nsudo apt install php-fpm php-mysql\n\n# \u5b89\u88c5MariaDB\u6570\u636e\u5e93\nsudo apt install mariadb-server\n\n# \u6570\u636e\u5e93\u521d\u59cb\u8bbe\u7f6e:\nmysq_secure_installation\n#\u4e2d\u95f4\u4f1a\u63d0\u793a\u8f93\u5165\u7cfb\u7edfroot\u7528\u6237\u5bc6\u7801\uff0c\u8bbe\u7f6e\u4fee\u6539\u6570\u636e\u5e93root\u5bc6\u7801\uff1b\u7981\u6b62root\u8fdc\u7a0b\u767b\u5f55\uff1b\u7981\u6b62\u533f\u540d\u7528\u6237\uff1b\u5220\u9664test\u5e93\u7b49,\u6839\u636e\u9700\u8981\u8bbe\u7f6e\n\n# \u8fde\u63a5\u6570\u636e\u5e93\nmysql -u root -p\n#\u8f93\u5165\u6570\u636e\u5e93root\u5bc6\u7801\n\n# \u521b\u5efaWordPress\u6570\u636e\u5e93\u548c\u7528\u6237\ncreate database wordpress;\ncreate user 'wp'@'localhost' identified by '\u7528\u6237wp\u7684\u5bc6\u7801';\ngrant all privileges on wordpress.* to 'wp'@'localhost';\nflush privileges;\nexit;\n\n# \u4e0b\u8f7d\u5b89\u88c5WordPress\nsudo wget https:\/\/cn.wordpress.org\/latest-zh_CN.tar.gz\nsudo tar zxvf laster.tar.gz\nsudo cp wordpress \/var\/www\/wordpress\nsudo chown -R www-data:www-data \/var\/www\/wordpress\n\n# \u914d\u7f6eNginx.conf\n# \u4ee5\u539f\u9ed8\u8ba4\u914d\u7f6e\u4e3a\u6a21\u677f\u65b0\u5efa\u4e00\u4e2aWordPress\u7684\u914d\u7f6e\nsudo cp \/etc\/nginx\/sites-available\/default \/etc\/nginx\/sites-available\/wordpress\n# \u4fee\u6539\u914d\u7f6e\nsudo vi \/etc\/nginx\/sites-available\/wordpress<\/code><\/pre>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u914d\u7f6e\u6587\u4ef6\u4e3b\u8981\u5185\u5bb9\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>server{\nlisten 80 default_server;\nlisten &#91;::]:80 default_server;\nserver_name \u57df\u540d;\n#\u91cd\u5b9a\u5411\u81f3https\nlocation \/ {\nreturn 301 https:\/\/$host$request_uri;\n}\n}\nserver {\n# SSL configuration\nlisten 443 ssl default_server;\nlisten &#91;::]:443 ssl default_server;\n#\u5728snakeoil.conf\u4e2d\u8bbe\u7f6e\u8bc1\u4e66\u8def\u5f84\ninclude snippets\/snakeoil.conf;\n#wordpress\u5b89\u88c5\u76ee\u5f55\nroot \/var\/www\/wordpress;\nindex index.html index.nginx-debian.html index.php;\nserver_name \u57df\u540d;\nlocation \/ {\ntry_files $uri $uri\/ =404;\n}\n# pass PHP scripts to FastCGI server\nlocation ~ .php$ {\ninclude snippets\/fastcgi-php.conf;\n#unix:\u53c2\u6570\u8981\u4e0e\/etc\/php\/8.1\/fpm\/pool.d\/www.conf\u4e2d\u7684listen\u503c\u4e00\u81f4\nfastcgi_pass unix:\/run\/php\/php8.1-fpm.sock;\n}\nlocation ~ \/.ht {\ndeny all;\n}\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>#\u68c0\u67e5\u914d\u7f6e\nsudo nginx -t\n\n#\u8bbe\u7f6e\u8f6f\u94fe\u63a5\u542f\u7528\u914d\u7f6e\n\n: sudo ln -s \/etc\/nginx\/sites-available\/wordpress \/etc\/nginx\/sites-enabled\/\n\n#\u91cd\u542fNginx\u4f7f\u914d\u7f6e\u751f\u6548\nsudo systemctl restart nginx\n\n#\u914d\u7f6eWordPress\ncd \/var\/www\/wordpress\nsudo cp wp-config-sample.php wp-config.php\nsudo vi wp-config.php<\/code><\/pre>\n\n\n\n<p>\u4e3b\u8981\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u4fee\u6539\u6dfb\u52a0\u6570\u636e\u5e93\u53c2\u6570\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>define( 'DB_NAME', 'wordpress' );<br>define( 'DB_USER', 'wp' );<br>define( 'DB_PASSWORD', '\u7528\u6237wp\u7684\u5bc6\u7801' );<br>define( 'DB_HOST', 'localhost' );<\/code><\/pre>\n\n\n\n<p>\u73b0\u5728\u7f51\u7ad9\u5e94\u8be5\u5c31\u53ef\u4ee5\u8dd1\u8d77\u6765\u4e86\uff0c\u6d4f\u89c8\u5668\u8bbf\u95eeECS\u670d\u52a1\u7684IP\u5730\u5740\u6216\u57df\u540d\u3002\u7ba1\u7406\u5458\u767b\u5f55\u5730\u5740\u4e3a\uff1a\u57df\u540d\/wp-admin\u3002<br>\u9700\u8981\u7528\u5230\u57df\u540d\u53ca\u89e3\u6790\u548cSSL\u8bc1\u4e66\u670d\u52a1\uff0c\u5728\u7528\u7684\u662f\u963f\u91cc\u4e91\u76f8\u5173\u670d\u52a1\uff0c\u6709\u9700\u8981\u7684\u53ef\u4ee5\u5230\u963f\u91cc\u4e91\u4e86\u89e3\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.aliyun.com\/daily-act\/ecs\/activity_selection?userCode=wsz55ojs\" target=\"_blank\" rel=\"noreferrer noopener\">\u963f\u91cc\u4e91ECS\u4e91\u670d\u52a1\u5668<\/a>\uff0c\u65b0\u7528\u6237\u4f18\u60e0\u6bd4\u8f83\u591a\u3002<\/li>\n\n\n\n<li><a href=\"https:\/\/help.aliyun.com\/zh\/dws\/product-overview\/what-is-domains?source=5176.11533457&amp;userCode=wsz55ojs\" target=\"_blank\" rel=\"noreferrer noopener\">\u963f\u91cc\u4e91\u57df\u540d\u670d\u52a1\u6587\u6863<\/a>\uff0c\u666e\u901a\u57df\u540d\u5f88\u4fbf\u5b9c\uff0c\u6ce8\u610f\u9009\u62e9\u652f\u6301\u89e3\u6790\u670d\u52a1\u7684\u3002<\/li>\n\n\n\n<li><a href=\"https:\/\/help.aliyun.com\/zh\/ssl-certificate\/user-guide\/what-is-an-ssl-certificate?source=5176.11533457&amp;userCode=wsz55ojs\" target=\"_blank\" rel=\"noreferrer noopener\">\u963f\u91cc\u4e91SSL\u8bc1\u4e66\u670d\u52a1\u6587\u6863<\/a>\uff0c\u5728\u7528\u7684\u662f\u514d\u8d39\u8bc1\u4e66\uff0c\u4f18\u70b9\u662f\u514d\u8d39\uff0c\u7f3a\u70b9\u662f\u8bc1\u4e66\u89813\u4e2a\u6708\u4e00\u66f4\u65b0\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u65e0\u8c13\u56e0\u679c\uff0c\u5148\u5206\u4eab\u4e0b\u5efa\u7ad9\u7684\u8fc7\u7a0b\u5427\u3002 \u56e0\u4e3a\u5e73\u65f6\u63a5\u89e6\u7684\u5c11\uff0c\u7f51\u4e0a\u7814\u7a76\u4e86\u4e00\u4e0b\uff0c\u51b3\u5b9a\u4f7f\u7528WordPress\u3002\u8d77\u521d\u60f3\u4f7f\u7528\u7fa4\u6656 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":389,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[26,27],"class_list":["post-373","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-28","tag-wordpress","tag-ecs"],"_links":{"self":[{"href":"https:\/\/readu.com\/index.php?rest_route=\/wp\/v2\/posts\/373","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/readu.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/readu.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/readu.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/readu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=373"}],"version-history":[{"count":8,"href":"https:\/\/readu.com\/index.php?rest_route=\/wp\/v2\/posts\/373\/revisions"}],"predecessor-version":[{"id":394,"href":"https:\/\/readu.com\/index.php?rest_route=\/wp\/v2\/posts\/373\/revisions\/394"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/readu.com\/index.php?rest_route=\/wp\/v2\/media\/389"}],"wp:attachment":[{"href":"https:\/\/readu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=373"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/readu.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=373"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/readu.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}