DockerのServerNameの設定についての質問です。
OS
mac(インテル)
やりたいこと
ServerNameを好きなドメイン名に変更しブラウザよりアクセスができるようにする
###ファイル構成
php -dockerfile -000-default.conf -php.ini html -index.html mysql docker-compose.yml
docker-compose.yml
yml
1version: '3' 2services: 3 php: 4 build: 5 context: ./php 6 dockerfile: dockerfile 7 volumes: 8 - ./php/000-default.conf:/etc/apache2/sites-enabled/000-default.conf 9 - ./php/php.ini:/usr/local/etc/php/php.ini 10 - ./html:/home/test/html 11 ports: 12 - 8000:80 13 links: 14 - mysql:mysql 15 mysql: 16 image: mysql:5.7 17 cpu_quota: 20000 18 volumes: 19 - ./mysql/data:/var/lib/mysql 20 ports: 21 - 13306:3306 22 environment: 23 - MYSQL_ROOT_PASSWORD=root 24 - MYSQL_DATABASE=testdb 25 - MYSQL_USER=testuser 26 - MYSQL_PASSWORD=password
php.ini
[Date] date.timezone = "Asia/Tokyo" [mbstring] mbstring.internal_encoding = "UTF-8" mbstring.language = "Japanese"
dockerfile
[Date] FROM php:7.4-apache ADD php.ini /usr/local/etc/php/ RUN apt-get update && apt-get install -y \ vim \ zip \ unzip \ libpng-dev \ libpq-dev \ && docker-php-ext-install \ pdo_mysql \ pdo_pgsql RUN a2enmod rewrite
000-default.conf
<Directory /home/test/html/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> <VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. ServerName local.test.com ServerAdmin webmaster@localhost DocumentRoot /home/test/html # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf </VirtualHost> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
index.html
test
hosts
127.0.0.1 local.test.com
の構成となっております。
やってみたこと1
http://localhost:8000/にアクセス。
結果
アクセスできる
やってみたこと2
local.test.comにアクセス。
結果
It works!
とでる。
これはおそらくdockerのアプリケーションを落としても、接続できるので、macの環境?
困っていること
ServerNameを好きなドメイン名に変更した後になにか設定があるのか?
よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー