{"id":3796,"date":"2023-01-08T14:49:39","date_gmt":"2023-01-08T05:49:39","guid":{"rendered":"https:\/\/dennie.tokyo\/it\/?p=3796"},"modified":"2026-01-30T19:00:35","modified_gmt":"2026-01-30T10:00:35","slug":"%e3%80%90docker%e3%80%91laravel8-%e7%92%b0%e5%a2%83%e6%a7%8b%e7%af%89","status":"publish","type":"post","link":"https:\/\/dennie.tokyo\/it\/?p=3796","title":{"rendered":"\u3010docker\u3011Laravel8 \u74b0\u5883\u69cb\u7bc9"},"content":{"rendered":"\n<p>\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u306edocker\u306bLaravel8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u52d5\u4f5c\u3055\u305b\u307e\u3059\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>\u81ea\u5206\u7528\u306e\u30e1\u30e2\u66f8\u304d\u306b\u306a\u308b\u306e\u3067\u3001\u8a73\u7d30\u306a\u8aac\u660e\u306f\u3057\u3066\u3044\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u30db\u30b9\u30c8PC\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u69cb\u6210<\/h1>\n\n\n\n<p>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u69cb\u6210\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>docker\n   -- Dockerfile\n   -- vhost.conf\nwebapp\ndocker-compose.yml<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">docker\u30c7\u30a3\u30ec\u30af\u30c8\u30ea<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Docker\u30d5\u30a1\u30a4\u30eb<\/h3>\n\n\n\n<p>Docker\u30d5\u30a1\u30a4\u30eb(Dockerfile)\u306e\u5185\u5bb9\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\" data-file=\"Dockerfile\"><code># \u30a4\u30e1\u30fc\u30b8\nFROM amazonlinux:2\n\n# \u30d0\u30fc\u30c1\u30e3\u30eb\u30db\u30b9\u30c8\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u30b3\u30f3\u30c6\u30ca\u3078\u30b3\u30d4\u30fc\u3059\u308b\nCOPY .\/docker\/vhost.conf \/etc\/httpd\/conf.d\/vhost.conf\n\n# \u30d0\u30fc\u30c1\u30e3\u30eb\u30db\u30b9\u30c8\u7528\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3059\u308b\nRUN mkdir \/www-contents\n\n# apache\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\nRUN yum -y update\nRUN yum -y install httpd\n\n# apache\u3092\u81ea\u52d5\u8d77\u52d5\u3055\u305b\u308b\nRUN systemctl enable httpd\n\n# \u30b3\u30f3\u30c6\u30ca\u8d77\u52d5\u6642 (docker run) \u30b3\u30de\u30f3\u30c9\nCMD [&quot;\/sbin\/init&quot;]<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d0\u30fc\u30c1\u30e3\u30eb\u30db\u30b9\u30c8\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb<\/h3>\n\n\n\n<p>Apache\u306e\u30d0\u30fc\u30c1\u30e3\u30eb\u30db\u30b9\u30c8\u3092\u8a2d\u5b9a\u3059\u308b\u30d5\u30a1\u30a4\u30eb(vhost.conf)\u306e\u5185\u5bb9\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\" data-file=\"vhost.conf\"><code>NameVirtualHost *:80\n\n&lt;VirtualHost *:80&gt;\n    ServerName local.webapp.com\n    DocumentRoot \/www-contents\/webapp\/public\n    DirectoryIndex index.php\n    &lt;Directory &quot;\/www-contents\/webapp\/public&quot;&gt;\n        Options -Indexes +FollowSymLinks\n        AllowOverride all\n        Require all granted\n    &lt;\/Directory&gt;\n&lt;\/VirtualHost&gt;<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">webapp\u30c7\u30a3\u30ec\u30af\u30c8\u30ea<\/h2>\n\n\n\n<p>Laravel\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">docker-compose.yml<\/h2>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>version: &quot;3&quot;\nservices:\n  web:\n    container_name: container_name\n    restart: always\n    build:\n      context: .\n      dockerfile: .\/docker\/Dockerfile\n    privileged: true\n    ports:\n      - 80:80\n    volumes:\n      - .\/webapp:\/www-contents\/webapp\n<\/code><\/pre><\/div>\n\n\n\n<h1 class=\"wp-block-heading\">\u624b\u9806<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">hosts\u306e\u8a2d\u5b9a<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>127.0.0.1 local.webapp.com<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u30b3\u30f3\u30c6\u30ca\u306e\u751f\u6210<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>docker-compose build\ndocker-compose up -d<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u30b3\u30f3\u30c6\u30ca\u30ed\u30b0\u30a4\u30f3<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>docker-compose exec web \/bin\/bash<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">PHP\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>amazon-linux-extras enable php8.0<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Laravel\u306b\u5fc5\u8981\u306aPHP\u30e2\u30b8\u30e5\u30fc\u30eb<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>yum install php-cli php-pdo php-fpm php-mysqlnd\nyum install php php-mbstring php-openssl php-xml zip unzip<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Apache\u518d\u8d77\u52d5<\/h2>\n\n\n\n<p>PHP\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u6709\u52b9\u306b\u3059\u308b\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u304c\u81ea\u52d5\u7684\u306b\u4f5c\u6210\u3055\u308c\u308b\u305f\u3081\u3001Apache\u306b\u518d\u8aad\u307f\u8fbc\u307f\u3055\u305b\u308b\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>systemctl restart httpd<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u30b3\u30f3\u30dd\u30fc\u30b6\u30fc\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>php -r &quot;copy(&#39;https:\/\/getcomposer.org\/installer&#39;, &#39;composer-setup.php&#39;);&quot;\nphp composer-setup.php\nmv composer.phar \/usr\/local\/bin\/composer\ncomposer -V\nrm composer-setup.php<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Laravel \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>cd www-contents\ncomposer create-project laravel\/laravel:^8.0 webapp<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u306e\u8a2d\u5b9a<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>cd webapp\nchmod -R 766 storage\/<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u30d6\u30e9\u30a6\u30b6\u30a2\u30af\u30bb\u30b9<\/h2>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>http:\/\/local.webapp.com<\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u306edocker\u306bLaravel8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u52d5\u4f5c\u3055\u305b\u307e\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":5116,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,13,12,14],"tags":[],"class_list":["post-3796","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-amazon-linux","category-apache","category-docker","category-laravel"],"_links":{"self":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/3796","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3796"}],"version-history":[{"count":8,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/3796\/revisions"}],"predecessor-version":[{"id":3807,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/3796\/revisions\/3807"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/media\/5116"}],"wp:attachment":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3796"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3796"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3796"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}