webdevops / php-docker-boilerplate

:stew: PHP Docker Boilerplate for Symfony, Wordpress, Joomla or any other PHP Project (NGINX, Apache HTTPd, PHP-FPM, MySQL, Solr, Elasticsearch, Redis, FTP)
https://webdevops.io/projects/php-docker-boilerplate/
MIT License
561 stars 185 forks source link

How do I install WordPress? #68

Closed mksglu closed 6 years ago

mksglu commented 6 years ago

Hello to everyone. I want to install WordPress inside the app directory. But mySQL does not accept the information. Can you help with this?

mblaschke commented 6 years ago

Which connection settings have you tried?

Hostname: mysql User: root (or dev) Password: dev Database: database

mksglu commented 6 years ago

Hi @mblaschke,

Thank u for responsive my issue.

Yes, it worked when I wrote mysql. This is definitely my mistake. I wrote "hostname: localhost". So where do I change the "mysql" name there?

mblaschke commented 6 years ago

The name mysql is coming from the name of the mysql container. If you change the name inside the docker-compose.yml file the hostname of the container will also be changed.

Each container is an own server environment (sandboxed) with it's own ip address.

And that's why you should use the hostname mysql for connecting to the mysql database which runs in a container :)

mksglu commented 6 years ago

Yes I understood. I have one more question. Do I also need to type "links: -phpmyadmin" in the "docker-compose.yml" file? So, the code below is correct?

version: '2'
services:
  #######################################
  # PHP application Docker container
  #######################################
  app:
    build:
      context: .
      dockerfile: Dockerfile.development
    links:
       - mysql
       - phpmyadmin
    ports:
      - "8000:80"
      - "8443:443"
      - "10022:22"
    volumes:
      - ./app/:/app/
      - ./:/docker/
    # cap and privileged needed for slowlog
    cap_add:
      - SYS_PTRACE
    privileged: true
    env_file:
      - etc/environment.yml
      - etc/environment.development.yml
    environment:
      - VIRTUAL_HOST=.app.boilerplate.docker
      - VIRTUAL_PORT=80
      - POSTFIX_RELAYHOST=[mail]:1025
mblaschke commented 6 years ago

The links are the network links so that these the app container can discover the mysql container using the hostname mysql. Same for phpmyadmin and all other containers. These containers are linked together.

The app container doesn't connect to phpmyadmin but phpmyadmin connects to mysql.

mksglu commented 6 years ago

You are awesome. Thank you for everything. Best regards.