7
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

WordPressの公式Dockerをサブディレクトリで使う方法

Last updated at Posted at 2018-11-25

概要

WordPressの公式Dockerをサブディレクトリで使いたいです。
例えば、http://example.com/blog/ でアクセスしたい。

この問題の対処法をぐぐるといくつかやり方が出て来ますが、良い方法が検索上位に来ていないので、インデックス用に記事を書きました。

結論

以下の方法を使うと良いです
https://github.com/docker-library/wordpress/pull/133#issuecomment-383199445

具体例 (docker-compose.yml)

version: '2'
services:
  blog:
    image: wordpress:4.9.8
    restart: always
    ports:
      - 8080:80
    volumes:
    - "/path/to/blog_store:/var/www/html/blog"
    working_dir: /var/www/html/blog # <- これがポイント
    links:
    - mysql:mysql-host
    environment:
      WORDPRESS_DB_HOST: mysql-host:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
  mysql:
    image: mysql:5.7
    volumes:
    - "/path/to/db_store:/var/lib/mysql"
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress
7
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?