{"id":10136,"date":"2023-08-14T23:00:18","date_gmt":"2023-08-14T14:00:18","guid":{"rendered":"https:\/\/www.itblog.jp\/?p=10136"},"modified":"2023-08-14T23:04:10","modified_gmt":"2023-08-14T14:04:10","slug":"centosnginxnextjs%e3%81%ae%e3%82%b5%e3%82%a4%e3%83%88%e3%82%92%e5%85%ac%e9%96%8b%e3%81%99%e3%82%8b%e3%81%be%e3%81%a7","status":"publish","type":"post","link":"https:\/\/www.itblog.jp\/?p=10136","title":{"rendered":"CentOS+Nginx+NextJS\u306e\u30b5\u30a4\u30c8\u3092\u516c\u958b\u3059\u308b\u307e\u3067"},"content":{"rendered":"\n<p>CentOS+Nginx+NextJS\u3067\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u3092\u30db\u30b9\u30c6\u30a3\u30f3\u30b0\u3057\u3066\u516c\u958b\u3059\u308b\u307e\u3067\u306e\u624b\u9806\u306b\u3064\u3044\u3066\u307e\u3068\u3081\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\uff11\u30fbNextJS\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210<\/h2>\n\n\n\n<p>npm create-next-app@latest &#8211;ts<\/p>\n\n\n\n<p>\u8cea\u554f\u306f\u5168\u3066yes\u3092\u9078\u629e\u3002<\/p>\n\n\n\n<p>\u3053\u308c\u3067\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u30d5\u30a9\u30eb\u30c0\u304c\u4f5c\u6210<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\uff12\u30fb\u30b5\u30fc\u30d0\u3092\u7acb\u3061\u4e0a\u3052<\/h2>\n\n\n\n<p>npm run dev<\/p>\n\n\n\n<p>\u2191 \u3053\u308c\u3067\u30a8\u30e9\u30fc\u304c\u51fa\u305f<\/p>\n\n\n\n<p>SyntaxError: Unexpected token &#8216;??=&#8217; after creating nextjs app and running it<\/p>\n\n\n\n<p>\u3088\u304f\u5206\u304b\u3089\u306a\u3044\u304c\u3001Node\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3068\u304b\u304c\u95a2\u4fc2\u3057\u3066\u308b\u3063\u307d\u3044\u3002<\/p>\n\n\n\n<p>\u6700\u65b0\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306b\u3042\u3052\u3066\u307f\u308b\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d1\u30c3\u30b1\u30fc\u30b8\u300cn\u300d\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n\n\n\n<p>npm install -g n<\/p>\n\n\n\n<p>\u3053\u308c\u3067\u3001\u30d0\u30fc\u30b8\u30e7\u30f3\u6307\u5b9a\u3067node\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u308b\u3002<\/p>\n\n\n\n<p>\u6700\u65b0\u306e\u30d0\u30fc\u30b8\u30e7\u30f3(18\uff5e20\uff09\u3060\u3068\u3001CentOS\u5074\u304c\u5bfe\u5fdc\u3057\u3066\u306a\u3044\u3063\u307d\u3044\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u306e\u3067\u3001\u6700\u7d42\u7684\u306b16.13.0\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u3002(\u7d30\u304b\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u6307\u5b9a\u306b\u306a\u3063\u3066\u308b\u306e\u3067\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u4f5c\u6210\u6642\u306b16.\uff10.\uff10\u3060\u3068\u30ef\u30fc\u30cb\u30f3\u30b0\u304c\u51fa\u305f\u306e\u3067\uff09<\/p>\n\n\n\n<p>n 16.13.0<\/p>\n\n\n\n<p>n<\/p>\n\n\n\n<p>\u3053\u308c\u3067\u8868\u793a\u3055\u308c\u305f\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u4e2d\u304b\u3089\u6307\u5b9a\u3057\u305f\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u9078\u629e<\/p>\n\n\n\n<p>\u3053\u308c\u3067\u3001npm run dev \u3067\u30a8\u30e9\u30fc\u304c\u51fa\u305a\u306b\u30b5\u30fc\u30d0\u304c\u8d77\u52d5\u3067\u304d\u305f\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u554f\u984c\uff1a\u3069\u3046\u3084\u3063\u3066\u30c9\u30e1\u30a4\u30f3\u540d\u3067\u30a2\u30af\u30bb\u30b9\u3057\u3066\u8868\u793a\u3059\u308b\u306e\u304b\u3002<\/h2>\n\n\n\n<p>localhost:3000\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u30b5\u30a4\u30c8\u304c\u8868\u793a\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3060\u304c\u3001\u3053\u308c\u3092\u3069\u3046\u3084\u3063\u3066\u30c9\u30e1\u30a4\u30f3\u540d\u3067\u6307\u5b9a\u3057\u3066\u30a2\u30af\u30bb\u30b9\u3059\u308b\u30b5\u30a4\u30c8\u3067\u898b\u308c\u308b\u72b6\u6cc1\u306b\u3067\u304d\u308b\u306e\u304b\u3002<\/p>\n\n\n\n<p>\/etc\/nginx\/conf.d \u4ee5\u4e0b\u306b\u3042\u308b conf\u30d5\u30a1\u30a4\u30eb\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a2d\u5b9a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>location \/ {\n    proxy_set_header Host $http_host;\n    proxy_set_header X-Real-IP $remote_addr;\n    proxy_pass http:\/\/hogehoge.com:3000\/;\n    proxy_http_version 1.1;\n    proxy_set_header Upgrade $http_upgrade;\n    proxy_set_header Connection \"upgrade\";\n    proxy_next_upstream error timeout http_502 http_503 http_504;\n}<\/code><\/pre>\n\n\n\n<p>\u610f\u5473\u306f\u5168\u304f\u5206\u304b\u3089\u306a\u3044\u304c\u3001\u305d\u306e\u3088\u3046\u306b\u3059\u308c\u3070\u3088\u3044\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u305d\u306e\u901a\u308a\u306b\u8a2d\u5b9a\u3002<\/p>\n\n\n\n<p>nginx\u3092\u518d\u8d77\u52d5\u3002<\/p>\n\n\n\n<p>\u3059\u308b\u3068\u3001\u30b5\u30a4\u30c8\u304c\u8868\u793a\u3055\u308c\u305f\u304c\u30ec\u30a4\u30a2\u30a6\u30c8\u304c\u5d29\u308c\u3066\u3044\u308b\u3002(CSS\u3068\u304b\u304c\u8aad\u307f\u8fbc\u307e\u308c\u3066\u3044\u306a\u3044\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>location ^~ \/_next\/ {\n    proxy_set_header Host $http_host;\n    proxy_set_header X-Real-IP $remote_addr;\n    proxy_pass http:\/\/hogehoge.com:3000\/_next\/;\n    proxy_http_version 1.1;\n    proxy_set_header Upgrade $http_upgrade;\n    proxy_set_header Connection \"upgrade\";\n    proxy_next_upstream error timeout http_502 http_503 http_504;\n}<\/code><\/pre>\n\n\n\n<p>\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306b\u4e0a\u8a18\u3092\u8ffd\u52a0\u5f8c\u3001nginx\u3092\u518d\u8d77\u52d5\u3002<\/p>\n\n\n\n<p>\u3059\u308b\u3068\u3001\u521d\u671f\u8868\u793a\u306e\u30da\u30fc\u30b8\u304c\u304d\u3061\u3093\u3068\u8868\u793a\u3055\u308c\u305f\u3002<\/p>\n\n\n\n<p>\u3042\u3068\u3001\u521d\u671f\u72b6\u614b\u306e<\/p>\n\n\n\n<p>npm run dev<\/p>\n\n\n\n<p>\u306e\u30b3\u30de\u30f3\u30c9\u306e\u753b\u9762\u3092\u9589\u3058\u308b\u3068\u30b5\u30a4\u30c8\u304c\u8868\u793a\u3055\u308c\u306a\u304f\u306a\u308b\u3053\u3068\u306b\u56f0\u3063\u305f\u3002\u3053\u308c\u306f\u3001<\/p>\n\n\n\n<p>npm run dev<\/p>\n\n\n\n<p>\u3067\u306f\u306a\u304f\u3001<\/p>\n\n\n\n<p>npm run build<\/p>\n\n\n\n<p>\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u3067\u89e3\u6c7a\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u6c38\u7d9a\u5316\u8a2d\u5b9a\u3068\u3044\u3046\u306e\u3082\u8abf\u3079\u305f\u3089\u51fa\u3066\u304d\u305f\u306e\u3067\u3001<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">npm install -g pm2\nnpm list -g\npm2 start npm --name \"\u4efb\u610f\u306e\u540d\u524d\" -- start<\/pre>\n\n\n\n<p>\u3068\u3044\u3046\u306e\u3082\u3084\u3063\u3066\u307f\u305f\u3051\u3069\u3001\u610f\u5473\u304c\u3042\u3063\u305f\u306e\u304b\u3069\u3046\u304b\u3088\u304f\u308f\u304b\u3089\u306a\u3044\u30fb\u30fb\u30fb\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CentOS+Nginx+NextJS\u3067\u30a6\u30a7\u30d6\u30b5\u30a4\u30c8\u3092\u30db\u30b9\u30c6\u30a3\u30f3\u30b0\u3057\u3066\u516c\u958b\u3059\u308b\u307e\u3067\u306e\u624b\u9806\u306b\u3064\u3044\u3066\u307e\u3068\u3081\u307e\u3057\u305f\u3002 \uff11\u30fbNextJS\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210 npm create-next-app@latest &#8211;t [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[198,179,131],"tags":[],"class_list":["post-10136","post","type-post","status-publish","format-standard","hentry","category-nextjs","category-react","category-131"],"_links":{"self":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts\/10136","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10136"}],"version-history":[{"count":0,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts\/10136\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10136"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10136"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10136"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}