Giter Club home page Giter Club logo

docker-compose-wordpress's Introduction

docker-compose-wordpress

A simplified yet refined Docker Compose workflow that sets up a LEMP network of containers for local WordPress development. If you'd like more interactive info, there's a video tutorial that walk you through setup and usage of this environment.

Usage

To get started, make sure you have Docker installed on your system, and then clone this repository.

Next, navigate in your terminal to the directory you cloned this, and spin up the containers for the web server by running docker-compose up -d --build site.

After that completes, follow the steps from the src/README.md file to get your WordPress installation added in (or create a new blank one).

Bringing up the Docker Compose network with site instead of just using up, ensures that only our site's containers are brought up at the start, instead of all of the command containers as well. The following are built for our web server, with their exposed ports detailed:

  • nginx - :80
  • mysql - :3306
  • php - :9000

An additional container is included that lets you use the wp-cli app without having to install it on your local machine. Use the following command examples from your project root, modifying them to fit your particular use case.

  • docker-compose run --rm wp user list

Persistent MySQL Storage

By default, whenever you bring down the Docker network, your MySQL data will be removed after the containers are destroyed. If you would like to have persistent data that remains after bringing containers down and back up, do the following:

  1. Create a mysql folder in the project root, alongside the nginx and src folders.
  2. Under the mysql service in your docker-compose.yml file, add the following lines:
volumes:
  - ./mysql:/var/lib/mysql

docker-compose-wordpress's People

Contributors

aschmelyun 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

docker-compose-wordpress's Issues

wp-cli exited (0)

Hi there!

I am using this repo. for my local dev setup. Somehow I run into this issue where wp-cli shows (grey icon showing the container is not running. It says EXITED (0).)

If I remove the wp-cli container everything else works fine.

Screenshot:
image

When I click the wp-cli container to see the logs show this
image

I appreciate it if you could help.

localhost is accessible instead of wordpress-docker.test

Hi there,

I've followed along with these settings but I am not able to access the installation on 'wordPress-docker.test' but I can access the localhost to install.

I am using Ubuntu 20 LTS on my windows 10 over WSL 2.

Localhost does not use the SSL either.

Nginx php config errors

I keep getting some errors when I'm trying to run this.

~/test$ docker-compose up

Creating network "test_default" with the default driver
Creating test_php_1 ... done
Creating test_mysql_1 ... done
Creating test_nginx_1 ... done
Attaching to test_mysql_1, test_php_1, test_nginx_1
mysql_1 | 2021-04-11 07:24:00+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.
nginx_1 | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
nginx_1 | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
mysql_1 | 2021-04-11 07:24:00+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
mysql_1 | 2021-04-11 07:24:00+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.
nginx_1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
php_1 | [11-Apr-2021 07:24:01] NOTICE: fpm is running, pid 1
mysql_1 | 2021-04-11T07:24:00.576418Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.23) starting as process 1
nginx_1 | 10-listen-on-ipv6-by-default.sh: Getting the checksum of /etc/nginx/conf.d/default.conf
mysql_1 | 2021-04-11T07:24:00.585796Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
nginx_1 | 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf differs from the packaged version
mysql_1 | 2021-04-11T07:24:00.764293Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
nginx_1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
php_1 | [11-Apr-2021 07:24:01] NOTICE: ready to handle connections
nginx_1 | /docker-entrypoint.sh: Configuration complete; ready for start up
mysql_1 | 2021-04-11T07:24:00.878672Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
mysql_1 | 2021-04-11T07:24:00.959117Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
mysql_1 | 2021-04-11T07:24:00.959323Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
mysql_1 | 2021-04-11T07:24:00.965843Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
mysql_1 | 2021-04-11T07:24:00.995846Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.23' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
nginx_1 | 2021/04/11 07:24:07 [crit] 30#30: *1 connect() to unix:/tmp/php-cgi.socket failed (2: No such file or directory) while connecting to upstream, client: 172.18.0.1, server: wordpress-docker.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-cgi.socket:", host: "localhost"
nginx_1 | 2021/04/11 07:24:07 [warn] 30#30: *1 upstream server temporarily disabled while connecting to upstream, client: 172.18.0.1, server: wordpress-docker.test, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-cgi.socket:", host: "localhost"
nginx_1 | 2021/04/11 07:24:07 [error] 30#30: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 172.18.0.1, server: wordpress-docker.test, request: "GET / HTTP/1.1", upstream: "fastcgi://172.18.0.3:9000", host: "localhost"
php_1 | 172.18.0.4 - 11/Apr/2021:07:24:07 +0000 "GET /index.php" 404
nginx_1 | 172.18.0.1 - - [11/Apr/2021:07:24:07 +0000] "GET / HTTP/1.1" 404 27 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0" "-"

