Help us understand the problem. What is going on with this article?

PHP+MySQL+ApacheでさくっとDocker開発立ち上げる

More than 1 year has passed since last update.

フレームワークなしのPHPとMysqlだけのApache開発環境を作る機会があったので作成しました。
PHPやMySQLから始めたいプログラミング初心者の方、XAMPP卒業したいDocker初心者の方は是非参考にして見て下さい。

ファイル構成イメージ

.
├── Dockerfile
├── docker-compose.yml
└── index.php

docker-compose.yml

docker-compose.yml
version: "2"

services:
  app:
    build:
      context: .
      dockerfile: ./Dockerfile
    volumes:
      - ./:/var/www/html
    ports:
      - 80:80
    links:
      - mysql
    depends_on:
      - mysql
  mysql:
    image: mysql:5.7
    environment:
      - MYSQL_ROOT_PASSWORD=pass
      - MYSQL_DATABASE=php

Dockerfile

Dockerfile
FROM php:7.2-apache

RUN docker-php-ext-install pdo_mysql

index.php

index.php
<?php
    phpinfo();

Docker立ち上げ

docker-compose up -d

どーん!

アクセス

こんにちわんこ!
http://localhost/

MYSQLなど

dbname php
host mysql
user root
password pass

docker-compose exec mysql mysql -p pass php

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした