{"id":441815,"date":"2025-07-16T20:31:31","date_gmt":"2025-07-16T12:31:31","guid":{"rendered":"https:\/\/www.idc.net\/help\/?p=441815"},"modified":"2025-09-16T10:11:17","modified_gmt":"2025-09-16T02:11:17","slug":"centos-%e4%b8%8e-ubuntu-%e7%b3%bb%e7%bb%9f%e5%91%bd%e4%bb%a4%e6%9c%89%e4%bb%80%e4%b9%88%e4%b8%8d%e5%90%8c","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/441815\/","title":{"rendered":"CentOS\u4e0eUbuntu\u5728\u540e\u6d6a\u4e91\u4e0a\u7684\u547d\u4ee4\u5bf9\u6bd4\u4e0e\u4f18\u5316\u5b9e\u8df5"},"content":{"rendered":"<h2>\u5f15\u8a00<\/h2>\n<p>CentOS\u548cUbuntu\u662f\u4e91\u670d\u52a1\u5668\u73af\u5883\u4e2d\u5e7f\u6cdb\u4f7f\u7528\u7684Linux\u53d1\u884c\u7248\uff0c\u5206\u522b\u57fa\u4e8eRPM\u548cDEB\u4f53\u7cfb\uff0c\u5728\u5305\u7ba1\u7406\u3001\u670d\u52a1\u63a7\u5236\u548c\u7f51\u7edc\u914d\u7f6e\u7b49\u65b9\u9762\u5b58\u5728\u663e\u8457\u5dee\u5f02\u3002\u4e86\u89e3\u8fd9\u4e9b\u5dee\u5f02\u6709\u52a9\u4e8e\u5f00\u53d1\u8005\u4e0e\u7cfb\u7edf\u7ba1\u7406\u5458\u5728\u4e0d\u540c\u7cfb\u7edf\u95f4\u9ad8\u6548\u5207\u6362\u3002\u672c\u6587\u4ee5<a href=\"https:\/\/idc.net\/cloud-hk\">\u540e\u6d6a\u4e91VPS<\/a>\u4e3a\u4f8b\uff0c\u6df1\u5165\u5bf9\u6bd4CentOS\u548cUbuntu\u7684\u5e38\u7528\u547d\u4ee4\uff0c\u5e76\u7ed3\u5408\u5b9e\u9645\u6848\u4f8b\u63d0\u4f9b\u4f18\u5316\u5b9e\u8df5\u6307\u5357\u3002<\/p>\n<h2>\u6848\u4f8b\u5206\u6790\uff1a\u540e\u6d6a\u4e91\u4e0a\u7684Web\u670d\u52a1\u5668\u90e8\u7f72<\/h2>\n<p>\u5047\u8bbe\u6211\u4eec\u5728<a href=\"https:\/\/idc.net\/cloud-hk\">\u540e\u6d6a\u4e91HK-1H2G VPS<\/a>\uff081\u6838CPU\u30012GB DDR4\u5185\u5b58\u300130GB SSD\u30011Mbps\u5e26\u5bbd\uff0c\u6708\u8d39\u00a530\uff09\u4e0a\u90e8\u7f72\u4e00\u4e2aNGINX Web\u670d\u52a1\u5668\uff0c\u9700\u5728CentOS 8\u548cUbuntu 20.04\u4e4b\u95f4\u9009\u62e9\u5408\u9002\u7684\u7cfb\u7edf\u3002\u901a\u8fc7\u5bf9\u6bd4\u4e24\u8005\u7684\u547d\u4ee4\u548c\u7279\u6027\uff0c\u6211\u4eec\u9009\u62e9\u4e86Ubuntu\u5e76\u4f18\u5316\u4e86\u914d\u7f6e\uff0c\u5feb\u901f\u5b8c\u6210\u4e86\u90e8\u7f72\u3002<\/p>\n<h2>\u6280\u672f\u539f\u7406\uff1aCentOS\u4e0eUbuntu\u7684\u4f53\u7cfb\u5dee\u5f02<\/h2>\n<h3>\u5305\u7ba1\u7406<\/h3>\n<ul>\n<li><strong>CentOS<\/strong>\uff1a\u4f7f\u7528<code>yum<\/code>\uff08CentOS 7\uff09\u6216<code>dnf<\/code>\uff08CentOS 8+\uff09\uff0c\u57fa\u4e8eRPM\u5305\u683c\u5f0f\uff0c\u4f9d\u8d56Red Hat\u751f\u6001\u7684\u5b58\u50a8\u5e93\uff0c\u5f3a\u8c03\u7a33\u5b9a\u6027\u3002<\/li>\n<li><strong>Ubuntu<\/strong>\uff1a\u4f7f\u7528<code>apt<\/code>\uff0c\u57fa\u4e8eDEB\u5305\u683c\u5f0f\uff0c\u4f9d\u8d56Debian\u751f\u6001\uff0c\u63d0\u4f9b\u66f4\u9891\u7e41\u7684\u66f4\u65b0\u548c\u66f4\u5e7f\u6cdb\u7684\u8f6f\u4ef6\u5305\u3002<\/li>\n<\/ul>\n<h3>\u670d\u52a1\u4e0e\u7f51\u7edc\u7ba1\u7406<\/h3>\n<p>\u4e24\u8005\u5747\u91c7\u7528<code>systemd<\/code>\u7ba1\u7406\u670d\u52a1\uff0c\u547d\u4ee4\u4e00\u81f4\uff0c\u4f46\u5728\u7f51\u7edc\u914d\u7f6e\u4e0a\uff0cCentOS\u504f\u5411<code>NetworkManager<\/code>\u548c\u914d\u7f6e\u6587\u4ef6\uff0cUbuntu 18.04+\u4f7f\u7528<code>Netplan<\/code>\uff08YAML\u683c\u5f0f\uff09\u3002<\/p>\n<h3>\u9632\u706b\u5899<\/h3>\n<ul>\n<li><strong>CentOS<\/strong>\uff1a\u9ed8\u8ba4\u4f7f\u7528<code>firewalld<\/code>\uff0c\u63d0\u4f9b\u52a8\u6001\u533a\u57df\u7ba1\u7406\u548c\u590d\u6742\u89c4\u5219\u3002<\/li>\n<li><strong>Ubuntu<\/strong>\uff1a\u4f7f\u7528<code>ufw<\/code>\uff08Uncomplicated Firewall\uff09\uff0c\u7b80\u5316<code>iptables<\/code>\u64cd\u4f5c\uff0c\u9002\u5408\u8f7b\u91cf\u914d\u7f6e\u3002<\/li>\n<\/ul>\n<h2>\u5b9e\u8df5\u6307\u5357\uff1a\u5728\u540e\u6d6a\u4e91VPS\u4e0a\u7ba1\u7406CentOS\u4e0eUbuntu<\/h2>\n<p>\u4ee5\u4e0b\u662f\u5bf9\u6bd4\u548c\u4f18\u5316CentOS 8\u4e0eUbuntu 20.04\u7684\u5e38\u7528\u547d\u4ee4\uff0c\u7ed3\u5408\u540e\u6d6a\u4e91VPS\u5b9e\u8df5\u3002<\/p>\n<h3>1. \u5305\u7ba1\u7406<\/h3>\n<p><strong>CentOS<\/strong>\uff1a<\/p>\n<pre><code class=\"language-bash\"># \u66f4\u65b0\u5305\u5217\u8868\r\nsudo dnf check-update\r\n\r\n# \u5b89\u88c5NGINX\r\nsudo dnf install nginx\r\n\r\n# \u5378\u8f7d\u8f6f\u4ef6\r\nsudo dnf remove nginx\r\n\r\n# \u6e05\u7406\u7f13\u5b58\r\nsudo dnf clean all\r\n<\/code><\/pre>\n<p><strong>Ubuntu<\/strong>\uff1a<\/p>\n<pre><code class=\"language-bash\"># \u66f4\u65b0\u5305\u5217\u8868\r\nsudo apt update\r\n\r\n# \u5b89\u88c5NGINX\r\nsudo apt install nginx\r\n\r\n# \u5378\u8f7d\u8f6f\u4ef6\r\nsudo apt remove nginx\r\n\r\n# \u6e05\u7406\u7f13\u5b58\r\nsudo apt clean\r\n<\/code><\/pre>\n<p><strong>\u4f18\u5316\u5b9e\u8df5<\/strong>\uff1a\u5728\u6848\u4f8b\u4e2d\uff0cUbuntu\u7684<code>apt<\/code>\u56e0\u66f4\u5feb\u7684\u5b58\u50a8\u5e93\u54cd\u5e94\u901f\u5ea6\uff08\u5f97\u76ca\u4e8e\u540e\u6d6a\u4e91\u7684<a href=\"https:\/\/idc.net\/hk\">\u9999\u6e2f\u6570\u636e\u4e2d\u5fc3<\/a>\uff09\u66f4\u9002\u5408\u5feb\u901f\u90e8\u7f72\u3002<\/p>\n<h3>2. \u670d\u52a1\u7ba1\u7406<\/h3>\n<p>\u4e24\u8005\u7684<code>systemd<\/code>\u547d\u4ee4\u4e00\u81f4\uff1a<\/p>\n<pre><code class=\"language-bash\"># \u542f\u52a8NGINX\r\nsudo systemctl start nginx\r\n\r\n# \u5f00\u673a\u81ea\u542f\r\nsudo systemctl enable nginx\r\n\r\n# \u67e5\u770b\u72b6\u6001\r\nsudo systemctl status nginx\r\n<\/code><\/pre>\n<p><strong>\u4f18\u5316\u5b9e\u8df5<\/strong>\uff1a\u4f7f\u7528<code>systemctl is-active nginx<\/code>\u68c0\u67e5\u670d\u52a1\u72b6\u6001\uff0c\u786e\u4fddNGINX\u5728\u540e\u6d6a\u4e91\u7684\u9ad8\u6027\u80fdCPU\u4e0a\u7a33\u5b9a\u8fd0\u884c\u3002<\/p>\n<h3>3. \u7f51\u7edc\u914d\u7f6e<\/h3>\n<p><strong>CentOS<\/strong>\uff1a<br \/>\n\u7f16\u8f91<code>\/etc\/sysconfig\/network-scripts\/ifcfg-eth0<\/code>\u8bbe\u7f6e\u9759\u6001IP\uff1a<\/p>\n<pre><code class=\"language-bash\">TYPE=Ethernet\r\nBOOTPROTO=none\r\nNAME=eth0\r\nDEVICE=eth0\r\nONBOOT=yes\r\nIPADDR=192.168.1.100\r\nNETMASK=255.255.255.0\r\nGATEWAY=192.168.1.1\r\n<\/code><\/pre>\n<p>\u91cd\u542f\u7f51\u7edc\uff1a<\/p>\n<pre><code class=\"language-bash\">sudo systemctl restart NetworkManager\r\n<\/code><\/pre>\n<p><strong>Ubuntu<\/strong>\uff1a<br \/>\n\u7f16\u8f91<code>\/etc\/netplan\/01-netcfg.yaml<\/code>\uff1a<\/p>\n<pre><code class=\"language-yaml\">network:\r\n  ethernets:\r\n    eth0:\r\n      addresses:\r\n        - 192.168.1.100\/24\r\n      gateway4: 192.168.1.1\r\n  version: 2\r\n<\/code><\/pre>\n<p>\u5e94\u7528\u914d\u7f6e\uff1a<\/p>\n<pre><code class=\"language-bash\">sudo netplan apply\r\n<\/code><\/pre>\n<p><strong>\u4f18\u5316\u5b9e\u8df5<\/strong>\uff1aUbuntu\u7684<code>Netplan<\/code>\u914d\u7f6e\u66f4\u7b80\u6d01\uff0c\u7ed3\u5408\u540e\u6d6a\u4e91\u76841Mbps\u5e26\u5bbd\uff0c\u9002\u5408\u5feb\u901f\u8c03\u6574\u7f51\u7edc\u3002<\/p>\n<h3>4. \u9632\u706b\u5899\u7ba1\u7406<\/h3>\n<p><strong>CentOS<\/strong>\uff1a<\/p>\n<pre><code class=\"language-bash\"># \u5f00\u653e80\u7aef\u53e3\r\nsudo firewall-cmd --add-port=80\/tcp --permanent\r\nsudo firewall-cmd --reload\r\n<\/code><\/pre>\n<p><strong>Ubuntu<\/strong>\uff1a<\/p>\n<pre><code class=\"language-bash\"># \u5f00\u653e80\u7aef\u53e3\r\nsudo ufw allow 80\r\nsudo ufw enable\r\n<\/code><\/pre>\n<p><strong>\u4f18\u5316\u5b9e\u8df5<\/strong>\uff1a\u5728\u6848\u4f8b\u4e2d\uff0cUbuntu\u7684<code>ufw<\/code>\u56e0\u7b80\u5355\u6027\u66f4\u9002\u5408\u8f7b\u91cfWeb\u670d\u52a1\u5668\uff0c\u8282\u7701\u914d\u7f6e\u65f6\u95f4\u3002<\/p>\n<h3>5. \u7528\u6237\u7ba1\u7406<\/h3>\n<p><strong>CentOS<\/strong>\uff1a<\/p>\n<pre><code class=\"language-bash\"># \u6dfb\u52a0\u7528\u6237\r\nsudo adduser webadmin\r\n\r\n# \u5220\u9664\u7528\u6237\r\nsudo userdel -r webadmin\r\n<\/code><\/pre>\n<p><strong>Ubuntu<\/strong>\uff1a<\/p>\n<pre><code class=\"language-bash\"># \u6dfb\u52a0\u7528\u6237\r\nsudo adduser webadmin\r\n\r\n# \u5220\u9664\u7528\u6237\r\nsudo deluser --remove-home webadmin\r\n<\/code><\/pre>\n<p><strong>\u4f18\u5316\u5b9e\u8df5<\/strong>\uff1a\u786e\u4fdd\u7528\u6237\u6743\u9650\u6700\u5c0f\u5316\uff0c\u7ed3\u5408\u540e\u6d6a\u4e91\u7684SSH\u7ba1\u7406\u529f\u80fd\u63d0\u5347\u5b89\u5168\u6027\u3002<\/p>\n<h3>6. \u6587\u4ef6\u7cfb\u7edf\u4e0e\u65e5\u5fd7<\/h3>\n<p><strong>\u6587\u4ef6\u7cfb\u7edf<\/strong>\uff1a<\/p>\n<pre><code class=\"language-bash\"># \u67e5\u770b\u78c1\u76d8\u4f7f\u7528\r\ndf -h\r\n\r\n# \u6302\u8f7d\u78c1\u76d8\r\nsudo mount \/dev\/sdb1 \/mnt\r\n<\/code><\/pre>\n<p><strong>\u65e5\u5fd7<\/strong>\uff1a<br \/>\n<strong>CentOS<\/strong>\uff1a<\/p>\n<pre><code class=\"language-bash\">sudo journalctl -u nginx\r\n<\/code><\/pre>\n<p><strong>Ubuntu<\/strong>\uff1a<\/p>\n<pre><code class=\"language-bash\">sudo tail -f \/var\/log\/syslog\r\n<\/code><\/pre>\n<p><strong>\u4f18\u5316\u5b9e\u8df5<\/strong>\uff1a\u540e\u6d6a\u4e91\u7684SSD\u5b58\u50a8\uff08<a href=\"https:\/\/idc.net\/cloud-hk\">HK-1H2G<\/a>\uff09\u52a0\u901f\u4e86\u65e5\u5fd7\u8bfb\u53d6\uff0c\u63a8\u8350\u5b9a\u671f\u6e05\u7406<code>\/var\/log<\/code>\u4ee5\u4f18\u5316\u7a7a\u95f4\u3002<\/p>\n<h2>\u6280\u672f\u5bf9\u6bd4\uff1aCentOS vs. Ubuntu<\/h2>\n<ul>\n<li><strong>CentOS<\/strong>\uff1a\u9002\u5408\u8ffd\u6c42\u7a33\u5b9a\u6027\u7684\u4f01\u4e1a\u7ea7\u5e94\u7528\uff0c<code>dnf<\/code>\u63d0\u4f9b\u9ad8\u6548\u4f9d\u8d56\u89e3\u6790\uff0c\u9002\u5408\u540e\u6d6a\u4e91\u7684\u957f\u671f\u8fd0\u884c\u573a\u666f\u3002<\/li>\n<li><strong>Ubuntu<\/strong>\uff1a\u8f6f\u4ef6\u5305\u66f4\u65b0\u5feb\uff0c<code>apt<\/code>\u548c<code>ufw<\/code>\u7b80\u5316\u914d\u7f6e\uff0c\u9002\u5408\u5feb\u901f\u90e8\u7f72\u548c\u5f00\u53d1\u6d4b\u8bd5\u3002<\/li>\n<\/ul>\n<p>\u5728\u6848\u4f8b\u4e2d\uff0cUbuntu\u7684\u5feb\u901f\u914d\u7f6e\u548c\u4e30\u5bcc\u793e\u533a\u652f\u6301\u66f4\u9002\u5408\u535a\u5ba2\u90e8\u7f72\u3002<\/p>\n<h2>\u6280\u672f\u7ecf\u9a8c\u5206\u4eab<\/h2>\n<p>\u901a\u8fc7\u5728\u540e\u6d6a\u4e91VPS\u4e0a\u90e8\u7f72Web\u670d\u52a1\u5668\uff0c\u6211\u4eec\u9009\u62e9\u4e86Ubuntu\u4ee5\u52a0\u5feb\u914d\u7f6e\u901f\u5ea6\u3002\u4ee5\u4e0b\u662f\u5173\u952e\u7ecf\u9a8c\uff1a<\/p>\n<ul>\n<li><strong>\u6027\u80fd\u4f18\u5316<\/strong>\uff1a\u540e\u6d6a\u4e91\u7684SSD\u5b58\u50a8\uff08<a href=\"https:\/\/idc.net\/cloud-hk\">HK-1H2G<\/a>\uff09\u63d0\u5347\u4e86\u5305\u7ba1\u7406\u548c\u65e5\u5fd7\u8bbf\u95ee\u6548\u7387\u3002<\/li>\n<li><strong>\u7f51\u7edc\u7a33\u5b9a\u6027<\/strong>\uff1a\u540e\u6d6a\u4e91\u7684\u9999\u6e2f\u6570\u636e\u4e2d\u5fc3\uff08<a href=\"https:\/\/idc.net\/hk\">https:\/\/idc.net\/hk<\/a>\uff09\u63d0\u4f9b\u4f4e\u5ef6\u8fdf\u7f51\u7edc\uff0c\u52a0\u901f\u5b58\u50a8\u5e93\u8bbf\u95ee\u3002<\/li>\n<li><strong>\u5b89\u5168\u914d\u7f6e<\/strong>\uff1a<code>ufw<\/code>\u548c\u6700\u5c0f\u6743\u9650\u7528\u6237\u589e\u5f3a\u4e86\u7cfb\u7edf\u5b89\u5168\u6027\u3002<\/li>\n<li><strong>\u65e5\u5fd7\u76d1\u63a7<\/strong>\uff1a\u5b9a\u671f\u68c0\u67e5<code>journalctl<\/code>\u786e\u4fdd\u670d\u52a1\u7a33\u5b9a\u3002<\/li>\n<\/ul>\n<p>\u8fdb\u4e00\u6b65\u8d44\u6e90\u53ef\u53c2\u8003Ubuntu\u6587\u6863\u6216<a href=\"https:\/\/idc.net\/\">\u540e\u6d6a\u4e91\u6280\u672f\u652f\u6301<\/a>\u3002<\/p>\n<h2>\u603b\u7ed3<\/h2>\n<p>\u901a\u8fc7\u5bf9\u6bd4CentOS\u548cUbuntu\u7684\u547d\u4ee4\u5dee\u5f02\uff0c\u6211\u4eec\u5728\u540e\u6d6a\u4e91VPS\u4e0a\u9ad8\u6548\u90e8\u7f72\u4e86Web\u670d\u52a1\u5668\u3002\u7ed3\u5408\u540e\u6d6a\u4e91\u7684\u9ad8\u6027\u80fd\u786c\u4ef6\u548c\u53ef\u9760\u7f51\u7edc\uff0c\u5f00\u53d1\u8005\u548c\u7cfb\u7edf\u7ba1\u7406\u5458\u53ef\u6839\u636e\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u53d1\u884c\u7248\uff0c\u4f18\u5316\u7cfb\u7edf\u7ba1\u7406\u548c\u5e94\u7528\u90e8\u7f72\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f15\u8a00 CentOS\u548cUbuntu\u662f\u4e91\u670d\u52a1\u5668\u73af\u5883\u4e2d\u5e7f\u6cdb\u4f7f\u7528\u7684Linux\u53d1\u884c\u7248\uff0c\u5206\u522b\u57fa\u4e8eRPM\u548cDEB\u4f53\u7cfb\uff0c\u5728\u5305\u7ba1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27,34,28],"tags":[],"class_list":["post-441815","post","type-post","status-publish","format-standard","hentry","category-centos","category-linux","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/441815","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=441815"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/441815\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=441815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=441815"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=441815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}