Git Product home page Git Product logo

wordpress-nginx-docker-compose's Introduction

Docker Compose and WordPress

Donate

Use WordPress locally with Docker using Docker compose

Contents

  • A Dockerfile for extending a base image and using a custom Docker image with an automated build on Docker Hub
  • PHP 8.1
  • Custom domain and HTTPS support. So you can use for example https://myapp.local
  • Custom nginx config in ./nginx
  • Custom PHP php.ini config in ./config
  • Volumes for nginx, wordpress and mariadb
  • Bedrock - modern development tools, easier configuration, and an improved secured folder structure for WordPress
  • Composer
  • WP-CLI - WP-CLI is the command-line interface for WordPress.
  • MailHog - An email testing tool for developers. Configure your outgoing SMTP server and view your outgoing email in a web UI.
  • PhpMyAdmin - free and open source administration tool for MySQL and MariaDB
    • PhpMyAdmin config in ./config
  • CLI script to create a SSL certificate

Instructions

Requirements

Install mkcert:

brew install mkcert
brew install nss # if you use Firefox
Setup

Setup Environment variables

Both step 1. and 2. below are required:

1. For Docker and the CLI script (Required step)

Copy .env.example in the project root to .env and edit your preferences.

Example:

IP=127.0.0.1
APP_NAME=myapp
DOMAIN="myapp.local"
DB_HOST=mysql
DB_NAME=myapp
DB_ROOT_PASSWORD=password
DB_TABLE_PREFIX=wp_

2. For WordPress (Required step)

Edit ./src/.env.example to your needs. During the composer create-project command described below, an ./src/.env will be created.

Example:

DB_NAME='myapp'
DB_USER='root'
DB_PASSWORD='password'

# Optionally, you can use a data source name (DSN)
# When using a DSN, you can remove the DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST variables
# DATABASE_URL='mysql://database_user:database_password@database_host:database_port/database_name'

# Optional variables
DB_HOST='mysql'
# DB_PREFIX='wp_'

WP_ENV='development'
WP_HOME='https://myapp.local'
WP_SITEURL="${WP_HOME}/wp"
WP_DEBUG_LOG=/path/to/debug.log

# Generate your keys here: https://roots.io/salts.html
AUTH_KEY='generateme'
SECURE_AUTH_KEY='generateme'
LOGGED_IN_KEY='generateme'
NONCE_KEY='generateme'
AUTH_SALT='generateme'
SECURE_AUTH_SALT='generateme'
LOGGED_IN_SALT='generateme'
NONCE_SALT='generateme'
Option 1). Use HTTPS with a custom domain
  1. Create a SSL cert:
cd cli
./create-cert.sh

This script will create a locally-trusted development certificates. It requires no configuration.

mkcert needs to be installed like described in Requirements. Read more for Windows and Linux

1b. Make sure your /etc/hosts file has a record for used domains. On Windows the hosts file can be find at C:\Windows\System32\drivers\etc. Make sure to open it with admin rights.

sudo nano /etc/hosts

Add your selected domain like this:

127.0.0.1 myapp.local
  1. Continue on the Install step below
Option 2). Use a simple config
  1. Edit nginx/default.conf.conf to use this simpler config (without using a cert and HTTPS)
server {
    listen 80;

    root /var/www/html/web;
    index index.php;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    client_max_body_size 100M;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass wordpress:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}
  1. Edit the nginx service in docker-compose.yml to use port 80. 443 is not needed now.
  nginx:
    image: nginx:latest
    container_name: ${APP_NAME}-nginx
    ports:
      - '80:80'
  1. Continue on the Install step below
Install
docker-compose run composer create-project
Run
docker-compose up

Docker Compose will now start all the services for you:

Starting myapp-mysql    ... done
Starting myapp-composer ... done
Starting myapp-phpmyadmin ... done
Starting myapp-wordpress  ... done
Starting myapp-nginx      ... done
Starting myapp-mailhog    ... done

🚀 Open https://myapp.local in your browser

PhpMyAdmin

PhpMyAdmin comes installed as a service in docker-compose.

🚀 Open http://127.0.0.1:8082/ in your browser

MailHog

MailHog comes installed as a service in docker-compose.

🚀 Open http://0.0.0.0:8025/ in your browser

Tools

Update WordPress Core and Composer packages (plugins/themes)

docker-compose run composer update

Use WP-CLI

docker exec -it myapp-wordpress bash

Login to the container

wp search-replace https://olddomain.com https://newdomain.com --allow-root

Run a wp-cli command

You can use this command first after you've installed WordPress using Composer as the example above.

Update plugins and themes from wp-admin?

You can, but I recommend to use Composer for this only. But to enable this edit ./src/config/environments/development.php (for example to use it in Dev)

Config::define('DISALLOW_FILE_EDIT', false);
Config::define('DISALLOW_FILE_MODS', false);

Useful Docker Commands

When making changes to the Dockerfile, use:

docker-compose up -d --force-recreate --build

Login to the docker container

docker exec -it myapp-wordpress bash

Stop

docker-compose stop

Down (stop and remove)

docker-compose down

Cleanup

docker-compose rm -v

Recreate

docker-compose up -d --force-recreate

Rebuild docker container when Dockerfile has changed

docker-compose up -d --force-recreate --build
Changelog

2022-05-28

2022-05-28

  • Use php:8.0-fpm-alpine as the base image on the image in Dockerfile

2022-05-28

  • Updated the Docker image to use PHP 8

2021-08-04

  • Updated to WordPress 5.8.0

2021-03-16

  • Changed root .env-example to .env.example to match the git ignore patterns. Thanks @scottnunemacher

2021-03-05

  • Clarify steps in the readme

2021-03-02

  • Fixed a misstake so instead of ./src/.env-example, it should be ./src/.env.example.
  • Redirect HTTP to HTTPS. Thanks @humblecoder

2021-01-02

  • Use NGINX_ENVSUBST_TEMPLATE_SUFFIX. Use a template and better substution of ENV variables in nginx config.

