{"id":1509,"date":"2026-07-16T19:14:47","date_gmt":"2026-07-16T11:14:47","guid":{"rendered":"https:\/\/www.loongdi.net\/blog\/?p=1509"},"modified":"2026-07-16T19:14:47","modified_gmt":"2026-07-16T11:14:47","slug":"%e6%a8%b1%e8%8a%b1vps%e5%a6%82%e4%bd%95%e9%85%8d%e7%bd%ae%e5%92%8c%e9%83%a8%e7%bd%b2%e7%ae%80%e5%8d%95%e7%9a%84%e7%bd%91%e7%ab%99%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.loongdi.net\/blog\/1509.html","title":{"rendered":"\u6a31\u82b1VPS\u5982\u4f55\u914d\u7f6e\u548c\u90e8\u7f72\u7b80\u5355\u7684\u7f51\u7ad9\uff1f"},"content":{"rendered":"<p><p>\u672c\u6587\u5c06\u4e3a\u60a8\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728\u6a31\u82b1VPS\u4e0a\u914d\u7f6e\u548c\u90e8\u7f72\u4e00\u4e2a\u7b80\u5355\u7684\u7f51\u7ad9\u3002\u6211\u4eec\u5c06\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5b8c\u6210\u8fd9\u4e2a\u4efb\u52a1\uff1a\u5b89\u88c5Nginx\u670d\u52a1\u5668\uff0c\u914d\u7f6eMySQL\u6570\u636e\u5e93\uff0c\u4ee5\u53ca\u90e8\u7f72\u4e00\u4e2a\u9759\u6001\u7f51\u7ad9\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u7684\u64cd\u4f5c\u6307\u5357\u3002<\/p>\n<\/p>\n<p><h2>\u64cd\u4f5c\u524d\u7684\u51c6\u5907<\/h2>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u7684\u6a31\u82b1VPS\u5df2\u7ecf\u5b89\u88c5\u4e86Linux\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5e76\u4e14\u60a8\u5177\u6709root\u6743\u9650\u3002<\/p>\n<\/p>\n<p><h2>\u5b89\u88c5Nginx\u670d\u52a1\u5668<\/h2>\n<\/p>\n<p><h3>1. \u66f4\u65b0\u7cfb\u7edf\u8f6f\u4ef6\u5305<\/h3>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u66f4\u65b0\u60a8\u7684\u7cfb\u7edf\u8f6f\u4ef6\u5305\u4ee5\u83b7\u53d6\u6700\u65b0\u7684\u5305\u5217\u8868\u3002<\/p>\n<\/p>\n<p><pre><code>sudo apt update<\/p>\r\n<p>sudo apt upgrade<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2. \u5b89\u88c5Nginx<\/h3>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u5b89\u88c5Nginx\u670d\u52a1\u5668\u3002<\/p>\n<\/p>\n<p><pre><code>sudo apt install nginx<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3. \u9a8c\u8bc1Nginx\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>\u542f\u52a8Nginx\u670d\u52a1\u5e76\u68c0\u67e5\u5176\u72b6\u6001\u3002<\/p>\n<\/p>\n<p><pre><code>sudo systemctl start nginx<\/p>\r\n<p>sudo systemctl status nginx<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u914d\u7f6eMySQL\u6570\u636e\u5e93<\/h2>\n<\/p>\n<p><h3>1. \u5b89\u88c5MySQL<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5MySQL\u6570\u636e\u5e93\u670d\u52a1\u5668\u3002<\/p>\n<\/p>\n<p><pre><code>sudo apt install mysql-server<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.loongdi.net\/blog\/wp-content\/uploads\/2026\/03\/H37yX.jpg\" alt=\"\u6a31\u82b1VPS\u5982\u4f55\u914d\u7f6e\u548c\u90e8\u7f72\u7b80\u5355\u7684\u7f51\u7ad9\uff1f\" title=\"\u6a31\u82b1VPS\u5982\u4f55\u914d\u7f6e\u548c\u90e8\u7f72\u7b80\u5355\u7684\u7f51\u7ad9\uff1f\"><\/p>\n<p><h3>2. \u914d\u7f6eMySQL<\/h3>\n<\/p>\n<p><p>\u5728\u9996\u6b21\u8fd0\u884cMySQL\u65f6\uff0c\u60a8\u5c06\u9700\u8981\u8bbe\u7f6eroot\u7528\u6237\u7684\u5bc6\u7801\u3002<\/p>\n<\/p>\n<p><pre><code>sudo mysql_secure_installation<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6309\u7167\u63d0\u793a\u5b8c\u6210\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u8bbe\u7f6eroot\u5bc6\u7801<\/li>\n<li>\u79fb\u9664\u533f\u540d\u7528\u6237<\/li>\n<li>\u7981\u6b62root\u7528\u6237\u8fdc\u7a0b\u767b\u5f55<\/li>\n<li>\u5220\u9664\u6d4b\u8bd5\u6570\u636e\u5e93<\/li>\n<li>\u9000\u51faMySQL\u5b89\u5168\u914d\u7f6e<\/p>\n<\/ul>\n<p><h3>3. \u521b\u5efa\u6570\u636e\u5e93\u548c\u7528\u6237<\/h3>\n<\/p>\n<p><p>\u767b\u5f55\u5230MySQL\u5e76\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6570\u636e\u5e93\u548c\u7528\u6237\u3002<\/p>\n<\/p>\n<p><pre><code>sudo mysql<\/p>\r\n<p>CREATE DATABASE mydatabase;<\/p>\r\n<p>CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword';<\/p>\r\n<p>GRANT ALL PRIVILEGES ON mydatabase. TO 'myuser'@'localhost';<\/p>\r\n<p>FLUSH PRIVILEGES;<\/p>\r\n<p>EXIT;<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u90e8\u7f72\u9759\u6001\u7f51\u7ad9<\/h2>\n<\/p>\n<p><h3>1. \u521b\u5efa\u7f51\u7ad9\u76ee\u5f55<\/h3>\n<\/p>\n<p><p>\u5728Nginx\u7684\u7f51\u7ad9\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7f51\u7ad9\u76ee\u5f55\u3002<\/p>\n<\/p>\n<p><pre><code>sudo mkdir \/var\/www\/mywebsite<\/p>\r\n<p>sudo chown -R $USER:$USER \/var\/www\/mywebsite<\/p>\r\n<p>sudo chmod -R 755 \/var\/www\/mywebsite<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2. \u6dfb\u52a0\u7f51\u7ad9\u914d\u7f6e\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>\u5728Nginx\u7684\u914d\u7f6e\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code>sudo nano \/etc\/nginx\/sites-available\/mywebsite<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\u5185\u5bb9\uff1a<\/p>\n<\/p>\n<p><pre><code>server {<\/p>\r\n<p>    listen 80;<\/p>\r\n<p>    server_name mywebsite.com www.mywebsite.com;<\/p>\r\n\r\n<p>    root \/var\/www\/mywebsite;<\/p>\r\n\r\n<p>    index index.html index.htm;<\/p>\r\n\r\n<p>    location \/ {<\/p>\r\n<p>        try_files $uri $uri\/ =404;<\/p>\r\n<p>    }<\/p>\r\n<p>}<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3. \u521b\u5efa\u7f51\u7ad9\u7684\u7b26\u53f7\u94fe\u63a5<\/h3>\n<\/p>\n<p><p>\u5c06\u914d\u7f6e\u6587\u4ef6\u94fe\u63a5\u5230Nginx\u7684\u7f51\u7ad9\u542f\u7528\u76ee\u5f55\u3002<\/p>\n<\/p>\n<p><pre><code>sudo ln -s \/etc\/nginx\/sites-available\/mywebsite \/etc\/nginx\/sites-enabled\/<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><h3>4. \u91cd\u8f7dNginx\u914d\u7f6e<\/h3>\n<\/p>\n<p><p>\u91cd\u65b0\u52a0\u8f7dNginx\u914d\u7f6e\u4ee5\u5e94\u7528\u66f4\u6539\u3002<\/p>\n<\/p>\n<p><pre><code>sudo systemctl reload nginx<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u64cd\u4f5c\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u9047\u5230\u7684\u95ee\u9898<\/h2>\n<\/p>\n<ul>\n<li><strong>\u95ee\u9898\uff1a<\/strong> Nginx\u65e0\u6cd5\u542f\u52a8\u3002<\/li>\n<li><strong>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/strong> \u68c0\u67e5\u65e5\u5fd7\u6587\u4ef6 <code>\/var\/log\/nginx\/error.log<\/code> \u4ee5\u67e5\u627e\u9519\u8bef\u539f\u56e0\u3002<\/li>\n<li><strong>\u95ee\u9898\uff1a<\/strong> MySQL\u670d\u52a1\u672a\u542f\u52a8\u3002<\/li>\n<li><strong>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/strong> \u4f7f\u7528 <code>sudo systemctl start mysql<\/code> \u542f\u52a8MySQL\u670d\u52a1\u3002<\/li>\n<\/ul>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u60a8\u5e94\u8be5\u5df2\u7ecf\u6210\u529f\u5730\u5728\u6a31\u82b1VPS\u4e0a\u90e8\u7f72\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u7f51\u7ad9\u3002\u795d\u60a8\u4f7f\u7528\u6109\u5feb\uff01<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u5c06\u4e3a\u60a8\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728\u6a31\u82b1VPS\u4e0a\u914d\u7f6e\u548c\u90e8\u7f72\u4e00\u4e2a\u7b80\u5355\u7684\u7f51\u7ad9\u3002\u6211\u4eec\u5c06\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5b8c\u6210\u8fd9\u4e2a\u4efb\u52a1\uff1a\u5b89\u88c5Nginx\u670d\u52a1\u5668\uff0c\u914d\u7f6eMySQL\u6570\u636e\u5e93\uff0c\u4ee5\u53ca\u90e8\u7f72\u4e00\u4e2a\u9759\u6001\u7f51\u7ad9\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u7684\u64cd\u4f5c\u6307\u5357\u3002 \u64cd\u4f5c\u524d\u7684\u51c6\u5907 \u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u7684\u6a31\u82b1VPS\u5df2\u7ecf\u5b89\u88c5\u4e86&#8230;<\/p>\n","protected":false},"author":1,"featured_media":116,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"topic":[],"class_list":["post-1509","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-yun"],"_links":{"self":[{"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/posts\/1509","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/comments?post=1509"}],"version-history":[{"count":1,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/posts\/1509\/revisions"}],"predecessor-version":[{"id":1510,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/posts\/1509\/revisions\/1510"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/media\/116"}],"wp:attachment":[{"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/media?parent=1509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/categories?post=1509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/tags?post=1509"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.loongdi.net\/blog\/wp-json\/wp\/v2\/topic?post=1509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}