{"id":429,"date":"2025-03-19T00:05:54","date_gmt":"2025-03-18T15:05:54","guid":{"rendered":"https:\/\/shugomatsuzawa.com\/techblog\/?p=429"},"modified":"2025-03-19T02:40:21","modified_gmt":"2025-03-18T17:40:21","slug":"%e3%82%b5%e3%83%96%e3%83%87%e3%82%a3%e3%83%ac%e3%82%af%e3%83%88%e3%83%aa%e3%81%a7%e5%85%ac%e9%96%8b%e3%81%95%e3%82%8c%e3%82%8blaravel%e3%82%a2%e3%83%97%e3%83%aa%e3%82%b1%e3%83%bc%e3%82%b7%e3%83%a7","status":"publish","type":"post","link":"https:\/\/shugomatsuzawa.com\/techblog\/2025\/03\/19\/429\/","title":{"rendered":"\u30b5\u30d6\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u516c\u958b\u3055\u308c\u308bLaravel\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u3001Docker\u958b\u767a\u74b0\u5883\u3067\u518d\u73fe\u3059\u308b"},"content":{"rendered":"\n<p>\u4f8b\u3048\u3070 <code>www.example.com\/sub<\/code> \u306e\u3088\u3046\u306a\u30b5\u30d6\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067Laravel\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u30db\u30b9\u30c8\u3059\u308b\u5834\u5408\u3001\u4f5c\u308a\u306b\u3088\u3063\u3066\u306f\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u3067\u306f\u7e4b\u304c\u3063\u3066\u3044\u305f\u30ea\u30f3\u30af\u304c\u5207\u308c\u305f\u308a\u3001\u4e0d\u5177\u5408\u304c\u767a\u751f\u3059\u308b\u3053\u3068\u3082\u3042\u308b\u3002<br>\u3053\u3093\u306a\u6642\u30ed\u30fc\u30ab\u30eb\u958b\u767a\u74b0\u5883\u3082\u30b5\u30d6\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u69cb\u7bc9\u3057\u3066\u304a\u3051\u3070\u3001\u5bfe\u51e6\u304c\u3057\u3084\u3059\u304f\u306a\u308b\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u8a2d\u5b9a\u65b9\u6cd5<\/h2>\n\n\n\n<p>\u4eca\u56de<code>Dockerfile<\/code>\u3067\u306f\u6b21\u306ePHP\u30a4\u30e1\u30fc\u30b8\u3092\u8aad\u307f\u8fbc\u3093\u3067\u3044\u308b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>FROM php:8.2-apache<\/code><\/pre>\n\n\n\n<p>Apache\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u78ba\u8a8d\u3059\u308b\u3068\u3001\u6b21\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u305f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># cat \/etc\/apache2\/sites-available\/000-default.conf\n&lt;VirtualHost *:80>\n        # The ServerName directive sets the request scheme, hostname and port that\n        # the server uses to identify itself. This is used when creating\n        # redirection URLs. In the context of virtual hosts, the ServerName\n        # specifies what hostname must appear in the request's Host: header to\n        # match this virtual host. For the default virtual host (this file) this\n        # value is not decisive as it is used as a last resort host regardless.\n        # However, you must set it for any further virtual host explicitly.\n        #ServerName www.example.com\n\n        ServerAdmin webmaster@localhost\n        DocumentRoot \/var\/www\/html\/public\n\n        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,\n        # error, crit, alert, emerg.\n        # It is also possible to configure the loglevel for particular\n        # modules, e.g.\n        #LogLevel info ssl:warn\n\n        ErrorLog ${APACHE_LOG_DIR}\/error.log\n        CustomLog ${APACHE_LOG_DIR}\/access.log combined\n\n        # For most configuration files from conf-available\/, which are\n        # enabled or disabled at a global level, it is possible to\n        # include a line for only one particular virtual host. For example the\n        # following line enables the CGI configuration for this host only\n        # after it has been globally disabled with \"a2disconf\".\n        #Include conf-available\/serve-cgi-bin.conf\n&lt;\/VirtualHost><\/code><\/pre>\n\n\n\n<p><code>DocumentRoot<\/code>\u306e\u4ee3\u308f\u308a\u306b<code>Alias<\/code>\u3092\u8a2d\u5b9a\u3057\u305f\u3089\u826f\u3055\u305d\u3046\u306a\u306e\u3067\u3001<br><code>Dockerfile<\/code>\u306b\u4e0b\u8a18\u3092\u8ffd\u52a0\u3057\u3066\u518d\u30d3\u30eb\u30c9\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>RUN sed -i '\/DocumentRoot\/c Alias \/sub \/var\/www\/html\/public' \/etc\/apache2\/sites-available\/000-default.conf<\/code><\/pre>\n\n\n\n<p>\u6b21\u306bLaravel\u30a2\u30d7\u30ea\u306e<code>public<\/code>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u3042\u308b<code>.htaccess<\/code>\u3092\u7de8\u96c6\u3059\u308b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Redirect Trailing Slashes If Not A Folder...\nRewriteCond %{REQUEST_FILENAME} !-d\nRewriteCond %{REQUEST_URI} (.+)\/$\n#RewriteRule ^ %1 &#91;L,R=301]\nRewriteRule ^(.*)\/$ \/sub\/$1 &#91;L,R=301] # \u8ffd\u52a0\nRewriteBase \/sub\/ # \u8ffd\u52a0<\/code><\/pre>\n\n\n\n<p>\u6700\u5f8c\u306b<code>.env<\/code>\u306e<code>APP_URL<\/code>\u3092\u30b5\u30d6\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u30d1\u30b9\u4ed8\u304d\u306b\u5909\u66f4\u3057\u305f\u3089\u5b8c\u4e86\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u53c2\u8003<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/minory.org\/laravel-subdirectry.html\" data-type=\"link\" data-id=\"https:\/\/minory.org\/laravel-subdirectry.html\">Apache\u306eAlias\u3068.htaccess\u3067Laravel\u3092\u30b5\u30d6\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u52d5\u304b\u3059 | minory<\/a><\/li>\n<\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"\u4f8b\u3048\u3070 www.example.com\/sub \u306e\u3088\u3046\u306a\u30b5\u30d6\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067Laravel\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u30db\u30b9\u30c8\u3059\u308b\u5834\u5408\u3001\u4f5c\u308a\u306b\u3088\u3063\u3066\u306f\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u3067\u306f\u7e4b\u304c\u3063\u3066\u3044\u305f\u30ea\u30f3\u30af\u304c\u5207\u308c\u305f\u308a\u3001\u4e0d\u5177\u5408\u304c\u767a\u751f\u3059\u308b\u3053\u3068\u3082\u3042\u308b\u3002\u3053\u3093\u306a\u6642\u30ed [&hellip;]","protected":false},"author":1,"featured_media":432,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"federate","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[8,39,47],"tags":[99,93,81,9,10],"class_list":["post-429","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-system-management","category-backend","category-frontend","tag-apache","tag-docker","tag-laravel","tag-linux","tag-memo"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/shugomatsuzawa.com\/techblog\/wp-content\/uploads\/sites\/3\/2025\/03\/work-flow-8453908_1920.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/posts\/429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/comments?post=429"}],"version-history":[{"count":2,"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/posts\/429\/revisions"}],"predecessor-version":[{"id":431,"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/posts\/429\/revisions\/431"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/media\/432"}],"wp:attachment":[{"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/media?parent=429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/categories?post=429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/tags?post=429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}