2020-10-04

  • Added mariadb-client (Solves #54)

2020-09-15

  • Updated Bedrock. Update WordPress to 5.5.1 and other composer updates.

2020-07-12

2020-05-03

  • Added nginx gzip compression

2020-04-19

  • Added Windows support for creating SSH cert, trusting it and setting up the host file entry. Thanks to @styssi

2020-04-12

  • Remove port number from DB_HOST. Generated database connection error in macOS Catalina. Thanks to @nirvanadev
  • Add missing ENV variable from mariadb Thanks to @vonwa

2020-03-26

2020-02-06

  • Readme improvements. Explain /etc/hosts better

2020-01-30

  • Use Entrypoint command in Docker Compose to replace the domain name in the nginx config. Removing the need to manually edit the domain name in the nginx conf. Now using the .env value DOMAIN
  • Added APP_NAME in .env-example Thanks to @Dave3o3

2020-01-11

  • Added .env support for specifying your own app name, domain etc in Docker and cli scripts.
  • Added phpMyAdmin. Visit http://127.0.0.1:8080/

2019-08-02

wordpress-nginx-docker-compose's People

Contributors

bc1121 avatar burdulixda avatar dependabot[bot] avatar dirkgroenen avatar mortensassi avatar nirvanadev avatar pliegl avatar scottnunemacher avatar styssi avatar urre avatar watchmydc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wordpress-nginx-docker-compose's Issues

Wordpress Index.php redirect loop causing performance issues

Hi Urre,

Once again, thanks for the great stack. I thought you should be aware of the multiple index.php redirects from each browser request. Scroll down to see Docker log. Also, note that there are no plugins installed in my installation.

The trouble is that when large plugins like WooCommerce and Buddypress are installed, the site takes up to 3min to load. I suspect it's because of these redirects.

I also enabled xDebug and realised that the functions.php file is also called 4 or sometimes 6 times. That means from a single call, WP tries to load several times.

I did a bit of digging and found this discussion on stackexchange:
https://wordpress.stackexchange.com/questions/292322/wordpress-index-php-seems-to-perform-unwanted-redirect-301

I have not been able to make the fix yet, because the wp-config file is really customised. When I change the .env file, the site falls apart. Also, this might be caused by the SSL certificate. Anyway, please have a look at it.

P.S here's a DOCKER log of all the calls that are initiated from a single browser request

skybookings-wordpress | [ip.hidden] - 25/Apr/2020:01:24:41 +0000 "GET /index.php" 301
skybookings-wordpress | [ip.hidden] - 25/Apr/2020:01:24:41 +0000 "GET /index.php" 404
skybookings-wordpress | [ip.hidden] - 25/Apr/2020:01:24:42 +0000 "GET /index.php" 404
skybookings-wordpress | [ip.hidden] - 25/Apr/2020:01:24:43 +0000 "GET /index.php" 200
skybookings-wordpress | [ip.hidden] - 25/Apr/2020:01:25:03 +0000 "GET /index.php" 200
skybookings-wordpress | [ip.hidden] - 25/Apr/2020:01:25:07 +0000 "GET /index.php" 404
skybookings-wordpress | [ip.hidden] - 25/Apr/2020:01:25:07 +0000 "GET /index.php" 301
skybookings-wordpress | [ip.hidden] - 25/Apr/2020:01:25:08 +0000 "GET /index.php" 404
skybookings-wordpress | [ip.hidden] - 25/Apr/2020:01:25:09 +0000 "GET /index.php" 20

create-cert.sh not portable to CentOS/RHEL

An error is produced when running create-cert.sh on CentOS (7.7):

[vagrant@localhost cli]$ ./create-cert.sh
cat: /etc/ssl/openssl.cnf: No such file or directory
Generating a 2048 bit RSA private key

writing new private key to 192.168.1.193.key

unable to find 'distinguished_name' in config
problems making Certificate Request
140288227555216:error:0E06D06C:configuration file routines:NCONF_get_string:no value:conf_lib.c:324:group=req name=distinguished_name

OpenSSL.conf is installed in /etc/pki/tls/openssl.cnf by default and is not found in your script.

Not a big deal, would be helpful to add this to the capabilities of your super-handy template!

How to make work with BrowserSync proxy

Hey @urre,

This is a great project, so thank you for making it. I'm trying to get browsersync to work to help with the theme's local development. I use the Sage theme also from the Roots stack. Normally you set the dev domain in the webpack.mix.js file and run yarn start from the theme directory.

I added a node service for this to docker-compose.yml:

  node:
    image: node:12-slim
    container_name: ${APP_NAME}-node
    working_dir: /var/www/html/web/app/themes/sage
    restart: 'no'
    volumes:
      - ../site:/var/www/html:rw,cached

So I can build the theme files by running: docker-compose run node yarn build but running docker-compose run node yarn start which starts the development mode using browsersync is not working. Browsersync gives the localhost:3000 URL to look at your site on to see the changes, but obviously this is not working. I'm not sure how to proxy this development URL from the docker container to be used on my machine. I've tried several things but I've ran in to a brick wall. I was wondering if you had an idea on how to get this set up?

Thanks again!
Aaron

404 NGINX Error Permission Denied

Hi, thanks for this great stack,
I don't have good experience in Docker but I tried to follow the steps in the readme file,
The trouble I have is related to permissions, I am running this stack in Linux Mint, but NGINX is complaining about permissions only for WordPress, PHPMyAdmin, and MailHog are up and running fine. Not sure what I missed here:

Error when trying to access WordPress:
404 Not Found

Error Log:

[crit] 8#8: *2 stat() "/var/www/html/web/" failed (13: Permission denied), client: <My_IP_ADDRESS>, server: mydomain.local, request: "GET / HTTP/2.0", host: "university.local"
[crit] 8#8: *2 stat() "/var/www/html/web/" failed (13: Permission denied), client: <My_IP_ADDRESS>, server: mydomain.local, request: "GET / HTTP/2.0", host: "university.local"
[crit] 8#8: *2 stat() "/var/www/html/web/index.php" failed (13: Permission denied), client: <My_IP_ADDRESS>, server: mydomain.local, request: "GET / HTTP/2.0", host: "university.local"

Nginx config:

server {
    listen      80;
    listen [::]:80;
    server_name $domain;

    location / {
        rewrite ^ https://$host$request_uri? permanent;
    }
}

server {
    listen      443           ssl http2;
    listen [::]:443           ssl http2;
    server_name               $domain www.$domain;

    add_header                Strict-Transport-Security "max-age=31536000" always;

    ssl_session_cache         shared:SSL:20m;
    ssl_session_timeout       10m;

    ssl_protocols             TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers               "ECDH+AESGCM:ECDH+AES256:ECDH+AES128:!ADH:!AECDH:!MD5;";

    root /var/www/html/web;
    index index.php;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ssl_certificate           /etc/certs/$domain.crt;
    ssl_certificate_key       /etc/certs/$domain.key;

    gzip on;
    gzip_http_version 1.0;
    gzip_disable "msie6";
        gzip_vary on;
        gzip_proxied any;
        gzip_comp_level 6;
        gzip_buffers 16 8k;
        gzip_min_length 256;
  gzip_types
    text/css
    text/javascript
    text/xml
    text/plain
    text/x-component
    application/javascript
    application/json
    application/xml
    application/rss+xml
    font/truetype
    font/opentype
    application/vnd.ms-fontobject
    image/svg+xml;

    client_max_body_size 100M;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass wordpress:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

Docker-compose.yml:

version: '3.6'
services:
  nginx:
    image: nginx:latest
    container_name: ${APP_NAME}-nginx
    ports:
      - '80:80'
      - '443:443'
    volumes:
      - ./nginx/default.conf:/tmp/default.template
      - ./src:/var/www/html:rw,cached
      - ./certs:/etc/certs
    depends_on:
      - wordpress
    restart: always
    entrypoint: /bin/bash -c 'cat /tmp/default.template | sed "s/\\\$$domain/${DOMAIN}/g" > /etc/nginx/conf.d/default.conf && nginx -g "daemon off;"'

  mysql:
    image: mariadb
    container_name: ${APP_NAME}-mysql
    volumes:
       - './data/db:/var/lib/mysql:delegated'
    environment:
      - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
      - MYSQL_DATABASE=${DB_NAME}
    restart: always
    ports:
      - '3306:3306'

  wordpress:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: ${APP_NAME}-wordpress
    volumes:
      - ./src:/var/www/html:rw,cached
      - ./config/php.ini:/usr/local/etc/php/conf.d/php.ini
    depends_on:
      - mysql
    restart: always

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: ${APP_NAME}-phpmyadmin
    volumes:
      - ./config/phpmyadmin.ini:/usr/local/etc/php/conf.d/phpmyadmin.ini
    environment:
      PMA_HOST: "${DB_HOST}"
      PMA_PORT: 3306
      MYSQL_ROOT_PASSWORD: "${DB_ROOT_PASSWORD}"
    ports:
      - '8080:80'
    links:
      - mysql:mysql

  mailhog:
    container_name: ${APP_NAME}-mailhog
    image: mailhog/mailhog
    ports:
      - "8025:8025"
      - "1025:1025"

  composer:
    image: composer
    container_name: ${APP_NAME}-composer
    working_dir: /var/www/html
    restart: 'no'
    volumes:
      - ./src:/var/www/html:rw,cached

Any help is appreciated.

Thanks again

Problem running Worpress site locally

Hello,

Environnement

I'm on Linux Mint Ulyana 20 on a LAMP config.

Problem & Verifications

When I launch the wordpress site on the custom domain neither HTTP or HTTPS config works and I get a 404.
I can access to phpmyadmin and mailhog containers.
The certs are installed in a certs/ folder is at the root.
No errors when I run docker-compose up

Test

  1. I just changed the port 80:80 to 81:81 because the 80 port is already used by my Apache server (for HTTP) locally.
  • The nginx config in docker-compose.yml :
version: '3.6'
services:
  nginx:
    image: nginx:latest
    container_name: ${APP_NAME}-nginx
    ports:
      - '81:81'
      - '443:443'
    volumes:
      - "./nginx/:/etc/nginx/templates/"
      - ./src:/var/www/html:rw,cached
      - ./certs:/etc/certs
    environment:
      - "NGINX_ENVSUBST_TEMPLATE_SUFFIX=.conf"
      - "DOMAIN=${DOMAIN}"
    depends_on:
      - wordpress
    restart: always
  • default.conf.conf :
server {
    listen      81;
    listen [::]:81;
  1. I tried to stop my local Apache server sudo systemctl stop apache2 and reloading containers but I also get a 404.

If someone has an idea...

Certificates file type, import into Firefox and Chrome

I have nearly zero knowledge about SSL and certificates, so I'm already sorry if this question might be out of scope of this project.

I could set up nearly everything, except for the certs. The creation works, adding it to the certificate store in Linux works and updating the host file works with the scripts. Yet, Firefox and Chromium both seems to manage their stores and don't take the certificate from the OS (at least on Ubuntu/Pop_OS).

Now both browsers accept importing a pfx file, so I generated a pfx file from the given cert file and imported it into both browsers, but apparently that doesn't seem to work.

Do I miss something to make this working flawlessly with Chromium and Firefox?

(Question) Production

Hi Urre, nice repo, thanks!

I've got a couple of questions regarding the best-practices for deployment to a VPS.
Besides these instructions, for production I still needed to include the ./src/vendor, ./src/config and the ./src/wp directories in the final build.
You're ignoring them by default in your .gitignore files.

I needed to add these lines in the Dockerfile you're using before and after the VOLUME in order to run the WP:

RUN set -ex; \
    mkdir -p -m775 /var/www/html/web/wp; \
    cp -ar /usr/src/wordpress/. /var/www/html/web/wp; \
    chmod -R 775 /var/www/html/web/wp

VOLUME /var/www/html

RUN mkdir -p -m775 /var/www/html/web/{vendor, config}
COPY src/vendor /var/www/html/web/vendor
COPY src/config /var/www/html/web/config
RUN chown -R www-data:www-data /var/www/html/web
# I mount all these three directories later with docker-compose.yml

Is this an appropriate way of doing things in production? Is there any specific production build routine for WP?
Do you maybe have some examples of a Dockerfile and/or docker-compose.yml (swarm stack?) files that you're using for production?

Issues working with Traefik

Following the steps exactly everything seems to work fine... However, I'm having trouble once I try to get this to work with Traefik.

Since Traefik uses port 80 and 443, I usually just remove the port section from anything else trying to reserve those ports (in this case nginx) and it usually doesn't cause me any problems. But with this setup it's been giving me 'not found' and 'gateway' errors.

Trying to trace the logs down to the source of the problem, this often comes up:

[emerg] 1#1: host not found in upstream "wordpress" in /etc/nginx/conf.d/wordpress_ssl.conf:43
myapp-nginx  | nginx: [emerg] host not found in upstream "wordpress" in /etc/nginx/conf.d/wordpress_ssl.conf:43

Which refers to this line in the nginx conf

fastcgi_pass wordpress:9000;

I've tried a number of this to try to get past this (I won't share them all), but this is my modified nginx conf:

server {
    listen      80;
    server_name myapp.local;

    # listen      443           ssl http2;
    # listen [::]:443           ssl http2;
    # server_name               myapp.local www.myapp.local;

    # add_header                Strict-Transport-Security "max-age=31536000" always;

    # ssl_session_cache         shared:SSL:20m;
    # ssl_session_timeout       10m;

    # ssl_protocols             TLSv1 TLSv1.1 TLSv1.2;
    # ssl_prefer_server_ciphers on;
    # ssl_ciphers               "ECDH+AESGCM:ECDH+AES256:ECDH+AES128:!ADH:!AECDH:!MD5;";

    root /var/www/html/web;
    index index.php;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    # ssl_certificate           /etc/certs/myapp.local.crt;
    # ssl_certificate_key       /etc/certs/myapp.local.key;

    # client_max_body_size 100M;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass wordpress:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

I disabled the SSL stuff to make it easier to debug... Any ideas on why I'm getting these issues / what I can do to get around them?

PHP-FPM

I assume this is working but havent forked the repo but how are you getting nginx to serve php files without using a php-fpm image? I cant see any reference in the configs although the nginx config shows you are using fastcgi.

ERR_NAME_NOT_RESOLVED when trying to access wp-admin on a new project

After following the instruction very carefully, I still can't connect to the wp-admin. I am by no mean an expert with docker and have only used an abstraction of it with Laravel sail.

Exact steps I did to arrive to this result

  1. Install mkcert and nss via homebrew
  2. Copy .env.example at the root of the project to a new .env file
  3. Generate keys with the URL in comments (roots.salt), and replaced my keys accordingly, then left everything as is in .env.example in ./src
  4. Generate certification with cd cli && ./create-cert.sh which has worked successfully
  5. I ran docker-compose run composer create-project. It returned a warning about the lock file not being up to date, which I ignored for the time being, but everything installed fine, and .env.example successfully copied to .env in src
  6. Ran docker-compose up -d, everything launches fine
  7. Try to connect using chrome to https://myapp.local or https://myapp.local/wp/wp-admin, both returns ERR_NAME_NOT_RESOLVED. I can connect to php-my-admin and mailhog successfully however.

After doing some research, I am not really sure how to solve this problem, but I thought I would share in case I am not the only one having this issue.

Nginx not passing requests further to Worpress

Hi urre,

thank you for your awesome work. I'm already using it right now for my third project! :)

I am currently struggling with just accessing the page. Unfortunately, I don't fully understand the NGINX config which tries to find files in the nginx container with the first rule location /.

If I curl the server with curl https://medals.local, it returns "403" and logs [error] 8#8: *11 directory index of "/var/www/html/" is forbidden.

If I run curl https://medals.local/composer.json, it actually returns my composer.json.

Thus, I suspect it only tries to resolve my requests with the files in the nginx container and doesn't pass them further to the wordpress container. Do you have a clue what I could have mixed up with the config so this arises? And why at all do we need this first location block in the nginx config?

nginx/default.conf:

server {
    listen      80;
    listen [::]:80;
    server_name $domain;

    location / {
        rewrite ^ https://$host$request_uri? permanent;
    }
}

server {
    listen      443           ssl http2;
    listen [::]:443           ssl http2;
    server_name               $domain www.$domain;

    add_header                Strict-Transport-Security "max-age=31536000" always;

    ssl_session_cache         shared:SSL:20m;
    ssl_session_timeout       10m;

    ssl_protocols             TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers               "ECDH+AESGCM:ECDH+AES256:ECDH+AES128:!ADH:!AECDH:!MD5;";

    root /var/www/html;
    index index.php;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ssl_certificate           /etc/certs/$domain.crt;
    ssl_certificate_key       /etc/certs/$domain.key;

    gzip on;
    gzip_http_version 1.0;
    gzip_disable "msie6";
        gzip_vary on;
        gzip_proxied any;
        gzip_comp_level 6;
        gzip_buffers 16 8k;
        gzip_min_length 256;
  gzip_types
    text/css
    text/javascript
    text/xml
    text/plain
    text/x-component
    application/javascript
    application/json
    application/xml
    application/rss+xml
    font/truetype
    font/opentype
    application/vnd.ms-fontobject
    image/svg+xml;

    client_max_body_size 100M;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass wordpress:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

Greetings and thanks in advance,
Thomas

Update:
I was able to solve it by fixing my wrong defined "root" attribute which was missing the /web suffix. Still, I'd be interested in how this whole nginx config works. Why doesn't it just pass everything further to wordpress but holds those files separately in the nginx container?

Fatal error: Uncaught Error

Sage-10 have Fatal error: Uncaught Error

Fatal error: Uncaught Error: Call to undefined method Dotenv\Repository\RepositoryBuilder::createWithDefaultAdapters() in /var/www/html/web/app/themes/sage-10/vendor/illuminate/support/Env.php:55 Stack trace:
#0 /var/www/html/web/app/themes/sage-10/vendor/illuminate/support/Env.php(76): Illuminate\Support\Env::getRepository() #1 /var/www/html/web/app/themes/sage-10/vendor/roots/acorn/src/Illuminate/Foundation/Application.php(1067): Illuminate\Support\Env::get('APP_CONFIG_CACH...')
#2 /var/www/html/web/app/themes/sage-10/vendor/roots/acorn/src/Illuminate/Foundation/Application.php(1015): Illuminate\Foundation\Application->normalizeCachePath('APP_CONFIG_CACH...', 'cache/config.ph...')
#3 /var/www/html/web/app/themes/sage-10/vendor/roots/acorn/src/Roots/Acorn/Bootstrap/LoadConfiguration.php(24): Illuminate\Foundation\Application->getCachedConfigPath() #4 /var/www/html/web/app/themes/sage-10/vendor/roots/acorn/src/Illuminate/Foundation/Application.php(237): Roots\Acorn\Bootstrap\LoadConfiguration->bootstrap(Object(Roots\Acorn in /var/www/html/web/app/themes/sage-10/vendor/illuminate/support/Env.php on line 55

domain.local is not resolved in composer container using satispress local composer repository

While using composer I came up with a need to setup satispress for my custom themes or plugins.

composer.json

{
...
"repositories": [
    {
      "type": "composer",
      "url": "https://wpackagist.org",
      "only": ["wpackagist-plugin/*", "wpackagist-theme/*"]
    },
    {
      "type": "composer",
      "url": "https://domain.local/satispress/"
    }
  ],
...
  "require": {
    ...
    "custompackage/package": "*"
  }
}

While running command:

docker-compose run composer update

Getting error:

[Composer\Downloader\TransportException]                           
  Failed to connect to domain.local port 443: Connection refused

I guess composer container uses docker network DNS server instead of host. Also composer container does not have root ca's in order to access https://domain.local

How to remove SSL

Hello,
i have problems with removing SSL Certificate in localhost:3000 url.
How to make this work.
I have OSX Catalina.
Please help.
I have this error: ERR_SSL_PROTOCOL_ERROR

Question: Use this repo without bedrock or composer

Thanks Urre for all you're work on this. I use this repo on a daily basis now!

I wanted to ask if you could upload some instructions or give the options to develop using this repo without bedrock or composer.

Reason for this is some basic hosts when deploying do not really work with bedrock / have composer installed.

I did try messing around and deleting composer but I just kept running into issues.

Any help or direction would be much appreciated!

Connection refused

When I run curl -I -k https://myapp.local I get curl: (7) Failed to connect to myapp.local port 443: Connection refused.
I also notice src/.env is not generated.
When I visit http://myapp.local (no https) I get the Nginx welcome page only.

I probably messed it up myself but I don't know what I did wrong. I tried with the Nginx config unchanged and the one in the readme but neither work.

nginx: [emerg] cannot load certificate "/etc/certs/"myapp.local".pem"

I just create certs by ./create_cert.sh but it requires mkcert. So, I use brew install mkcert and create the certs folder successfully. And this forwards to the problem VARIABLE is not set. After resetting the terminal, I meet this issue.

$ docker-compose ps
           Name                          Command                 State                                            Ports                                      
-------------------------------------------------------------------------------------------------------------------------------------------------------------
6137b00f87eb_myapp-mysql      docker-entrypoint.sh --low ...   Up           0.0.0.0:3306->3306/tcp,:::3306->3306/tcp                                         
6cc6aea5d1cd_myapp-composer   /docker-entrypoint.sh composer   Exit 0                                                                                        
a290743c1e84_myapp-mailhog    MailHog                          Up           0.0.0.0:1025->1025/tcp,:::1025->1025/tcp,                                        
                                                                            0.0.0.0:8025->8025/tcp,:::8025->8025/tcp                                         
myapp-nginx                   /docker-entrypoint.sh ngin ...   Restarting                                                                                    
myapp-phpmyadmin              /docker-entrypoint.sh apac ...   Up           0.0.0.0:8082->80/tcp,:::8082->80/tcp                                             
myapp-wordpress               docker-php-entrypoint php-fpm    Up           9000/tcp 
$ docker-compose logs nginx
myapp-nginx   | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
myapp-nginx   | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
myapp-nginx   | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
myapp-nginx   | 10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
myapp-nginx   | 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf differs from the packaged version
myapp-nginx   | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
myapp-nginx   | 20-envsubst-on-templates.sh: Running envsubst on /etc/nginx/templates/default.conf.conf to /etc/nginx/conf.d/default.conf
myapp-nginx   | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
myapp-nginx   | /docker-entrypoint.sh: Configuration complete; ready for start up
myapp-nginx   | 2021/07/25 06:06:04 [emerg] 1#1: cannot load certificate "/etc/certs/"myapp.local".pem": BIO_new_file() failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/certs/"myapp.local".pem','r') error:2006D080:BIO routines:BIO_new_file:no such file)
myapp-nginx   | nginx: [emerg] cannot load certificate "/etc/certs/"myapp.local".pem": BIO_new_file() failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/certs/"myapp.local".pem','r') error:2006D080:BIO routines:BIO_new_file:no such file)

Please help me. Thank you.

create-cert.sh: line 33: syntax error near unexpected token `('

Just installing a project based on this on another machine but getting terminal error?

./create-cert.sh: line 33: syntax error near unexpected token `('

Using an exact version of your create-cert.sh. Using iTerm macOS and tried normal terminal too.

Any ideas? Thanks, D.

what about a quick shell script to install ?

This approach to the local environment is super cool but what about a quick setup shell before composer install??

something like:

./setup/setup.sh

Tested in macOS, I use most of the time GasMask App, for host management, so I don't add the host shell script, instead, I suggest if you prefer to use GasMask:

[ Download GasMask App: ]

Download GasMask

or

brew cask install gas-mask

[Configure GasMask App]

also, I end up using Python for Randomly using an open Port for MySQL

This Shell Script is too simple but works JUST for MacOS local environment.

and Need to add Nginx Reverse Proxy, but I have to think how to do that LOL

#!/usr/bin/env bash

set -e
export DOCKERING="../../"

RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[0;93m'
NC='\033[0m'

if ((BASH_VERSINFO[0] <= 4)); then 
    echo -e "Sorry, you need at least bash-4.0 to run this script." >&2; 
    echo "The Bash version is $BASH_VERSION !";

    echo -e "${RED}You need to update Bash Version to 4+"
    echo -e "${Red}Would you like to update BASH? YES or NO"
    select yn in "YES" "NO"; do 
    case $yn in
        YES ) brew install bash; which -a bash; bash --version; break;;
        NO ) break;;
        esac
    done
else
     echo -e "You have the bash-4.0 or above" >&2;
echo "The Bash version is $BASH_VERSION !";
fi

echo -e "${BLUE}Enter name of the project domain (i.e. project): ${NC}"
read PROJECT

POD=${PROJECT}
SCHEMEDOWN=${POD,,}
SCHEMEUP=${POD^^}

BLOCK_DK="./.docker-compose.yml"

# Find out random unused TCP port 
PORT_MYSQL=$(python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()');

if [[ (-z "${PROJECT}") ]]; then
    echo -e "${RED}Project Cancelled ${NC}";
        rm -rf .docker-compose.yml
else
    echo -e "${BLUE}Project ** ${SCHEMEUP} ** initiallizad : ${NC}"
    rm -f .docker-compose.yml;

tee ${BLOCK_DK} > /dev/null <<EOF 
version: '3.6'
services:
  nginx:
    image: nginx:latest
    container_name: app-${SCHEMEDOWN}-nginx
    ports:
      - '80:80'
      - '443:443'
    volumes:
      - ./nginx:/etc/nginx/conf.d
      - ./src:/var/www/html:rw,cached
      - ./certs:/etc/certs
    depends_on:
      - wordpress
    restart: always

  mysql:
    image: mariadb
    container_name: app-${SCHEMEDOWN}-mysql
    volumes:
      - './data/db:/var/lib/mysql:delegated'
    environment:
      - MYSQL_ROOT_PASSWORD=wp
      - MYSQL_DATABASE=app_${SCHEMEDOWN}_db
    restart: always
    ports:
      - '$PORT_MYSQL:3306'

  wordpress:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: app-${SCHEMEDOWN}-wordpress
    volumes:
      - ./src:/var/www/html:rw,cached
      - ./config/php.ini:/usr/local/etc/php/conf.d/php.ini
    environment:
      - WORDPRESS_DB_NAME=app_${SCHEMEDOWN}_db
      - WORDPRESS_TABLE_PREFIX=wp_
      - WORDPRESS_DB_HOST=mysql
      - WORDPRESS_DB_PASSWORD=wp
    depends_on:
      - mysql
    restart: always

  composer:
    image: composer/composer
    container_name: app-${SCHEMEDOWN}-composer
    working_dir: /var/www/html
    restart: 'no'
    volumes:
      - ./src:/var/www/html:rw,cached
EOF

rm -f .wordpress_${SCHEMEDOWN}_ssl.conf;

BLOCK_SSL="./.wordpress_ssl.conf"
tee ${BLOCK_SSL} > /dev/null <<EOF 
server {
    listen      80;
    listen [::]:80;
    server_name $SCHEMEDOWN.local;

  location / {
    rewrite ^ https://\$host\$request_uri? permanent;
  }
}

server {
    listen      443           ssl http2;
    listen [::]:443           ssl http2;
    server_name               $SCHEMEDOWN www.$SCHEMEDOWN;

    add_header                Strict-Transport-Security "max-age=31536000" always;

    ssl_session_cache         shared:SSL:20m;
    ssl_session_timeout       10m;

    ssl_protocols             TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers               "ECDH+AESGCM:ECDH+AES256:ECDH+AES128:!ADH:!AECDH:!MD5;";

    root /var/www/html/web;
    index index.php;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ssl_certificate           /etc/certs/$SCHEMEDOWN.local.crt;
    ssl_certificate_key       /etc/certs/$SCHEMEDOWN.local.key;

    client_max_body_size 100M;

  location / {
    try_files \$uri \$uri/ /index.php?\$args;
  }

  location ~ \.php\$ {
    try_files \$uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)\$;
    fastcgi_pass wordpress:9000;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
    fastcgi_param PATH_INFO \$fastcgi_path_info;
  }
}
EOF

echo -e "\n ${GREEN} Project ${SCHEMEUP} Created"
fi

if [[ "$OSTYPE" == "linux-gnu" ]]; then
    OPENSSL_CNF_PATH=/etc/ssl/openssl.cnf
fi

if [[ "$OSTYPE" == "darwin"* ]]; then
    OPENSSL_CNF_PATH=/System/Library/OpenSSL/openssl.cnf
fi

openssl req \
    -newkey rsa:2048 \
    -x509 \
    -nodes \
    -keyout ${SCHEMEDOWN}.local.key \
    -new \
    -out ${SCHEMEDOWN}.local.crt \
    -subj /CN=${SCHEMEDOWN}.local \
    -reqexts SAN \
    -extensions SAN \
    -config <(cat $OPENSSL_CNF_PATH \
        <(printf '[SAN]\nsubjectAltName=DNS:'${PROJECT}.local)) \
    -sha256 \
    -days 3650

mkdir -p ../certs

mv *.crt ../certs/
mv *.key ../certs/

echo -e ${GREEN}"Cert created in /cert! ${NC}"


if [[ "$OSTYPE" == "darwin"* ]]; then
    sudo security add-trusted-cert -d -r trustRoot -k "/Library/Keychains/System.keychain" "../certs/${SCHEMEDOWN}.local.crt"
fi

if [[ "$OSTYPE" == "linux-gnu" ]]; then
    cp ../certs/* /usr/local/share/ca-certificates/
    sudo update-ca-certificates
fi
echo -e ${GREEN}"The cert should now be trusted in macOS System Keychain. Trusted in Chrome and Safari. (Not Firefox since it's using its own keychain manager) ${NC}"

# Update docker-compose
echo -e "${GREEN}docker-compose.yml file will set and update it"
mv .docker-compose.yml docker-compose.yml;
cp docker-compose.yml ../;
rm -rf ./docker-compose.yml;
echo -e "${GREEN}Success docker-compose.yml file created"

# Update SSL
echo -e "${GREEN}NGNIX Config file we will setand update it"
mv .wordpress_ssl.conf wordpress_ssl.conf;
cp wordpress_ssl.conf ../nginx;
rm -rf ./wordpress_ssl.conf;
echo -e "${GREEN}Success wordpress_ssl.conf file created"

# Config Environment
echo -e "${GREEN}Configuring Environment"
echo -e "DB_HOST=mysql:3306
DB_NAME=app_${SCHEMEDOWN}_db
DB_USER=root
DB_PASSWORD=wp
# DB_PREFIX=wp_

WP_ENV=development
WP_HOME=https://${SCHEMEDOWN}.local
WP_SITEURL=${WP_HOME}/wp

# Generate your keys here: https://roots.io/salts.html
AUTH_KEY='generateme'
SECURE_AUTH_KEY='generateme'
LOGGED_IN_KEY='generateme'
NONCE_KEY='generateme'
AUTH_SALT='generateme'
SECURE_AUTH_SALT='generateme'
LOGGED_IN_SALT='generateme'
NONCE_SALT='generateme'
" > .env

echo -e "${GREEN}.env file will set and update it"
cp .env ../src;
rm -rf ./.env;
echo -e "${GREEN}Success .env file created"

# Set Composer install and Run Docker
echo -e "${BLUE}#Install WP and Composer dependencies and Run Docker.\n" 
echo -e "${BLUE}cd ../src && composer install && docker-compose run composer update && cd ../ && docker-compose up -d --force-recreate --build;
\n"

issue when trying to run create-cert.sh on Latest MacOS Catalina 10.15.4

Downloaded the repo, copied to folder, run brew install openssl but when doing so

openssl version
LibreSSL 2.8.3

is the result i get

cli % ./create-cert.sh
Error Loading extension section SAN
4415454828:error:22FFF06D:X509 V3 routines:func(4095):invalid null value:/AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-47.100.4/libressl-2.8/crypto/x509v3/v3_utl.c:355:
4415454828:error:22FFF069:X509 V3 routines:func(4095):invalid extension string:/AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-47.100.4/libressl-2.8/crypto/x509v3/v3_conf.c:149:name=subjectAltName,section=DNS:
4415454828:error:22FFF080:X509 V3 routines:func(4095):error in extension:/AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-47.100.4/libressl-2.8/crypto/x509v3/v3_conf.c💯name=subjectAltName, value=DNS:
plebeian@Marks-MacBook-Pro cli %

Persist DB

Lovely – super clean and well documented.

I would’ve assumed there to be a volume for db persistence per default too though, no?

composer.json on the root directory

Hi Everyone,

I wonder if there's a way to include the composer.json file on the root directory, I'm having a little issue with our CI set-up.

(FEATURE) Add HTTPS redirect to nginx conf.

Since the configuration uses certs, it might be nice to add the following to the existing configuration:

server {
    listen      80;
    listen [::]:80;
    server_name ${DOMAIN};
    return 301 https://$host$request_uri;  #HTTPS redirect
}

Issues with trust-cert.sh under ArchLinux and Manjaro

I have issues with trust-cert.sh under ArchLinux and Manjaro:
Path "/usr/local/share/ca-certificates/" doesn't exist on these distro :/
I have this error :
cp: target '/usr/local/share/ca-certificates/' is not a directory

sudo update-ca-certificates doesn't exist :/

For first issue, I did not find a solution.
I tried with : /etc/ca-certificates/trust-source/anchors/ but isn't working :/

I found a solution for second issue by replace update-ca-certificates with trust extract-compat The packages : ca-certificates ca-certificates-mozilla ca-certificates-utils openssl are installed

Thank you, otherwise the rest works fine ^^

Error establishing database connection.

Great tutorial!

Everything works except the Wp install can't connect to the database.

https://myapp.local

Gives me

Warning: mysqli_real_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/html/web/wp/wp-includes/wp-db.php on line 1612 Warning: mysqli_real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/html/web/wp/wp-includes/wp-db.php on line 1612

php_network_getaddresses: getaddrinfo failed: Name or service not known

or

Warning: mysqli_real_connect(): (HY000/2002): Connection refused in /var/www/html/web/wp/wp-includes/wp-db.php on line 1612
Connection refused
Error establishing a database connection
This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at db:3306. This could mean your host’s database server is down.

Are you sure you have the correct username and password?
Are you sure that you have typed the correct hostname?
Are you sure that the database server is running?

All DB credentials are the same. Changed everything to 'wordpress' but the wp install still wont connect. Is there a way to see what the containers are setting the login info as? Or see the generated wp-config.php settings?

I tried adding a phpmyadmin container. It was visible but couldn't log in.

This is by far the closest tutorial for what i need & would be amazing to get over this final hurdle. I've been using docker a lot and not had this issue before. However none of my previous projects use a local domain or ssl.

D.

docker-compose.yml

version: '3.6'
services:
  nginx:
    image: nginx:latest
    container_name: myapp-nginx
    ports:
      - '8084:80'
      - '443:443'
    volumes:
      - ./nginx:/etc/nginx/conf.d
      - ./src:/var/www/html:rw,cached
      - ./certs:/etc/certs
    depends_on:
      - wordpress
    restart: always

  db:
    image: mysql:5.7
    container_name: myapp-mysql
    volumes:
       - './data/db:/var/lib/mysql:delegated'
    environment:
      - MYSQL_ROOT_PASSWORD=wordpress
      - MYSQL_DATABASE=wordpress
      - MYSQL_USER=wordpress
      - MYSQL_PASSWORD=wordpress
    restart: always
    # ports:
    #   - '3306:3306'

  wordpress:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: myapp-wordpress
    volumes:
      - ./src:/var/www/html:rw,cached
      - ./config/php.ini:/usr/local/etc/php/conf.d/php.ini
    environment:
      - WORDPRESS_DB_NAME=wordpress
      - WORDPRESS_TABLE_PREFIX=wp_
      - WORDPRESS_DB_HOST=db:3306
      - WORDPRESS_DB_PASSWORD=wordpress
    depends_on:
      - db
    restart: always

  composer:
    image: composer/composer
    container_name: myapp-composer
    working_dir: /var/www/html
    restart: 'no'
    volumes:
      - ./src:/var/www/html:rw,cached

.env

DB_HOST=db:3306
DB_NAME=wordpress
DB_USER=wordpress
DB_PASSWORD=wordpress
# DB_PREFIX=wp_

WP_ENV=development
WP_HOME=https://myapp.local
WP_SITEURL=${WP_HOME}/wp

# Generate your keys here: https://roots.io/salts.html
AUTH_KEY='generateme'
SECURE_AUTH_KEY='generateme'
LOGGED_IN_KEY='generateme'
NONCE_KEY='generateme'
AUTH_SALT='generateme'
SECURE_AUTH_SALT='generateme'
LOGGED_IN_SALT='generateme'
NONCE_SALT='generateme'

feedback during build

docker-compose up -d --force-recreate --build
Creating network "wordpress-nginx-docker-compose_default" with the default driver
Building wordpress
Step 1/4 : FROM urre/wordpress-nginx-docker-compose-image
 ---> c3797de1da74
Step 2/4 : RUN curl -o /bin/wp-cli.phar https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
 ---> Using cache
 ---> 2c780d637b20
Step 3/4 : RUN chmod +x /bin/wp-cli.phar
 ---> Using cache
 ---> 632824aec449
Step 4/4 : RUN cd /bin && mv wp-cli.phar wp
 ---> Using cache
 ---> 7a7b5fb81401

Successfully built 7a7b5fb81401
Successfully tagged wordpress-nginx-docker-compose_wordpress:latest
Creating myapp-composer  ... done
Creating myapp-mysql    ... done
Creating myapp-wordpress ... done
Creating myapp-nginx     ... done

Cannot setup SSL on Chromium

After following all the steps, I get a .key and .crt files in the certs folder, but when importing in chromium it says the private key is missing or invalid.

Problem when running compose comment

Creating wordpress-nginx-docker-compose_composer_run ... done
> php -r "copy('.env.example', '.env');"
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.

  Problem 1
    - roots/wordpress-core-installer is locked to version 1.1.0 and an update of this package was not requested.
    - roots/wordpress-core-installer 1.1.0 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.
  Problem 2
    - roots/wordpress-core-installer 1.1.0 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.
    - roots/wordpress 5.5.1 requires roots/wordpress-core-installer >=1.0.0 -> satisfiable by roots/wordpress-core-installer[1.1.0].
    - roots/wordpress is locked to version 5.5.1 and an update of this package was not requested.

You are using Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report a plugin-issue to ask them to support Composer 2.

APP_NAME variable not set

hello,

When I run docker-compose up -d, I get the following warning:
WARNING: The APP_NAME variable is not set. Defaulting to a blank string.

Then a number errors appear when trying to create mysql.

--

Note that I've set the APP_NAME in the .env file.

Please help, thanks.

Nginx string interpolation seems to fail in docker-compose.yml

In the docker-compose.yml using version:"3.6", there is a line of code as follows:

entrypoint: /bin/bash -c 'cat /tmp/default.template | sed "s/\\\$$domain/${DOMAIN}/g" > /etc/nginx/conf.d/default.conf && nginx -g "daemon off;"'

${DOMAIN} is not appropriately substituted, and simply results in a default.conf nginx file that replaces all instance of $domain with blanks.

Hopefully I'm missing something obvious. 😣

Error Loading extension section SAN

Hi, I downloaded the code earlier today when I tried to run the create-cert.sh file in VS Code on macOS, I get the following error...

Error Loading extension section SAN
4492713580:error:22FFF06D:X509 V3 routines:func(4095):invalid null value:/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-47.11.1/libressl-2.8/crypto/x509v3/v3_utl.c:355:
4492713580:error:22FFF069:X509 V3 routines:func(4095):invalid extension string:/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-47.11.1/libressl-2.8/crypto/x509v3/v3_conf.c:149:name=subjectAltName,section=DNS:
4492713580:error:22FFF080:X509 V3 routines:func(4095):error in extension:/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-47.11.1/libressl-2.8/crypto/x509v3/v3_conf.c💯name=subjectAltName, value=DNS:

MySQL server has gone away

Hi!
Thanks for sharing your work — it's a truly amazing, and well-designed template
but also quite a complex one.
Unfortunately, I've run into some trouble during the setup...
I'm running Ubuntu. I've done everything from the Readme.md, but finally got:

Warning: Packets out of order. Expected 0 received 1. Packet size=69 in
/var/www/html/web/wp/wp-includes/wp-db.php on line 1633
Warning: mysqli_real_connect(): MySQL server has gone away in 
/var/www/html/web/wp/wp-includes/wp-db.php on line 1633
Warning:  mysqli_real_connect(): Error while reading greeting packet. PID=6 in 
/var/www/html/web/wp/wp-includes/wp-db.php on line 1633
Warning:  mysqli_real_connect(): (HY000/2006): MySQL server has gone away in 
/var/www/html/web/wp/wp-includes/wp-db.php on line 1633

MySQL server has gone away

phpMyAdmin is reachable, but when trying to log in, the same errors pop up.
Would you mind helping me to find out what's going on?

How to configure for multisite network?

Thanks for a great project @urre.
Do you have any experience on how to configure your project for WP Multisite?

Roots claim Bedrock is multisite compatible and that you don't need to do anything is using subfolders as I do. https://roots.io/docs/bedrock/master/installation/#getting-started
Yet I cannot get this to work after having tried various tweaks.

Here is the Multisite setup I use for a well functioning standard project without Bedrock.
Here I've just adapted it for use in application.php instead of config.php. Any idea how I'd need to tweak things to make multisite work with your project structure?

Would be grateful for any help.

/* application.php */
Config::define( 'WP_ALLOW_MULTISITE', true );
Config::define('MULTISITE', true);
Config::define('SUBDOMAIN_INSTALL', false);
Config::define('DOMAIN_CURRENT_SITE', 'mydomain');
Config::define('PATH_CURRENT_SITE', '/');
Config::define('SITE_ID_CURRENT_SITE', 1);
Config::define('BLOG_ID_CURRENT_SITE', 1);
Config::define('WP_ALLOW_REPAIR', true);
Config::define('WP_HOME','http://mydomain');
Config::define('WP_SITEURL','http://mydomain');
# .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
</IfModule>

Port Issues

Hi, thanks for the awesome repo. I followed the instructions and at the end, I am getting this port issue after running the docker-compose up -d command.

Screen Shot 2020-05-05 at 10 01 34 PM

Not sure how to move forward from this. Help please !

Error establishing a database connection

Hi @urre thanks for creating this repo.

I have run the steps and have ran docker compose up -d and everything seems fine but I do get the above error
from Wordpress when I attempt to load the admin.

I also see that the composer container is not running should it be?

thanks in advance for your help

I include the env file below

IP=127.0.0.1
APP_NAME=themetest
DOMAIN=themetest.local
DB_HOST=mysql
DB_NAME=themetest
DB_ROOT_PASSWORD=password
DB_TABLE_PREFIX=wp_

wp-cli errors

docker exec -it myapp-wordpress bash
/var/www/html# wp search-replace https://olddomain.com https://myapp.local --allow-root

returns this error -

Error: The site you have requested is not installed.
Run `wp core install` to create database tables.

And running -

/var/www/html# wp

Error: YIKES! It looks like you're running this as root...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.