Nginx: Permission denied

Hello
I followed the instructions and the service ran completely. But when executing a domain address, Nginx has the following error:

nginx    | 2022/04/25 08:17:20 [error] 31#31: *4 "/var/www/html/index.php" is forbidden (13: Permission denied), client: xxxxxx, server: localhost, request: "GET / HTTP/1.1", host: "localhost"

My OS details:

Distributor ID:	Linuxmint
Description:	Linux Mint 20.3
Release:	20.3
Codename:	una

Nginx SSL error

I generated self-signed certs as per instructions:

nginx/certs/self-signed/wordpress-docker.test+5.pem
nginx/certs/self-signed/wordpress-docker.test+5-key.pem

and I referenced them in the nginx config:

    ssl_certificate /etc/nginx/certs/self-signed/wordpress-docker.test+5.pem;
    ssl_certificate_key /etc/nginx/certs/self-signed/wordpress-docker.test+5-key.pem;

but I'm getting this error when I build

2021/08/05 15:51:43 [emerg] 1#1: cannot load certificate "/etc/nginx/certs/self-signed/wordpress-docker.test+5.pem": BIO_new_file() failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/nginx/certs/self-signed/wordpress-docker.test+5.pem','r') error:2006D080:BIO routines:BIO_new_file:no such file)

nginx: [emerg] cannot load certificate "/etc/nginx/certs/self-signed/wordpress-docker.test+5.pem": BIO_new_file() failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/nginx/certs/self-signed/wordpress-docker.test+5.pem','r') error:2006D080:BIO routines:BIO_new_file:no such file)

nginx is not starting

Running below command give me below status of the containers and nginx is not up
$docker-compose ps
Name Command State Ports

mysql docker-entrypoint.sh mysqld Up 0.0.0.0:3306->3306/tcp,:::3306->3306/tcp, 33060/tcp
nginx /docker-entrypoint.sh ngin ... Exit 1
php docker-php-entrypoint php-fpm Up 9000/tcp

Remote SQL connection times out

I am getting a "Unable to connect to host 127.0.0.1, or the request timed out." with SQL pro. I've sniffed all my 3306 ports and docker is the only one running on that port. Am i missing something?

I have tried to connect using these credentials:

host: 127.0.0.1
username: wp
password: secret
port 3306

host: mysql
username: wp
password: secret
port 3306

Enable Imagick

New to using Docker for WP dev without using an app like Local. Thank you for providing such a thorough walk-through.

I was hoping you could provide info on how imagick could be enabled. I was able to get everything set up with a copy of an existing WP site. However, I received a warning that imagick wasn't installed while logged into the Dashboard. I've tried various methods of adding it in the php.docker file but I keep running into issues where it doesn't get installed or it causes some sort of gateway issue when it does.

You're making a very good yt tutorial about this topic!

But I've a question about the combination of wordpress container and nginx:
Can you explain how to config nginx (and maybe wordpress container itself) so that wordpress can be reached as in a sub directory?

I tried it with this config (and some others) but i cannot figure it out..

server {
  listen 443 ssl http2;
  server_name localhost mydomain.com;
 
  location /wpsubdir {
    rewrite ^/wp-admin/(.*)$ /$1 break;
    proxy_pass http://localhost:8081/;
    proxy_redirect http://localhost:8081/ /wpsubdir/;
  }
}

ERROR: Service 'php' failed to build

config.status: creating config.h
/bin/sh /usr/src/php/ext/mysqli/libtool --mode=compile cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/usr/src/php/ext/mysqli -DPHP_ATOM_INC -I/usr/src/php/ext/mysqli/include -I/usr/src/php/ext/mysqli/main -I/usr/src/php/ext/mysqli -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_CONFIG_H -fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -c /usr/src/php/ext/mysqli/mysqli.c -o mysqli.lo
make: /bin/sh: Operation not permitted
make: *** [Makefile:192: mysqli.lo] Error 127
ERROR: Service 'php' failed to build : The command '/bin/sh -c docker-php-ext-install mysqli pdo pdo_mysql && docker-php-ext-enable pdo_mysql' returned a non-zero code: 2

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.