{"id":3451,"date":"2021-08-08T00:56:11","date_gmt":"2021-08-07T15:56:11","guid":{"rendered":"https:\/\/taitan916.info\/blog\/?p=3451"},"modified":"2024-02-22T22:34:03","modified_gmt":"2024-02-22T13:34:03","slug":"post-3451","status":"publish","type":"post","link":"https:\/\/taitan916.info\/blog\/archives\/3451","title":{"rendered":"Nginx\u306e\u30d0\u30fc\u30c1\u30e3\u30eb\u30db\u30b9\u30c8\u8a2d\u5b9a\u3068Let's Encrypt\u306e\u5c0e\u5165"},"content":{"rendered":"<p>Nginx\u3067VirtualHost\u306e\u8a2d\u5b9a\u3057\u3001\u8907\u6570\u306e\u30c9\u30e1\u30a4\u30f3\u3092\u540c\u4e00\u30b5\u30fc\u30d0\u306b\u5272\u308a\u5f53\u3066\u305f\u3044\u3002\u307e\u305f\u3001Virtual Host\u8a2d\u5b9a\u3057\u305f\u30c9\u30e1\u30a4\u30f3\u306b\u5bfe\u3057\u3066Let's Encrypt\u3092\u5c0e\u5165\u3057\u3001SSL\u5bfe\u5fdc\u3057\u305f\u3044\u3002\u3042\u3068\u30c9\u30e1\u30a4\u30f3\u6bce\u306baccess_log\u3084error_log\u3092\u500b\u5225\u306b\u51fa\u529b\u3055\u305b\u305f\u3044\u3002\u4ee5\u4e0b\u306b\u8a2d\u5b9a\u65b9\u6cd5\u3092\u30e1\u30e2\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u30d0\u30fc\u30c1\u30e3\u30eb\u30db\u30b9\u30c8\u8a2d\u5b9a<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"default\" data-enlighter-title=\"\">#\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u7de8\u96c6\r\nvi \/etc\/nginx\/conf.d\/default.conf\r\n\r\n#\u4ee5\u4e0b\u3092\u8ffd\u8a18\u3059\u308b(hoge.com\u90e8\u5206\u306f\u9069\u5b9c\u5909\u66f4\u3059\u308b)\r\nserver { \r\n    listen 80; \r\n\r\n    server_name hoge.com;\r\n\r\n    access_log \/var\/log\/nginx\/hoge.com.access.log main;\r\n    error_log \/var\/log\/nginx\/hoge.com.error.log;\r\n\r\n    location \/ { \r\n          root \/usr\/share\/nginx\/html\/hoge.com; \r\n          index index.php;\r\n    }\r\n\r\n    location ~ \\.php$ {\r\n        root           \/usr\/share\/nginx\/html\/hoge.com;\r\n        fastcgi_pass   127.0.0.1:9000;\r\n        fastcgi_index  index.php;\r\n        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;\r\n        include        fastcgi_params;\r\n    }\r\n}<\/pre>\n<p>\u30d0\u30fc\u30c1\u30e3\u30eb\u30db\u30b9\u30c8\u6bce\u306bserver{}\u3067\u56f2\u3063\u3066\u8a2d\u5b9a\u3057\u3066\u3044\u304f\u307f\u305f\u3044\u3002<\/p>\n<p>\u5c1a\u3001\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u7de8\u96c6\u5f8c\u306f\u3059\u3050\u306bNginx\u3092\u518d\u8d77\u52d5\u305b\u305a\u306b\u4ee5\u4e0b\u3067\u69cb\u6587\u30c1\u30a7\u30c3\u30af\u304c\u884c\u3048\u308b\u3068\u306e\u3053\u3068\u3002\u4eca\u5f8c\u306f\u5fc5\u305a\u69cb\u6587\u30c1\u30a7\u30c3\u30af\u5f8c\u306b\u518d\u8d77\u52d5\u3092\u304b\u3051\u308b\u3088\u3046\u306b\u3059\u308b\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"default\" data-enlighter-title=\"\">#\u69cb\u6587\u30c1\u30a7\u30c3\u30af\r\nnginx -t\r\n\r\n#\u4ee5\u4e0b\u304c\u8868\u793a\u3055\u308c\u308b\u3068OK\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\r\n#nginx\u518d\u8d77\u52d5\r\nsystemctl restart nginx<\/pre>\n<p>&nbsp;<\/p>\n<h2>Let's Encrypt\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"default\" data-enlighter-title=\"\">#\u8a3c\u660e\u66f8\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306e\u30c6\u30b9\u30c8(hoge.com\u90e8\u5206\u306f\u9069\u5b9c\u5909\u66f4\u3059\u308b)\r\ncertbot certonly --webroot -w \/usr\/share\/nginx\/html\/hoge.com -d hoge.com --email test@hoge.com --dry-run\r\n\r\n#\u554f\u984c\u7121\u3051\u308c\u3070\u8a3c\u660e\u66f8\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\r\ncertbot certonly --webroot -w \/usr\/share\/nginx\/html\/hoge.com -d hoge.com --email test@hoge.com<\/pre>\n<p>&nbsp;<\/p>\n<h2>Nginx\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u518d\u7de8\u96c6<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"default\" data-enlighter-title=\"\">#\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u7de8\u96c6\r\nvi \/etc\/nginx\/conf.d\/default.conf\r\n\r\n#\u5148\u307b\u3069\u30d0\u30fc\u30c1\u30e3\u30eb\u30db\u30b9\u30c8\u3057\u305fserver{}\u5185\u306elisten80\u306e\u4e0b\u3042\u305f\u308a\u306b\u4ee5\u4e0b\u3092\u8ffd\u8a18\r\n    listen 443 ssl;\r\n    ssl_certificate     \/etc\/letsencrypt\/live\/hoge.com\/fullchain.pem;\r\n    ssl_certificate_key \/etc\/letsencrypt\/live\/hoge.com\/privkey.pem;<\/pre>\n<p>\u4e0a\u8a18\u8a2d\u5b9a\u5f8c\u3001\u5ff5\u306e\u305f\u3081\u69cb\u6587\u30c1\u30a7\u30c3\u30af\u3092\u884c\u3063\u3066\u304b\u3089Nginx\u3092\u518d\u8d77\u52d5\u3059\u308b\u3002\u3053\u306e\u6642\u70b9\u3067https\u3067\u306e\u30a2\u30af\u30bb\u30b9\u304c\u53ef\u80fd\u3068\u306a\u308b\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u6240\u611f<\/h2>\n<p>Apache\u3088\u308a\u3082Nginx\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u65b9\u304c\u76f4\u611f\u7684\u3067\u5206\u304b\u308a\u3084\u3059\u3044\u3088\u3046\u306a\u6c17\u304c\u3059\u308b\u3002\u5f8c\u306f\u4eca\u56de\u3068\u306f\u5225\u4ef6\u3060\u3051\u3069Nginx\u306fhtaccess\u304c\u4f7f\u3048\u306a\u3044\u3089\u3057\u3044\u306e\u3067\u3001Basic\u8a8d\u8a3c\u3084\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3092\u3069\u3046\u3059\u308b\u306e\u304b\u52c9\u5f37\u3057\u3066\u304a\u304d\u305f\u3044\u3068\u3053\u308d\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u53c2\u8003\u30b5\u30a4\u30c8<\/h2>\n<p><a href=\"https:\/\/www.unix-power.net\/networking\/post-1116\" target=\"_blank\" rel=\"noopener\">https:\/\/www.unix-power.net\/networking\/post-1116<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nginx\u3067VirtualHost\u306e\u8a2d\u5b9a\u3057\u3001\u8907\u6570\u306e\u30c9\u30e1\u30a4\u30f3\u3092\u540c\u4e00\u30b5\u30fc\u30d0\u306b\u5272\u308a\u5f53\u3066 ... <\/p>\n","protected":false},"author":1,"featured_media":3445,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[77,7],"tags":[99],"class_list":["post-3451","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nginx","category-server","tag-lets-encrypt"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/3451","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/comments?post=3451"}],"version-history":[{"count":1,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/3451\/revisions"}],"predecessor-version":[{"id":4950,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/3451\/revisions\/4950"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/media\/3445"}],"wp:attachment":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/media?parent=3451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/categories?post=3451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/tags?post=3451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}