IT技術に関する情報掲載サイト

プログラミングに関することを掲載します。

Dockerを使ってMac環境でのLAMP環境の作り方

Linuxでのやり方は、たくさんあったのですが、Macでのものがなかったので、メモ程度に設定ファイルを作成しました。

どうもlinuxは、linux/x86_64を指定する必要があるようです

 

docker-compose.yml

 

version: '3.3'

services:
  mysql:
    # for M1 Mac
    platform: linux/x86_64
    image: mysql:5.7-oracle
    volumes:
      - ./docker/data:/var/lib/mysql
      - ./docker/mysql/sql:/docker-entrypoint-initdb.d
      - ./docker/mysql/conf.d:/etc/mysql/conf.d
    ports:
      - 33060:3306
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_DATABASE=craftsports-japan_com_db2
      - MYSQL_USER=user
      - MYSQL_PASSWORD=user
      - TZ=Asia/Tokyo
    command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --innodb-buffer-pool-size=64M --explicit_defaults_for_timestamp=1
    tty: true

  php:
    build: ./docker/
    volumes:
      - ./docker/php.ini:/usr/local/etc/php/php.ini
      - ./docker/logs:/var/log/httpd
      - ./html:/var/www/html
    ports:
      - 8080:80

  phpmyadmin:
    image: phpmyadmin:5.2
    environment:
      - PMA_ARBITRARY=1
      - PMA_HOST=mysql
      - PMA_USER=root
      - PMA_PASSWORD=root
      - UPLOAD_LIMIT=256M
    ports:
      - 4040:80
    volumes:
      - ./docker/phpmyadmin/sessions:/sessions

あと、apacheの設定ファイルも

apache.txt

 

#
# The following directives define some format nicknames for use with
# a CustomLog directive.
#
# These deviate from the Common Log Format definitions in that they use %O
# (the actual bytes sent including headers) instead of %b (the size of the
# requested file), because the latter makes it impossible to detect partial
# requests.
#
# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
# Use mod_remoteip instead.
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.

# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet