{"id":33214,"date":"2022-11-07T17:53:40","date_gmt":"2023-08-11T14:42:53","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e8%8d%89%e7%a8%bf\/"},"modified":"2024-04-28T23:30:53","modified_gmt":"2024-04-28T15:30:53","slug":"%e8%8d%89%e7%a8%bf","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e8%8d%89%e7%a8%bf\/","title":{"rendered":"\u8349\u7a3f"},"content":{"rendered":"<p>\u5728 CentOS \u4e0a\u5b89\u88c5 nodejs\u3002<\/p>\n<pre class=\"post-pre\"><code>\u30e1\u30e2\u66f8\u304d\r\n\u30db\u30fc\u30e0\u30da\u30fc\u30b8\u304b\u3089\u53d6\u3063\u3066\u304f\u308b\u306e\u3067\u306f\u306a\u304f\u3001\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u304b\u3089\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3002\r\n\u30b0\u30fc\u30b0\u30eb\u691c\u7d22\u3059\u308b\u3068\u304d\u306f\u3000\u4f1a\u8a71\u3059\u308b\u611f\u3058\u3067\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u9069\u5f53\u306b\u6253\u3061\u8fbc\u3080\u306e\u304c\u3000\u60c5\u5831\u306b\u5f53\u3066\u3084\u3059\u3044\u3002\r\nHow to install a nodejs on CentOS?\r\n\u3068\u304b\u3002\r\nWeb\u8a18\u4e8b\u3082\u82f1\u8a9e\u3067\u4f1a\u8a71\u3057\u3066\u305f\u308a\u3059\u308b\u306e\u3067\u3002\u65e5\u672c\u8a9e\u306f\u4f1a\u8a71\u8868\u73fe\u304c\u3044\u308d\u3044\u308d\u3042\u3063\u3066\u3000\u60c5\u5831\u306b\u5f53\u3066\u3065\u3089\u3044\u6c17\u304c\u3059\u308b\u3002\r\n\u30ad\u30fc\u30ef\u30fc\u30c9\u3060\u3051\u3092\u6253\u3061\u8fbc\u3080\u3068\u3000\u30ad\u30fc\u30ef\u30fc\u30c9\u72d9\u3044\u6483\u3061\u306e\u30a2\u30d5\u30a3\u30ea\u30a8\u30a4\u30c8\u8a18\u4e8b\u306b\u5f53\u305f\u308a\u3084\u3059\u3044\u6c17\u304c\u3059\u308b\u3002\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>http-server <span class=\"nt\">-p<\/span> 80\r\n<\/code><\/pre>\n<p>\u5f53\u8f93\u5165&#8221;and&#8221;\u547d\u4ee4\u65f6\uff0cWeb\u670d\u52a1\u5668\u4f1a\u572880\u7aef\u53e3\u542f\u52a8\u3002\u7136\u800c\uff0c\u7531\u4e8e\u8fd9\u6837\u505a\u4f1a\u5bfc\u81f4nodejs\u4e0d\u6298\u4e0d\u6263\u5730\u52aa\u529b\uff0c\u6240\u4ee5\u9700\u8981\u5728\u5176\u524d\u9762\u52a0\u4e0anginx\u4f5c\u4e3a\u4e2d\u95f4\u670d\u52a1\u5668\u3002<\/p>\n<pre class=\"post-pre\"><code>\u3053\u308c\u3082\u3084\u306f\u308a\r\nHow to install nginx on CentOS?\r\n<\/code><\/pre>\n<p>\u4f60\u4eec\u53ef\u80fd\u4e0d\u77e5\u9053\u8fc7\u53bb\u7684PC\u60c5\u51b5\uff0c\u4f46\u5bf9\u4e8e\u8001\u4eba\u6765\u8bf4\u6700\u8fd1\u7684PC\u60c5\u51b5\u662f\u901a\u8fc7\u5728\u672c\u5730\u7535\u8111\u4e0a\u521b\u5efa\u5b58\u50a8\u5e93\u8fdb\u884c\u5206\u5e03\u5f0f\u5904\u7406\u8ba1\u7b97\uff0c\u6211\u4f1a\u60f3\u5230\u201c\u54c7\u201d\u7684\u3002\u8fc7\u53bb\u53ea\u9700\u8981\u4e0b\u8f7d\u548c\u5b89\u88c5\u3002<\/p>\n<p>\u67d0\u7bc7\u65e7\u7684\u6587\u7ae0<\/p>\n<p>\u5148\u6682\u4e14\u4ee5\u6211\u7684\u7535\u8111\u4e3a\u4f8b\uff0c\u91c7\u7528\u6700\u9ad8\u6743\u9650\u8fdb\u884c\u64cd\u4f5c\u3002<\/p>\n<pre class=\"post-pre\"><code>sudo su -\r\ncd \/\r\nls\r\ncd etc\r\nls\r\ncd yum.repos.d\r\nls\r\nvi nginx.repo\r\n<\/code><\/pre>\n<p>\u5df2\u7ecf\u5199\u597d\u4e86\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"p\">:<\/span><span class=\"k\">q<\/span><span class=\"p\">!<\/span>\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code><span class=\"nb\">ls<\/span> <span class=\"nt\">-l<\/span> \/etc\/yum.repos.d\/\r\n\r\n<span class=\"nb\">cd<\/span> \/\r\nyum info nginx\r\n<\/code><\/pre>\n<p>\u8fd8\u662f\u89c9\u5f97\u4e71\u4e03\u516b\u7cdf\u7684\uff0c\u611f\u5230\u4e0d\u6109\u5feb\u3002\u6211\u4eec\u56de\u5bb6\u5427\u3002<\/p>\n<pre class=\"post-pre\"><code>exit\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>how to use systemctl?\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>systemctl list-unit-files <span class=\"nt\">--type<\/span><span class=\"o\">=<\/span>service\r\n<\/code><\/pre>\n<p>nginx \u6ca1\u6709\u8fd0\u884c\u3002<\/p>\n<pre class=\"post-pre\"><code>How do you link nginx and nodejs?\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>sudo su -\r\ncd etc\r\ncd nginx\r\nls\r\nvi nginx.conf\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>events <span class=\"p\">{<\/span>\r\n    worker_rlimit_nofile <span class=\"m\">10240<\/span>;\r\n    worker_connections  <span class=\"m\">1024<\/span>;\r\n<span class=\"p\">}<\/span>\r\n<\/code><\/pre>\n<p>nginx\u548cnodejs\u7684\u534f\u4f5c\u4e0d\u592a\u987a\u5229\u3002<\/p>\n<p>\u4e0d\u4f7f\u7528nginx\u3002<\/p>\n<pre class=\"post-pre\"><code>http-server -p 80\r\n<\/code><\/pre>\n<p>\u4e0d\u901a\u3002<\/p>\n<pre class=\"post-pre\"><code>exit\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>pm2 start\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>how to start server nodejs by pm2?\r\n<\/code><\/pre>\n<p>\u6211\u627e\u4e0d\u5230Node.js\u7684\u5b58\u50a8\u5e93\u3002\u5b83\u53bb\u54ea\u4e86\uff1f\u662f\u5426\u9700\u8981\u91cd\u65b0\u5efa\u7acb\uff1f<\/p>\n<pre class=\"post-pre\"><code>mkdir xxx\r\ncd xxx\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>how to install nodejs on centos?\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>node -v\r\nv11.5.0\r\n<\/code><\/pre>\n<p>\u8fdb\u6765\u4e86\u3002<\/p>\n<p>[Node.js] \u6784\u5efaWeb\u670d\u52a1\u5668+\u5e94\u7528\u901f\u5ea6\u592a\u5feb\u4e86 \u301c JS\u7684\u5965\u79d8\u4e4b\u9053\uff03004<\/p>\n<p>\u9ebb\u70e6\u3002\u88c5\u4e2aWinSCP\u3002<\/p>\n<p>WinSCP-\u83b7\u80dc\u7684SCP<\/p>\n<p>\u6211\u51b3\u5b9a\u5728Windows\u4e0a\u7f16\u5199JavaScript\u5e76\u5c06\u5176\u53d1\u9001\u5230CentOS\u3002<\/p>\n<pre class=\"post-pre\"><code>var http = require('http');\r\nhttp.createServer(function (req, res) {\r\n    res.writeHead(200, {'Content-Type': 'text\/plain'});\r\n    res.end('Hello Kifuwarabe!\\n');\r\n}).listen(80, 'http:\/\/192.168.xx.xx');\r\n<\/code><\/pre>\n<p>\u4e0d\u52a8\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nx\">console<\/span><span class=\"p\">.<\/span><span class=\"nx\">log<\/span><span class=\"p\">(<\/span><span class=\"dl\">\"<\/span><span class=\"s2\">Hello js!<\/span><span class=\"dl\">\"<\/span><span class=\"p\">);<\/span>\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>node hello.js\r\n<\/code><\/pre>\n<p>\u52a8\u8d77\u6765\u3002<\/p>\n<pre class=\"post-pre\"><code>var http = require('http');\r\nhttp.createServer(function (req, res) {\r\n    res.writeHead(200, {'Content-Type': 'text\/plain'});\r\n    res.end('Hello Kifuwarabe!\\n');\r\n}).listen(80, '192.168.xx.xx');\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code><span class=\"nb\">sudo <\/span>node start-server.js\r\n<\/code><\/pre>\n<p>\u4e00\u65e6\u6743\u9650\u8bbe\u5b9a\u597d\u540e\u5c31\u53ef\u4ee5\u8fd0\u884c\u4e86\u3002\u7136\u800c\uff0c\u53ea\u80fd\u5728\u5bb6\u4e2d\u7684\u5c40\u57df\u7f51\u5185\u770b\u5230\u3002<\/p>\n<p>\u5728\u8c37\u6b4c\u6d4f\u89c8\u5668\u4e2d\u6309 [Ctrl]+[F5] \u8fdb\u884c\u8d85\u7ea7\u5237\u65b0\u3002\u4ecd\u7136\u770b\u4e0d\u5230\u3002<br \/>\n\u4e5f\u8bb8\u9700\u8981\u4e00\u4e2a\u53d1\u5939\u8def\u7531\u5668\u3002\u592a\u9ebb\u70e6\u4e86\u3002\u5c1d\u8bd5\u4f7f\u7528IP\u5730\u5740\u8bbf\u95ee\u3002\u53ef\u4ee5\u770b\u5230\u3002<\/p>\n<p>\u76f4\u63a5\u4ece\u7ec8\u7aef\u9000\u51fa\u4f1a\u5bfc\u81f4Web\u670d\u52a1\u5668\u5173\u95ed\u3002\u8fd9\u6837\u7684\u4e1c\u897f\u4e0d\u80fd\u79f0\u4e4b\u4e3aWeb\u670d\u52a1\u5668\u3002<\/p>\n<pre class=\"post-pre\"><code>pm2 start start-server.js\r\n<\/code><\/pre>\n<p>\u4e0d\u53ef\u80fd\u3002<\/p>\n<pre class=\"post-pre\"><code>pm2 stop start-server\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>npm <span class=\"nb\">install <\/span>express\r\nnpm <span class=\"nb\">install <\/span>express-generator\r\n.\/node_modules\/.bin\/express\r\n<span class=\"nb\">ls<\/span>\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code><span class=\"nb\">sudo <\/span>yum <span class=\"nb\">install <\/span>tree\r\ny\r\ntree <span class=\"nt\">-I<\/span> node_modules\r\n<span class=\"nb\">.<\/span>\r\n\u251c\u2500\u2500 app.js\r\n\u251c\u2500\u2500 bin\r\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 www\r\n\u251c\u2500\u2500 hello.js\r\n\u251c\u2500\u2500 package-lock.json\r\n\u251c\u2500\u2500 package.json\r\n\u251c\u2500\u2500 public\r\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 images\r\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 javascripts\r\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 stylesheets\r\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 style.css\r\n\u251c\u2500\u2500 routes\r\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 index.js\r\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 users.js\r\n\u251c\u2500\u2500 start-server.js\r\n\u2514\u2500\u2500 views\r\n    \u251c\u2500\u2500 error.jade\r\n    \u251c\u2500\u2500 index.jade\r\n    \u2514\u2500\u2500 layout.jade\r\n<\/code><\/pre>\n<p>www\u5728bin\u76ee\u5f55\u4e2d\u3002<br \/>\n\u4e0d\u770b\u8bf4\u660e\u5c31\u5f00\u59cb\u6253\u5b57\u3002<\/p>\n<pre class=\"post-pre\"><code>pm2 start bin\/www\r\n<\/code><\/pre>\n<p>\u4e0d\u884c\u3002<\/p>\n<pre class=\"post-pre\"><code>pm2 stop www\r\n\r\nnpm <span class=\"nb\">install\r\n<\/span>npm audit fix\r\nnpm start\r\n<\/code><\/pre>\n<p>\u8fd9\u4e5f\u662f\u4e0d\u53ef\u80fd\u7684\u3002<\/p>\n<pre class=\"post-pre\"><code>curl http:\/\/localhost:3000\r\ncurl: (7) Failed connect to localhost:3000; \u63a5\u7d9a\u3092\u62d2\u5426\u3055\u308c\u307e\u3057\u305f\r\n\r\ncurl http:\/\/127.0.0.1:3000\r\ncurl: (7) Failed connect to 127.0.0.1:3000; \u63a5\u7d9a\u3092\u62d2\u5426\u3055\u308c\u307e\u3057\u305f\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>pm2 start bin\/www\r\ncurl http:\/\/127.0.0.1:3000\r\n<\/code><\/pre>\n<p>\u53ef\u4ee5\u4e86\u3002<br \/>\n\u4f46\u9019\u53ea\u80fd\u5728\u672c\u5730\u4e3b\u6a5f\u4e0a\u904b\u884c\uff0c\u7121\u6cd5\u5f9e\u5916\u90e8\u8a2a\u554f\u3002Nginx\u672a\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n<p>\u5728\u5c40\u57df\u7f51\u7684\u5185\u90e8\u770b\u4e0d\u89c1\u3002\u53ea\u80fd\u5728CentOS\u4e2d\u770b\u89c1\u3002<\/p>\n<p>\u5c06Nginx\u53cd\u5411\u4ee3\u7406\u81f3Node.js\u3002<\/p>\n<p>\u6211\u4e0d\u660e\u767d\u3002\u6211\u8981\u770b\u5f15\u7528\u7684\u6587\u7ae0\u3002<\/p>\n<p>\u5c06Nginx\u914d\u7f6e\u4e3a\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\u3002<\/p>\n<pre class=\"post-pre\"><code>vi \/etc\/nginx\/nginx.conf\r\n<\/code><\/pre>\n<p>\u5199\u7684\u5185\u5bb9\u6709\u5f88\u5927\u7684\u5dee\u5f02\u3002<\/p>\n<pre class=\"post-pre\"><code>vi \/etc\/nginx\/conf.d\/default.conf\r\n<\/code><\/pre>\n<p>\u8fd9\u8fb9\u5427\u3002\u6211\u4eec\u6765\u770b\u4e00\u4e0b\u8bbe\u7f6e\u2026\u2026\u3002<\/p>\n<pre class=\"post-pre\"><code>    <span class=\"n\">location<\/span> \/ {\r\n        <span class=\"n\">root<\/span>   \/<span class=\"n\">usr<\/span>\/<span class=\"n\">share<\/span>\/<span class=\"n\">nginx<\/span>\/<span class=\"n\">html<\/span>;\r\n        <span class=\"n\">index<\/span>  <span class=\"n\">index<\/span>.<span class=\"n\">html<\/span> <span class=\"n\">index<\/span>.<span class=\"n\">htm<\/span>;\r\n    }\r\n<\/code><\/pre>\n<p>\u5728\u67e5\u770b usr \u76ee\u5f55\u3002 \u9ed8\u8ba4\u7684\u5417\uff1f<br \/>\n\u6307\u5b9a\u8981\u52a8\u6001\u751f\u6210\u7684 express \u662f\u4ec0\u4e48\uff1f<\/p>\n<p>\u5b8c\u5168\u4e0d\u660e\u767d\u3002\u6211\u8bd5\u7740\u6dfb\u52a0\u4e00\u4e9b\u5185\u5bb9\u3002<\/p>\n<pre class=\"post-pre\"><code>sudo vi default.conf\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>server {\r\n    location @node {\r\n        proxy_pass http:\/\/node;\r\n        proxy_redirect off;\r\n        proxy_http_version 1.1;\r\n        proxy_set_header Upgrade $http_upgrade;\r\n        proxy_set_header Connection 'upgrade';\r\n        proxy_set_header Host $host;\r\n        proxy_set_header X-Real-IP $remote_addr;\r\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n        proxy_cache_bypass $http_upgrade;\r\n    }\r\n}\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>pm2 restart www\r\n\r\ncurl http:\/\/localhost\r\ncurl: (7) Failed connect to localhost:80; \u63a5\u7d9a\u3092\u62d2\u5426\u3055\u308c\u307e\u3057\u305f\r\n<\/code><\/pre>\n<p>\u636e\u6211\u6240\u77e5\uff0c\u9605\u8bfb\u7684\u6587\u7ae0\u548c\u64cd\u4f5c\u7cfb\u7edf\u597d\u50cf\u4e0d\u4e00\u6837\u3002<\/p>\n<pre class=\"post-pre\"><code>systemctl restart nginx\r\n<\/code><\/pre>\n<p>\u4e0d\u53ef\u80fd\u7684\u3002\u8bfb\u9519\u4e86\u4e00\u7bc7\u6587\u7ae0\u3002<\/p>\n<p>\u5728CentOS\u4e0a\u642d\u5efaNodeJS+nginx\u73af\u5883\u3002<\/p>\n<pre class=\"post-pre\"><code>sudo \/etc\/init.d\/nginx restart\r\nsudo: \/etc\/init.d\/nginx: \u30b3\u30de\u30f3\u30c9\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>sudo nginx -s reload\r\nnginx: [emerg] \"worker_rlimit_nofile\" directive is not allowed here in \/etc\/nginx\/nginx.conf:10\r\n<\/code><\/pre>\n<p>\u6309\u7167\u793a\u4f8b\u7a0b\u5e8f\u5199\u7684\u8bdd\u4f1a\u51fa\u73b0\u9519\u8bef\u3002<\/p>\n<p>\u542f\u52a8Nginx\uff0c\u91cd\u65b0\u542f\u52a8<\/p>\n<pre class=\"post-pre\"><code>sudo nginx -s reload\r\nnginx: [error] open() \"\/var\/run\/nginx.pid\" failed (2: No such file or directory)\r\n<\/code><\/pre>\n<p>\u5176\u5b9e\u6839\u672c\u6ca1\u5f00\u673a\u3002<\/p>\n<h2>\u542f\u52a8 Nginx<\/h2>\n<pre class=\"post-pre\"><code>systemctl start nginx\r\n\r\ncurl http:\/\/localhost:80\r\n<\/code><\/pre>\n<p>\u5728\u672c\u5730\u53ef\u4ee5\u770b\u5230\u3002<\/p>\n<pre class=\"post-pre\"><code>500 Internal Server Error\r\nnginx\/1.14.2\r\n<\/code><\/pre>\n<p>\u5f9e\u5916\u90e8\u958b\u59cb\u63a5\u6536\u5230nginx\u7684\u56de\u61c9\u4e86\u3002<br \/>\n\u662f\u4e0d\u662f\u53ea\u8981\u7d66HTTP\u52a0\u4e0a\u6a19\u982d\u5c31\u53ef\u4ee5\u4e86\uff1f<\/p>\n<pre class=\"post-pre\"><code>http {\r\n    proxy_set_header X-Real-IP $remote_addr;\r\n    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n    proxy_set_header Host $http_host;\r\n    proxy_set_header X-NginX-Proxy true;\r\n    proxy_redirect off;\r\n}\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>400 Bad Request\r\nRequest Header Or Cookie Too Large\r\nnginx\/1.14.2\r\n<\/code><\/pre>\n<p>\u55ef\uff0c\u56e0\u4e3a\u52a0\u4e86\u6807\u9898\u3002<\/p>\n<p>\u5982\u679cnginx\u8fd4\u56de\u9519\u8bef\uff0c\u662f\u4e0d\u662f\u53ef\u4ee5\u67e5\u770bnginx\u7684\u65e5\u5fd7\uff1f<\/p>\n<pre class=\"post-pre\"><code>cd \/var\/log\/nginx\/\r\nls\r\nvi error.log\r\n\u8a8d\u53ef\u304c\u3042\u308a\u307e\u305b\u3093\r\nsudo vi error.log\r\n\r\n2019\/03\/10 02:27:50 [alert] 53970#53970: *5202 socket() failed (24: Too many open files) while connecting to upstream, client: 127.0.0.1, server: xxxxxxxxxxxxx, request: \"GET \/ HTTP\/1.0\", upstream: \"http:\/\/127.0.0.1:80\/\", host: \"backend_node\"\r\n2019\/03\/10 02:27:50 [crit] 53970#53970: *5202 open() \"\/usr\/share\/nginx\/html\/50x.html\" failed (24: Too many open files), client: 127.0.0.1, server: xxxxxxxxxxxxxxx, request: \"GET \/ HTTP\/1.0\", upstream: \"http:\/\/127.0.0.1:80\/\", host: \"backend_node\"\r\n<\/code><\/pre>\n<p>\u662f\u5426\u5c06\u6570\u636e\u4f20\u8f93\u5230\u8282\u70b9\u4e86\u5417\uff1f<\/p>\n<pre class=\"post-pre\"><code>:q\r\npm2 list\r\n<\/code><\/pre>\n<p>Express\u6b63\u5728\u8fd0\u884c\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"nb\">sudo <\/span>vi \/etc\/nginx\/conf.d\/default.conf\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>upstream backend_node {\r\n    ip_hash;\r\n    # Nodejs express port.\r\n    server 127.0.0.1:3000;\r\n}\r\n<\/code><\/pre>\n<p>Express \u6846\u67b6\u7684\u7aef\u53e3\u662f 3000 \u662f\u5417\u3002<\/p>\n<pre class=\"post-pre\"><code>systemctl restart nginx\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>An error occurred.\r\nSorry, the page you are looking for is currently unavailable.\r\nPlease try again later.\r\n\r\nIf you are the system administrator of this resource then you should check the error log for details.\r\n\r\nFaithfully yours, nginx.\r\n<\/code><\/pre>\n<p>\u9519\u8bef\u9875\u9762\u4e0d\u505c\u5730\u53d8\u6362\u3002<br \/>\n\u603b\u4e4b\uff0c\u611f\u89c9\u597d\u50cf\u662f\u5728\u5012\u9000\u3002<\/p>\n<pre class=\"post-pre\"><code>cd ~\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>curl http:\/\/localhost:80\r\n<\/code><\/pre>\n<p>\u5728enginx\u7684\u9519\u8bef\u9875\u9762\u4e0a\uff0c<\/p>\n<pre class=\"post-pre\"><code>curl http:\/\/localhost:3000\r\n<\/code><\/pre>\n<p>\u6b22\u8fce\u6765\u5230Express\u754c\u9762\uff0c\u8fd8\u6ca1\u6709\u8fdb\u884c\u534f\u540c\u5408\u4f5c\u3002<br \/>\n\u6ca1\u6709\u4efb\u52a1\u53ef\u505a\u3002<\/p>\n<pre class=\"post-pre\"><code>sudo npm install -g npm-check-updates\r\nncu\r\nncu -u\r\nnpm install\r\nnpm audit fix\r\n<\/code><\/pre>\n<p>\u55ef\u3002<\/p>\n<p>\u4fee\u6539 default.conf\u3002<\/p>\n<pre class=\"post-pre\"><code>Welcome to nginx!\r\nIf you see this page, the nginx web server is successfully installed and working. Further configuration is required.\r\n\r\nFor online documentation and support please refer to nginx.org.\r\nCommercial support is available at nginx.com.\r\n\r\nThank you for using nginx.\r\n<\/code><\/pre>\n<p>\u56de\u5230\u9ed8\u8ba4\u753b\u9762\u3002<\/p>\n<p>\u6211\u8981\u6539\u53d8\u8fd9\u7bc7\u6587\u7ae0\u3002<\/p>\n<p>\u5c06Nginx\u4f5c\u4e3aNode.js\u7684\u53cd\u5411\u4ee3\u7406<\/p>\n<p>\u6211\u8981\u6539\u53d8\u6587\u7ae0\u3002<\/p>\n<p>\u5728Vagrant\u73af\u5883\u4e2d\u5b89\u88c5CentOS 7.1\u4e0a\u7684Nginx+NodeJS\uff08nvm\uff09\u3002<\/p>\n<pre class=\"post-pre\"><code>sudo nginx -t\r\nnginx: the configuration file \/etc\/nginx\/nginx.conf syntax is ok\r\nnginx: configuration file \/etc\/nginx\/nginx.conf test is successful\r\n<\/code><\/pre>\n<p>\u505c\u6b62 nginx\u3002<\/p>\n<pre class=\"post-pre\"><code>systemctl stop nginx\r\n\r\nsudo http-server -p 80\r\n<\/code><\/pre>\n<p>\u76f8\u8fde\u3002<\/p>\n<pre class=\"post-pre\"><code>sudo node start-server.js\r\n<\/code><\/pre>\n<p>\u8fd9\u4e5f\u662f\u76f8\u4e92\u8054\u7cfb\u7684\u3002<\/p>\n<pre class=\"post-pre\"><code> curl http:\/\/localhost:3000\r\n<\/code><\/pre>\n<p>\u8054\u7cfb\u8d77\u6765\u3002<\/p>\n<pre class=\"post-pre\"><code>curl http:\/\/localhost:80\r\ncurl: (7) Failed connect to localhost:80; \u63a5\u7d9a\u3092\u62d2\u5426\u3055\u308c\u307e\u3057\u305f\r\n\r\ncurl http:\/\/localhost:8080\r\ncurl: (7) Failed connect to localhost:8080; \u63a5\u7d9a\u3092\u62d2\u5426\u3055\u308c\u307e\u3057\u305f\r\n<\/code><\/pre>\n<p>\u7136\u540enginx\u4f3c\u4e4e\u53ea\u662f\u6ca1\u6709\u5de5\u4f5c&#8230;&#8230;<\/p>\n<pre class=\"post-pre\"><code>curl http:\/\/localhost\/page.html\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;title&gt;Error&lt;\/title&gt;\r\n&lt;style&gt;\r\n    body {\r\n        width: 35em;\r\n        margin: 0 auto;\r\n        font-family: Tahoma, Verdana, Arial, sans-serif;\r\n    }\r\n&lt;\/style&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;h1&gt;An error occurred.&lt;\/h1&gt;\r\n&lt;p&gt;Sorry, the page you are looking for is currently unavailable.&lt;br\/&gt;\r\nPlease try again later.&lt;\/p&gt;\r\n&lt;p&gt;If you are the system administrator of this resource then you should check\r\nthe &lt;a href=\"http:\/\/nginx.org\/r\/error_log\"&gt;error log&lt;\/a&gt; for details.&lt;\/p&gt;\r\n&lt;p&gt;&lt;em&gt;Faithfully yours, nginx.&lt;\/em&gt;&lt;\/p&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/code><\/pre>\n<p>\u5373\u4f7f\u6307\u5b9a\u4e86\u4e0d\u5b58\u5728\u7684\u9875\u9762\uff0cnginx\u4e5f\u4f1a\u505a\u51fa\u54cd\u5e94\u3002<\/p>\n<p>\u6539\u53d8\u6587\u7ae0\u3002<\/p>\n<p>71\u53f7\u5e16\u5b50\u7684\u535a\u5ba2<\/p>\n<p>\u6539\u53d8\u6587\u7ae0\u3002<\/p>\n<p>nginx\u7cfb\u5217\u7b2c4\u7bc7\uff1anginx\u914d\u7f6e\u6307\u5357\uff0c\u7b2c2\u90e8\u5206 &#8211; \u865a\u62df\u670d\u52a1\u5668\u7684\u914d\u7f6e<\/p>\n<p>\u6539\u53d8\u62a5\u9053\u3002<\/p>\n<p>CentOS7\u4e2d\u7684nginx\u914d\u7f6e\u3002<\/p>\n<pre class=\"post-pre\"><code>#\u72b6\u614b\u78ba\u8a8d\r\nsystemctl status nginx\r\n\r\n\r\n\u25cf nginx.service - nginx - high performance web server\r\n   Loaded: loaded (\/usr\/lib\/systemd\/system\/nginx.service; disabled; vendor preset: disabled)\r\n   Active: active (running) since \u65e5 2019-03-10 04:10:18 JST; 3min 1s ago\r\n     Docs: http:\/\/nginx.org\/en\/docs\/\r\n  Process: 55904 ExecStop=\/bin\/kill -s TERM $MAINPID (code=exited, status=0\/SUCCESS)\r\n  Process: 55907 ExecStart=\/usr\/sbin\/nginx -c \/etc\/nginx\/nginx.conf (code=exited, status=0\/SUCCESS)\r\n Main PID: 55908 (nginx)\r\n   CGroup: \/system.slice\/nginx.service\r\n           \u251c\u250055908 nginx: master process \/usr\/sbin\/nginx -c \/etc\/nginx\/nginx....\r\n           \u251c\u250055909 nginx: worker process\r\n           \u251c\u250055910 nginx: worker process\r\n           \u251c\u250055911 nginx: worker process\r\n           \u251c\u250055912 nginx: worker process\r\n           \u251c\u250055913 nginx: worker process\r\n           \u251c\u250055914 nginx: worker process\r\n           \u251c\u250055915 nginx: worker process\r\n           \u251c\u250055916 nginx: worker process\r\n           \u251c\u250055917 nginx: worker process\r\n           \u251c\u250055918 nginx: worker process\r\n           \u251c\u250055919 nginx: worker process\r\n           \u2514\u250055920 nginx: worker process\r\n\r\n 3\u6708 10 04:10:18 localhost.localdomain systemd[1]: Starting nginx - high per...\r\n 3\u6708 10 04:10:18 localhost.localdomain systemd[1]: Started nginx - high perf...\r\nHint: Some lines were ellipsized, use -l to show in full.\r\n<\/code><\/pre>\n<p>\u6539\u53d8\u6587\u7ae0\u3002<\/p>\n<p>\u5982\u679cpm2\u6b63\u5728\u8fd0\u884c\uff0c\u5219\u5c06nginx\u7684proxy_pass\u8bbe\u4e3a\u3002<\/p>\n<p>\u6539\u53d8\u6587\u7ae0\u5185\u5bb9\u3002<\/p>\n<p>\u4f7f\u7528React+Next.js+PM2+Nginx\u6765\u90e8\u7f72\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<pre class=\"post-pre\"><code>node -v\r\nv11.5.0\r\nnpm -v\r\n6.4.1\r\n<\/code><\/pre>\n<p>\u6211\u7a0d\u5fae\u7406\u89e3\u4e86\u9053\u7406\u3002\uff08\u867d\u7136\u8fd9\u4e9b\u6587\u7ae0\u90fd\u6ca1\u6709\u89e3\u91ca\u9053\u7406\u2026\u2026\u2606\uff09<\/p>\n<pre class=\"post-pre\"><code>\/etc\/nginx\/conf.d\/default.conf\r\n\/etc\/nginx\/conf.d\/xxxxx.conf\r\n<\/code><\/pre>\n<p>\u53ef\u4ee5\u521b\u5efa\u591a\u4e2a\u914d\u7f6e\u6587\u4ef6\uff0c\u5e76\u4e14\u53ef\u4ee5\u6839\u636e\u57df\u540d\u7b49\u5c06 server {} \u76ee\u5f55\u5199\u5165\u5230\u672c\u5730\u4e3b\u673a\u7b49\u4e0d\u540c\u7684\u4f4d\u7f6e\u3002<br \/>\n\u5982\u679c\u914d\u7f6e\u91cd\u590d\uff0c\u5219\u53ef\u4ee5\u901a\u8fc7 sudo nginx -t \u6307\u4ee4\u67e5\u770b\u9519\u8bef\u884c\u3002<\/p>\n<p>\u8bd5\u7740\u6539\u53d8\u4e00\u4e0b\u4e8b\u6001\u3002<\/p>\n<p>\u76f4\u5230\u642d\u5efaCentOS\u4e0a\u7684node.js+Express\u73af\u5883\u5e76\u8fdb\u884c\u6d4b\u8bd5<\/p>\n<p>\u8bd5\u7740\u6539\u53d8\u4e00\u4e0b\u6001\u5ea6\u3002<\/p>\n<p>\u5c06\u8282\u70b9daemonize\u5e76\u5c06nginx\u4f5c\u4e3a\u53cd\u5411\u4ee3\u7406\u4e0e\u5176\u8fde\u63a5<\/p>\n<pre class=\"post-pre\"><code>sudo nginx -t\r\nnginx: [emerg] \"proxy_redirect\" directive is not allowed here in \/etc\/nginx\/conf.d\/ip.conf:25\r\nnginx: configuration file \/etc\/nginx\/nginx.conf test failed\r\n<\/code><\/pre>\n<p>\u6709\u4e9b\u5730\u65b9\u65e0\u6cd5\u7f16\u5199\u4ee3\u7406\u91cd\u5b9a\u5411\u3002<\/p>\n<p>\u8bd5\u7740\u66f4\u6539\u6587\u7ae0\u3002<\/p>\n<p>\u5728\u5f00\u53d1\u670d\u52a1\u5668\u4e0a\uff0c\u81f3\u5c11\u9700\u8981\u505a\u8fd9\u4e00\u4e2anginx\u7684\u8bbe\u7f6e<\/p>\n<pre class=\"post-pre\"><code>grep processor \/proc\/cpuinfo | wc -l\r\n4\r\n\r\nulimit -n\r\n1024\r\n<\/code><\/pre>\n<p>\u6539\u53d8\u6587\u7ae0\u3002<\/p>\n<p>[nginx] \u53ea\u9700\u89815\u5206\u949f\u5c31\u8db3\u591f\u4e86\uff0c\u7ed9\u6211\u8dea\u4e0b\uff01\uff01<\/p>\n<p>\u6539\u53d8\u6587\u7ae0\u3002<\/p>\n<p>\u4f7f\u7528Node.js + Express + forever\u7684\u7ec4\u5408\uff0c\u5e76\u901a\u8fc7nginx\u8fdb\u884c\u4f20\u8f93\u3002<\/p>\n<pre class=\"post-pre\"><code>proxy_redirect                          off;\r\n<\/code><\/pre>\n<p>\u6211\u5e94\u8be5\u4f1a\u5199\uff0c\u4f46\u662f\u51fa\u73b0 &#8220;proxy_redirect&#8221; \u6307\u4ee4\u4e0d\u5141\u8bb8 \u7684\u9519\u8bef\u53ef\u80fd\u662f\u539f\u56e0\u4e4b\u4e00\u3002<\/p>\n<p>\u6539\u53d8\u65b0\u95fb\u62a5\u9053\u3002<\/p>\n<p>[\u968f\u7b14] \u5bf9\u4e8e nginx \u7684 proxy_set_header \u7684\u4f7f\u7528\u65b9\u5f0f<\/p>\n<p>\u6ca1\u6709\u53d8\u5316\u3002<\/p>\n<p>\u6539\u53d8\u6587\u7ae0\u3002<\/p>\n<p>nginx: Linux\u8f6f\u4ef6\u5305<\/p>\n<pre class=\"post-pre\"><code>sudo yum install yum-utils\r\n\r\n\u30d1\u30c3\u30b1\u30fc\u30b8 yum-utils-1.1.31-50.el7.noarch \u306f\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6e08\u307f\u304b\u6700\u65b0\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u3059\r\n\u4f55\u3082\u3057\u307e\u305b\u3093\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>vi \/etc\/yum.repos.d\/nginx.repo\r\n\r\n[nginx]\r\nname=nginx repo\r\nbaseurl=http:\/\/nginx.org\/packages\/centos\/7\/$basearch\/\r\ngpgcheck=0\r\nenabled=1\r\n<\/code><\/pre>\n<p>\u5185\u5bb9\u4e0d\u540c\u3002<\/p>\n<pre class=\"post-pre\"><code>[nginx-stable]\r\nname=nginx stable repo\r\nbaseurl=http:\/\/nginx.org\/packages\/centos\/$releasever\/$basearch\/\r\ngpgcheck=1\r\nenabled=1\r\ngpgkey=https:\/\/nginx.org\/keys\/nginx_signing.key\r\n\r\n[nginx-mainline]\r\nname=nginx mainline repo\r\nbaseurl=http:\/\/nginx.org\/packages\/mainline\/centos\/$releasever\/$basearch\/\r\ngpgcheck=1\r\nenabled=0\r\ngpgkey=https:\/\/nginx.org\/keys\/nginx_signing.key\r\n<\/code><\/pre>\n<p>\u6539\u5199\u3002<\/p>\n<pre class=\"post-pre\"><code>sudo yum-config-manager --enable nginx-mainline\r\nsudo yum install nginx\r\n<\/code><\/pre>\n<p>Nginx\u7684\u7248\u672c\u5c06\u53d1\u751f\u53d8\u5316\u3002<\/p>\n<p>\u6539\u53d8\u6587\u7ae0\u3002<\/p>\n<p>\u5f00\u59cb\u3001\u505c\u6b62\u548c\u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e<\/p>\n<p>\u53ea\u9700\u8981\u6267\u884c\u4e00\u6b21\u542f\u52a8nginx\uff0c\u7136\u540e\u4f7f\u7528nginx\u7684\u56db\u4e2a\u547d\u4ee4\u3002<\/p>\n<pre class=\"post-pre\"><code>nginx -s stop\r\nnginx -s quit\r\nnginx -s reload\r\nnginx -s reopen\r\n<\/code><\/pre>\n<p>\u6ca1\u6709\u521d\u6b21\u542f\u52a8\u7684\u8bf4\u660e\uff0c\u4f46\u53ef\u4ee5\u4f7f\u7528 systemctl start nginx \u547d\u4ee4\u6765\u542f\u52a8\u3002<\/p>\n<pre class=\"post-pre\"><code>nginx -s quit\r\nnginx: [alert] could not open error log file: open() \"\/var\/log\/nginx\/error.log\" failed (13: Permission denied)\r\n2019\/03\/10 06:42:08 [warn] 57176#57176: the \"user\" directive makes sense only if the master process runs with super-user privileges, ignored in \/etc\/nginx\/nginx.conf:2\r\n2019\/03\/10 06:42:08 [notice] 57176#57176: signal process started\r\n2019\/03\/10 06:42:08 [alert] 57176#57176: kill(57150, 3) failed (1: Operation not permitted)\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>sudo nginx -s reload\r\n<\/code><\/pre>\n<p>\u55ef\uff0c\u5fc5\u987b\u6709\u6743\u9650\u5417\uff1f<\/p>\n<pre class=\"post-pre\"><code>ps -ax | grep nginx\r\n\r\n 57150 ?        S      0:00 nginx: master process \/usr\/sbin\/nginx -c \/etc\/nginx\/nginx.conf\r\n 57180 ?        S      0:00 nginx: worker process\r\n 57181 ?        S      0:00 nginx: worker process\r\n 57182 ?        S      0:00 nginx: worker process\r\n 57183 ?        S      0:00 nginx: worker process\r\n 57185 pts\/1    S+     0:00 grep --color=auto nginx\r\n<\/code><\/pre>\n<p>\u6709\u4e00\u4e2a\u4ec0\u4e48\u5de5\u4f5c\u90fd\u4e0d\u505a\u7684nginx\u5b58\u5728\u3002<\/p>\n<pre class=\"post-pre\"><code>cd \/usr\/share\/nginx\/html\r\nls -l\r\n\u5408\u8a08 12\r\n-rw-r--r--. 1 root root 494  2\u6708 27 00:47 50x.html\r\n-rw-r--r--. 1 root root 612  2\u6708 27 00:47 index.html\r\n<\/code><\/pre>\n<p>\u6539\u53d8\u4e8b\u52a1\u3002<\/p>\n<p>nginx\u7684\u6240\u6709\u8005\u3001\u7ec4\u548c\u6743\u9650<\/p>\n<p>\u90a3\u4e48\uff0c\u8ba9\u6211\u4eec\u8bd5\u8bd5\u770b\u662f\u5426\u53ef\u4ee5\u8bbe\u7f6e\u80fd\u591f\u67e5\u770b\u672c\u5730\u6587\u4ef6\u7684\u914d\u7f6e\u3002<\/p>\n<pre class=\"post-pre\"><code>    server {\r\n        location \/ {\r\n            root \/home\/muzudho\/public-html;\r\n        }\r\n    }\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>nginx -s reload\r\nnginx: [alert] could not open error log file: open() \"\/var\/log\/nginx\/error.log\" failed (13: Permission denied)\r\n2019\/03\/10 12:28:19 [warn] 58407#58407: the \"user\" directive makes sense only if the master process runs with super-user privileges, ignored in \/etc\/nginx\/nginx.conf:2\r\n2019\/03\/10 12:28:19 [notice] 58407#58407: signal process started\r\n2019\/03\/10 12:28:19 [alert] 58407#58407: kill(57150, 1) failed (1: Operation not permitted)\r\n<\/code><\/pre>\n<p>\u4e0d\u8981\u6307\u5b9a\u7528\u6237\u4e3b\u9875\uff0c\u9009\u62e9\u5176\u4ed6\u76ee\u5f55\u6765\u6307\u5b9a\u3002<\/p>\n<pre class=\"post-pre\"><code>    server {\r\n        location \/ {\r\n            root \/usr\/share\/nginx\/html;\r\n        }\r\n    }\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>nginx -s reload\r\nnginx: [alert] could not open error log file: open() \"\/var\/log\/nginx\/error.log\" failed (13: Permission denied)\r\n2019\/03\/10 12:32:43 [warn] 58428#58428: the \"user\" directive makes sense only if the master process runs with super-user privileges, ignored in \/etc\/nginx\/nginx.conf:2\r\n2019\/03\/10 12:32:43 [notice] 58428#58428: signal process started\r\n2019\/03\/10 12:32:43 [alert] 58428#58428: kill(57150, 1) failed (1: Operation not permitted)\r\n<\/code><\/pre>\n<p>\u5982\u679c\u4e0d\u80fd\u5728\/usr\/share\u91cc\u627e\u7684\u8bdd\uff0c\u90a3\u53bb\u54ea\u91cc\u80fd\u627e\u5230\u5462\uff1f<\/p>\n<pre class=\"post-pre\"><code>sudo nginx -s reload\r\n<\/code><\/pre>\n<p>\u53ef\u4ee5\u8fd9\u6837\u505a\u3002\u8fd9\u4e2a\u65e5\u5fd7\u662f\u5426\u5177\u6709\u6839\u6743\u9650\uff1f<\/p>\n<pre class=\"post-pre\"><code>sudo nginx -s stop\r\n<\/code><\/pre>\n<p>\u5f3a\u884c\u505c\u6b62\u3002<\/p>\n<pre class=\"post-pre\"><code>systemctl start nginx\r\n<\/code><\/pre>\n<p>\u8bf7\u81ea\u884c\u542f\u52a8\u3002<\/p>\n<pre class=\"post-pre\"><code>nginx -t\r\nnginx: [alert] could not open error log file: open() \"\/var\/log\/nginx\/error.log\" failed (13: Permission denied)\r\n2019\/03\/10 12:40:25 [warn] 58508#58508: the \"user\" directive makes sense only if the master process runs with super-user privileges, ignored in \/etc\/nginx\/nginx.conf:2\r\nnginx: the configuration file \/etc\/nginx\/nginx.conf syntax is ok\r\n2019\/03\/10 12:40:25 [emerg] 58508#58508: open() \"\/var\/run\/nginx.pid\" failed (13: Permission denied)\r\nnginx: configuration file \/etc\/nginx\/nginx.conf test failed\r\n<\/code><\/pre>\n<p>\u65e0\u6cd5\u5199\u5165\u9519\u8bef\u65e5\u5fd7\u7684\u6743\u9650\u662f\u4ec0\u4e48\uff1f<\/p>\n<p>\u8bd5\u7740\u6539\u53d8\u4e8b\u7269\u3002<\/p>\n<p>\u5728nginx.conf\u7684\u914d\u7f6e\u4e2d\u51fa\u73b0\u4e86\u9519\u8bef\u3002<\/p>\n<p>\u542c\u8bf4\u5728\u6839\u76ee\u5f55\u4e0b\u542f\u52a8nginx\u662f\u5e38\u89c1\u7684\u505a\u6cd5\u3002<\/p>\n<pre class=\"post-pre\"><code>sudo su -\r\nsystemctl start nginx\r\n<\/code><\/pre>\n<p>\u6682\u65f6\u4e4b\u540e<\/p>\n<pre class=\"post-pre\"><code>    server {\r\n        location \/ {\r\n            root \/home\/muzudho\/public-html;\r\n        }\r\n    }\r\n<\/code><\/pre>\n<p>\u662f\u7981\u6b62\u7684\u3002<\/p>\n<pre class=\"post-pre\"><code>    server {\r\n        location \/ {\r\n            root \/usr\/share\/nginx\/html;\r\n        }\r\n    }\r\n<\/code><\/pre>\n<p>\u53ef\u4ee5\u7684\u3002<\/p>\n<p>\u987a\u4fbf\u8bf4\u4e00\u4e0b\uff0cHTML\u9875\u9762\u51fa\u73b0\u4e86\u4e71\u7801\u3002<\/p>\n<pre class=\"post-pre\"><code>    server {\r\n        charset utf-8;\r\n        location \/ {\r\n            root \/usr\/share\/nginx\/html;\r\n        }\r\n    }\r\n<\/code><\/pre>\n<p>\u6dfb\u52a0\u5b57\u7b26\u96c6utf-8\uff0c\u6548\u679c\u5982\u4f55\uff1f<\/p>\n<p>\u4f7f\u7528 Google Chrome \u6d4f\u89c8\u5668\uff0c\u6309\u4e0b [Ctrl]+[F5] \u952e\u8fdb\u884c\u8d85\u7ea7\u5237\u65b0\u3002<br \/>\n\u6b63\u5e38\u60c5\u51b5\u4e0b\uff0cNginx \u53ef\u4ee5\u663e\u793a\u9759\u6001\u9875\u9762\uff0c\u8fd9\u662f Nginx \u7684\u529f\u80fd\u3002\u4e0d\u5c06\u8bbf\u95ee\u4f20\u9012\u7ed9\u540e\u7aef\u7684 Node \u662f\u5f02\u5e38\u7684\u3002<\/p>\n<pre class=\"post-pre\"><code>502 Bad Gateway\r\nnginx\/1.15.9\r\n<\/code><\/pre>\n<p>\u6211\u5fd8\u8bb0\u5199\u4e0a\u6e38\u3002<\/p>\n<pre class=\"post-pre\"><code>        if ( !-f $request_filename ) {\r\n            proxy_pass http:\/\/backend_node;\r\n            break;\r\n        }\r\n<\/code><\/pre>\n<p>\u6211\u53d1\u73b0\u5728\u8865\u5145\u4e0a\u8ff04\u884c\u540e\u4f1a\u5bfc\u81f4500\u7cfb\u5217\u9519\u8bef\u3002<\/p>\n<pre class=\"post-pre\"><code>upstream backend_node {\r\n    ip_hash;\r\n    # Nodejs express port.\r\n    server 127.0.0.1:3000;\r\n}\r\n<\/code><\/pre>\n<p>\u7136\u540e\uff0c\u8fd9\u5e94\u8be5\u662f\u4e0d\u8d77\u4f5c\u7528\u7684\u3002<\/p>\n<pre class=\"post-pre\"><code># curl http:\/\/127.0.0.1:3000\r\n&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;title&gt;Express&lt;\/title&gt;&lt;link rel=\"stylesheet\" href=\"\/stylesheets\/style.css\"&gt;&lt;\/head&gt;&lt;body&gt;&lt;h1&gt;Express&lt;\/h1&gt;&lt;p&gt;Welcome to Express&lt;\/p&gt;&lt;\/body&gt;&lt;\/html&gt;\r\n<\/code><\/pre>\n<p>\u5b83\u4eec\u5206\u522b\u79fb\u52a8\u3002<\/p>\n<pre class=\"post-pre\"><code># curl http:\/\/127.0.0.1:3000\/users\r\nrespond with a resource\r\n\r\n# curl http:\/\/127.0.0.1:80\/users\r\n&lt;html&gt;\r\n&lt;head&gt;&lt;title&gt;404 Not Found&lt;\/title&gt;&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;center&gt;&lt;h1&gt;404 Not Found&lt;\/h1&gt;&lt;\/center&gt;\r\n&lt;hr&gt;&lt;center&gt;nginx&lt;\/center&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/code><\/pre>\n<p>\u6ca1\u6709\u4f20\u5230\u540e\u7aef\u3002<\/p>\n<p>\u6682\u65f6\u5c1d\u8bd5\u4ee5\u8d85\u7ea7\u7528\u6237\u8eab\u4efd\u91cd\u65b0\u542f\u52a8\u8282\u70b9\u3002<\/p>\n<pre class=\"post-pre\"><code>pm2 list\r\n<\/code><\/pre>\n<p>\u6ca1\u6709\u4efb\u4f55\u4e1c\u897f\u88ab\u542f\u52a8\u3002<\/p>\n<pre class=\"post-pre\"><code>exit\r\npm2 list\r\n<\/code><\/pre>\n<p>\u6211\u542f\u52a8\u4e86\u8bb8\u591a\u4e1c\u897f\u3002<\/p>\n<pre class=\"post-pre\"><code>pm2 stop www\r\npm2 delete start-server\r\npm2 delete www\r\n<\/code><\/pre>\n<p>\u628a\u4e00\u4e2a\u8282\u70b9\u653e\u5728\/home\u76ee\u5f55\u4e0b\u662f\u5426\u6ca1\u6709\u610f\u4e49\u3002<\/p>\n<pre class=\"post-pre\"><code>mv \/home\/muzudho\/html \/usr\/share\/html\r\n<\/code><\/pre>\n<p>\u5728 \/usr\/share\/ \u7684\u76ee\u5f55\u4e0b\u653e\u7f6e Web \u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u5417\uff1f<\/p>\n<pre class=\"post-pre\"><code>mkdir \/usr\/local\/webapps\r\nmv \/usr\/share\/html \/usr\/local\/webapps\/xxx\r\n<\/code><\/pre>\n<p>\u7531\u4e8e\u4e0d\u559c\u6b22\uff0c\u6211\u51b3\u5b9a\u79fb\u52a8\u3002<\/p>\n<pre class=\"post-pre\"><code>cd \/usr\/local\/webapps\/xxx\r\nsudo su -\r\npm2 start www\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code># curl http:\/\/localhost:80\/users\r\n&lt;html&gt;\r\n&lt;head&gt;&lt;title&gt;404 Not Found&lt;\/title&gt;&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;center&gt;&lt;h1&gt;404 Not Found&lt;\/h1&gt;&lt;\/center&gt;\r\n&lt;hr&gt;&lt;center&gt;nginx&lt;\/center&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n\r\n# curl http:\/\/localhost:3000\/users\r\nrespond with a resource\r\n<\/code><\/pre>\n<p>\u73b0\u5728\u4e3a\u4ec0\u4e48\u4f1a\u8fd9\u6837\u5462\u3002<\/p>\n<pre class=\"post-pre\"><code>vi \/var\/log\/nginx\/error.log\r\n<\/code><\/pre>\n<p>\u6ca1\u6709\u60c5\u62a5\u3002<\/p>\n<pre class=\"post-pre\"><code>cd \/var\/log\/nginx\r\nvi access.log\r\n<\/code><\/pre>\n<p>\u65e0\u8bbf\u95ee\u8bb0\u5f55\u3002<\/p>\n<p>\u7531\u4e8eNginx\u4e0d\u8d77\u5230\u53cd\u5411\u4ee3\u7406\u7684\u4f5c\u7528\uff0c\u6240\u4ee5\u6ca1\u6709\u5de5\u4f5c\u3002<\/p>\n<pre class=\"post-pre\"><code>    location \/ {\r\n        proxy_pass http:\/\/localhost:3000;\r\n<\/code><\/pre>\n<p>\u4f60\u8ba4\u4e3a\u4e22\u7ed9\u522b\u4eba\u600e\u4e48\u6837\uff1f<\/p>\n<pre class=\"post-pre\"><code>curl http:\/\/localhost:3000\/users\r\ncurl http:\/\/localhost:80\/users\r\n<\/code><\/pre>\n<p>500\u9519\u8bef\u3002<\/p>\n<p>\u4ee3\u7406\u670d\u52a1\u5668\u672a\u8d77\u4f5c\u7528\u3002\u641c\u7d22\u4e00\u4e0b\u3002<\/p>\n<pre class=\"post-pre\"><code>proxy_pass does not work between nginx and node.\r\n<\/code><\/pre>\n<p>NodeJS\u548cNginx\u4ee3\u7406\u65e0\u6cd5\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n<p>\u5982\u4f55\u5728Ubuntu 14.04\u4e0a\u4f7f\u7528Let&#8217;s Encrypt\u4fdd\u62a4Nginx<\/p>\n<pre class=\"post-pre\"><code># nano \/etc\/nginx\/sites-available\/default\r\n<\/code><\/pre>\n<p>\u6ca1\u6709\u8fd9\u6837\u7684\u76ee\u5f55\u3002<\/p>\n<p>\u6539\u53d8\u6587\u7ae0\u3002<\/p>\n<p>\u5c06NGINX\u914d\u7f6e\u4e3a\u7528\u4e8eNode.js\u5e94\u7528\u7a0b\u5e8f\u7684\u53cd\u5411\u4ee3\u7406\u3002<\/p>\n<p>\u641c\u7d22\u4e00\u4e0b\u3002<\/p>\n<pre class=\"post-pre\"><code>proxy_pass does not work between nginx and node on centos.\r\n<\/code><\/pre>\n<p>\u5982\u4f55\u5728 CentOS 7 \u4e0a\u4e3a\u751f\u4ea7\u73af\u5883\u8bbe\u7f6e Node.js \u5e94\u7528\u7a0b\u5e8f<\/p>\n<pre class=\"post-pre\"><code>sudo systemctl restart nginx\r\nsudo systemctl enable nginx\r\n<\/code><\/pre>\n<p>\u63d0\u4f9b\u4e86\u4e00\u79cd\u4e0d\u4ee5root\u7528\u6237\u8eab\u4efd\u542f\u52a8nginx\u7684\u65b9\u6cd5\u3002<\/p>\n<pre class=\"post-pre\"><code>sudo yum install epel-release\r\n<\/code><\/pre>\n<p>\u8fd9\u5df2\u7ecf\u5b89\u88c5\u597d\u4e86\u3002<\/p>\n<p>\u6539\u53d8\u65b0\u95fb\u7a3f\u3002<\/p>\n<p>\u4f7f\u7528CentOS 7\u8fdb\u884c\u521d\u59cb\u670d\u52a1\u5668\u8bbe\u7f6e<\/p>\n<p>\u4ee5SSH\u534f\u8bae\u4f7f\u7528root\u7528\u6237\u767b\u5f55\u3002<\/p>\n<p>\u589e\u52a0\u8d26\u6237\u7684\u6570\u91cf\u3002<\/p>\n<pre class=\"post-pre\"><code>adduser demo\r\n<\/code><\/pre>\n<p>\u5728\u90a3\u4e4b\u524d\uff0c\u67e5\u770b\u7528\u6237\u5217\u8868\u3002<\/p>\n<pre class=\"post-pre\"><code>cat \/etc\/passwd\r\n<\/code><\/pre>\n<p>\u7136\u540e\uff0c\u5df2\u7ecf\u521b\u5efa\u4e86\u4e00\u4e2a\u9488\u5bf9nginx\u7684\u5e10\u6237\u3002<\/p>\n<pre class=\"post-pre\"><code>gpasswd -a demo wheel\r\n<\/code><\/pre>\n<p>\u67e5\u770b\u7528\u6237\u7ec4\u7684\u5217\u8868\u3002<\/p>\n<pre class=\"post-pre\"><code>cat \/etc\/group\r\n<\/code><\/pre>\n<p>\u6682\u65f6\u5c06\u5176\u6dfb\u52a0\u5230\u8f6e\u7ec4\u5185\u3002<\/p>\n<pre class=\"post-pre\"><code>ssh-keygen\r\n<\/code><\/pre>\n<p>\u968f\u610f\u8f93\u5165\u6587\u4ef6\u540d\u548c\u5bc6\u7801\u3002<\/p>\n<p>\u7136\u540e\uff0c\u5728\u672c\u5730\u7528\u6237\u7684\u4e3b\u76ee\u5f55\u4e0b\u751f\u6210\u4e86\u4e00\u4e2a\u540d\u4e3a&lt;\u6587\u4ef6\u540d&gt;\u548c&lt;\u6587\u4ef6\u540d&gt;.pub\u7684\u6587\u4ef6\u3002\u8fd9\u5e94\u8be5\u662f\u79c1\u94a5\u548c\u516c\u94a5\u3002<\/p>\n<pre class=\"post-pre\"><code>ssh-copy-id demo@SERVER_IP_ADDRESS\r\n\r\n\/bin\/ssh-copy-id: ERROR: failed to open ID file '\/root\/.pub': \u305d\u306e\u3088\u3046\u306a\u30d5\u30a1\u30a4\u30eb\u3084\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306f\u3042\u308a\u307e\u305b\u3093\r\n        (to install the contents of '\/root\/.pub' anyway, look at the -f option)\r\n<\/code><\/pre>\n<p>\u90a3\u4e48\u5b89\u5168\u6027\u5c31\u901a\u8fc7\u5bc6\u7801\u6765\u4fdd\u969c\u5427\u3002<\/p>\n<p>\u7531\u4e8e\u672c\u5730\u4e3b\u673a\u7684\u7aef\u53e33000\u548c80\u6ca1\u6709\u8fde\u63a5\u8d77\u6765\uff0c\u800c\u4e14\u5b83\u662f\u4e00\u4e2a\u79c1\u6709IP\u5730\u5740\uff0c\u56e0\u6b64\u65e0\u6cd5\u4ece\u5916\u90e8\u8bbf\u95ee\u3002DNS\u4e5f\u65e0\u6cd5\u8fde\u63a5\uff0c\u4e24\u4e2a\u90fd\u6ca1\u6709\u8fde\u63a5\u6210\u529f\u3002<\/p>\n<pre class=\"post-pre\"><code>ipconfig\r\nWindows IP \u69cb\u6210\r\n\r\n\r\n\u30a4\u30fc\u30b5\u30cd\u30c3\u30c8 \u30a2\u30c0\u30d7\u30bf\u30fc \u30a4\u30fc\u30b5\u30cd\u30c3\u30c8:\r\n\r\n   \u63a5\u7d9a\u56fa\u6709\u306e DNS \u30b5\u30d5\u30a3\u30c3\u30af\u30b9 . . . . .: xxxxxxxxxxxxxxxx\r\n   IPv6 \u30a2\u30c9\u30ec\u30b9 . . . . . . . . . . . .: xxxxxxxxxxxxxxxxxxxx\r\n   \u4e00\u6642 IPv6 \u30a2\u30c9\u30ec\u30b9. . . . . . . . . .: xxxxxxxxxxxxxxxxxxxx\r\n   \u30ea\u30f3\u30af\u30ed\u30fc\u30ab\u30eb IPv6 \u30a2\u30c9\u30ec\u30b9. . . . .: xxxxxxxxxxxxxxxxxxxxxxx\r\n   IPv4 \u30a2\u30c9\u30ec\u30b9 . . . . . . . . . . . .: xxxxxxxxxxxxxxxxxxx\r\n   \u30b5\u30d6\u30cd\u30c3\u30c8 \u30de\u30b9\u30af . . . . . . . . . .: xxxxxxxxxxxxxxxxxxxx\r\n   \u30c7\u30d5\u30a9\u30eb\u30c8 \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4 . . . . . . .: xxxxxxxxxxxxxxxxxxx\r\n                                          xxxxxxxxxxxxxxxxxx\r\n<\/code><\/pre>\n<p>\u8fd9\u4e2a\u9ed8\u8ba4\u7f51\u5173\u8fde\u63a5\u5230Windows 10\uff0c\u5e76\u4e14\u5b83\u6307\u5411CentOS\u3002\u6211\u539f\u672c\u4ee5\u4e3a\u8fd9\u5c06\u6574\u5408CentOS\u5185\u90e8nginx\u63a5\u6536\u7684\u8def\u7531\u548c\u8bbf\u95eeCentOS\u79c1\u6709IP\u5730\u5740\u7684\u53e6\u4e00\u6761\u8def\u7531\uff0c\u4f46\u662f\u7531\u4e8e\u9ebb\u70e6\uff0c\u6211\u51b3\u5b9a\u5c06\u4ece\u5916\u90e8\u8fdb\u5165\u7684\u90e8\u5206\u653e\u5728\u540e\u9762\u3002<\/p>\n<p>\u5f53\u60a8\u8bbf\u95ee\u79c1\u6709IP\u5730\u5740\uff0c\u8def\u7531\u5668\u7684\u767b\u5f55\u9875\u9762\u4f1a\u663e\u793a\u51fa\u6765\u3002<br \/>\n\u5f53\u60a8\u8bbf\u95eeCentOS\u7684\u79c1\u6709IP\u5730\u5740\uff0c\u4f1a\u51fa\u73b0500\u9519\u8bef\u3002<br \/>\n\u5f53\u60a8\u8bbf\u95ee\u8d2d\u4e70\u7684\u57df\u540d\uff0c\u4f1a\u8d85\u65f6\u3002<\/p>\n<p>\u56e0\u4e3a\u73b0\u5728\u6ca1\u4ec0\u4e48\u4e8b\u60c5\u53ef\u505a\uff0c\u6211\u5c31\u8bd5\u8bd5\u7528Team Viewer\u767b\u5f55Windows 10\u5427\uff0c\u8fde\u63a5\u5230\u6211\u7684\u5408\u4f5c\u4f19\u4f34\u3002<\/p>\n<p>\u7531\u4e8e\u8def\u7531\u5668\u5df2\u7ecf\u5360\u7528\u4e86IP\u5730\u57401\uff0c\u800c\u4e14\u8def\u7531\u5668\u4f1a\u81ea\u52a8\u5206\u914d\u79c1\u6709IP\u5730\u5740\uff0c\u6240\u4ee5\u6211\u6ca1\u6709\u4ec0\u4e48\u53ef\u505a\u7684\u3002<\/p>\n<p>\u53ea\u662f\u5728Hyper-V\u7ba1\u7406\u5668\u4e2d\u8fd0\u884cCentOS\uff0c\u5e76\u4e0d\u9700\u8981Windows10\u3002\u5c31\u50cf\u6253\u5f00\u6216\u5173\u95ed\u4e00\u4e2a\u7a7a\u51b0\u7bb1\u4e00\u6837\uff0c\u8fdb\u6765\u4e5f\u4ec0\u4e48\u90fd\u6ca1\u6709\u3002<\/p>\n<p>\u554f\u984c\u53ea\u5b58\u5728\u4e8eCentOS\u5185\u90e8\u3002<\/p>\n<p>\u6539\u53d8\u6587\u7ae0\u3002<\/p>\n<p>\u5c06Nginx\u4f5c\u4e3aNode.js\u7684\u53cd\u5411\u4ee3\u7406\u4f7f\u7528\u3002<\/p>\n<p>\u4e3a\u4ec0\u4e48 Nginx \u4f1a\u51fa\u73b0500\u9519\u8bef\uff0c\u5374\u6ca1\u6709\u6253\u5370\u51fa\u9519\u8bef\u65e5\u5fd7\uff1f<\/p>\n<pre class=\"post-pre\"><code>2019\/03\/10 03:23:43 [crit] 55248#55248: *3 connect() to 127.0.0.1:3000 failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: *********, request: \"GET \/ HTTP\/1.1\", upstream: \"http:\/\/127.0.0.1:3000\/\", host: \"localhost\"\r\n<\/code><\/pre>\n<p>\u5e76\u4e0d\u662f\u8bf4\u8c03\u6574\u4e86\u534f\u8c03\u4e16\u754c\u65f6\uff0c\u800c\u662f\u5728\u5348\u591c\u7ffb\u770b\u9519\u8bef\u65e5\u5fd7\u65f6\u53d1\u73b0\u4e2d\u65ad\u4e86\u3002<\/p>\n<pre class=\"post-pre\"><code>127.0.0.1 - - [10\/Mar\/2019:03:24:05 +0900] \"GET \/ HTTP\/1.1\" 502 537 \"-\" \"curl\/7.29.0\" \"-\"\r\n127.0.0.1 - - [10\/Mar\/2019:03:24:11 +0900] \"GET \/index.html HTTP\/1.1\" 200 653 \"-\" \"curl\/7.29.0\" \"-\"\r\n127.0.0.1 - - [10\/Mar\/2019:03:25:38 +0900] \"GET \/ HTTP\/1.1\" 502 537 \"-\" \"curl\/7.29.0\" \"-\"\r\n127.0.0.1 - - [10\/Mar\/2019:03:27:29 +0900] \"GET \/users HTTP\/1.1\" 502 537 \"-\" \"curl\/7.29.0\" \"-\"\r\n127.0.0.1 - - [10\/Mar\/2019:03:37:05 +0900] \"GET \/ HTTP\/1.1\" 502 537 \"-\" \"curl\/7.29.0\" \"-\"\r\n<\/code><\/pre>\n<p>\u7531\u4e8e\u8bbf\u95ee\u65e5\u5fd7\u4e5f\u5f88\u65e7\uff0c\u6240\u4ee5\u505c\u6b62\u4e86\u3002\u65e5\u5fd7\u8f93\u51fa\u5230\u54ea\u91cc\u4e86\uff1f<\/p>\n<pre class=\"post-pre\"><code>nginx: [emerg] \"proxy_redirect\" directive is not allowed here in \/etc\/nginx\/conf.d\/default.conf:31\r\nnginx: configuration file \/etc\/nginx\/nginx.conf test failed\r\n<\/code><\/pre>\n<p>\u6211\u4e5f\u4e0d\u660e\u767d\u3002\u6bd4\u5982\u8bf4\u5728 location \u76ee\u5f55\u4e0b\u662f\u53ef\u4ee5\u5199\u7684\uff0c\u4f46\u5728 if \u4ee3\u7801\u5757\u4e2d\u5c31\u4e0d\u80fd\u5199\u3002<\/p>\n<pre class=\"post-pre\"><code>C:\\Users\\\u3080\u305a\u3067\u3087&gt;telnet\r\n'telnet' \u306f\u3001\u5185\u90e8\u30b3\u30de\u30f3\u30c9\u307e\u305f\u306f\u5916\u90e8\u30b3\u30de\u30f3\u30c9\u3001\r\n\u64cd\u4f5c\u53ef\u80fd\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u307e\u305f\u306f\u30d0\u30c3\u30c1 \u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u8a8d\u8b58\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\r\n<\/code><\/pre>\n<p>TELNET\u592a\u8fc7\u65f6\u4e86\uff0c\u6211\u4e0d\u61c2\u3002\u4f7f\u7528PuTTY\u8fdb\u884cSSH\u8fde\u63a5\u4e0d\u884c\u5417\uff1f<\/p>\n<p>\u4f7f\u7528Windows Telnet\u5ba2\u6237\u7aef\u7684\u65b9\u6cd5\uff081\/2\uff09<\/p>\n<pre class=\"post-pre\"><code>\u30db\u30b9\u30c8\u3092\u89e3\u6c7a\u3057\u3066\u3044\u307e\u3059\r\n\u63a5\u7d9a\u4e2d\r\n<\/code><\/pre>\n<p>\u4ece\u5916\u9762\u4e5f\u4f9d\u65e7\u770b\u4e0d\u89c1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 CentOS \u4e0a\u5b89\u88c5 nodejs\u3002 \u30e1\u30e2\u66f8\u304d \u30db\u30fc\u30e0\u30da\u30fc\u30b8\u304b\u3089\u53d6\u3063\u3066\u304f\u308b\u306e\u3067\u306f\u306a\u304f\u3001\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u304b\u3089\u30a4 [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-33214","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u8349\u7a3f - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u8349\u7a3f\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u8349\u7a3f\" \/>\n<meta property=\"og:description\" content=\"\u5728 CentOS \u4e0a\u5b89\u88c5 nodejs\u3002 \u30e1\u30e2\u66f8\u304d \u30db\u30fc\u30e0\u30da\u30fc\u30b8\u304b\u3089\u53d6\u3063\u3066\u304f\u308b\u306e\u3067\u306f\u306a\u304f\u3001\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u304b\u3089\u30a4 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u8349\u7a3f\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-08-11T14:42:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-28T15:30:53+00:00\" \/>\n<meta name=\"author\" content=\"\u5b87, \u534e\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u5b87, \u534e\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e8%8d%89%e7%a8%bf\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e8%8d%89%e7%a8%bf\/\",\"name\":\"\u8349\u7a3f - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-08-11T14:42:53+00:00\",\"dateModified\":\"2024-04-28T15:30:53+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e8%8d%89%e7%a8%bf\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e8%8d%89%e7%a8%bf\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e8%8d%89%e7%a8%bf\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u8349\u7a3f\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458\",\"name\":\"\u5b87, \u534e\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g\",\"caption\":\"\u5b87, \u534e\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/yuhua\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e8%8d%89%e7%a8%bf\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u8349\u7a3f - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u8349\u7a3f\/","og_locale":"zh_CN","og_type":"article","og_title":"\u8349\u7a3f","og_description":"\u5728 CentOS \u4e0a\u5b89\u88c5 nodejs\u3002 \u30e1\u30e2\u66f8\u304d \u30db\u30fc\u30e0\u30da\u30fc\u30b8\u304b\u3089\u53d6\u3063\u3066\u304f\u308b\u306e\u3067\u306f\u306a\u304f\u3001\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u304b\u3089\u30a4 [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u8349\u7a3f\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-08-11T14:42:53+00:00","article_modified_time":"2024-04-28T15:30:53+00:00","author":"\u5b87, \u534e","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u5b87, \u534e","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"10 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e8%8d%89%e7%a8%bf\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e8%8d%89%e7%a8%bf\/","name":"\u8349\u7a3f - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-08-11T14:42:53+00:00","dateModified":"2024-04-28T15:30:53+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e8%8d%89%e7%a8%bf\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e8%8d%89%e7%a8%bf\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e8%8d%89%e7%a8%bf\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u8349\u7a3f"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458","name":"\u5b87, \u534e","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g","caption":"\u5b87, \u534e"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/yuhua\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e8%8d%89%e7%a8%bf\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/33214","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=33214"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/33214\/revisions"}],"predecessor-version":[{"id":65157,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/33214\/revisions\/65157"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=33214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=33214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=33214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}