-
Notifications
You must be signed in to change notification settings - Fork 0
FAQ
If you're using caching or optimization plugins such as Autoptimize or W3 Total Cache you should disable locally because they might create issues with CORS and Vite etc.
Well maybe but it's easier for other developers to install the project in the future if they have some starting point. If you don't like this, just remove the !database/wordpress.sql
from .gitignore
.
Because the official image includes all the basics WordPress requires. Image could very well be php:*-apache
etc. as well.
How to setup a multisite network
How to setup a multisite with path-based install. This guide assumes that the project contains a MySQL dump in database/wordpress.sql
.
- Read Before You Create A Network
- Change all strings with
localhost:8000
tolocalhost
and changeports: 8000:80
toports: 80:80
indocker-compose.yml
. E.g. make sure you don't have port in the dev url - Restart docker. Note that your new site is now located in localhost
- Run
docker-compose exec web bash -c "wp search-replace 'localhost:8000' 'localhost' --allow-root --network"
to replace all the old strings in database - Run
docker-compose exec web bash -c "wp search-replace 'localhost/wp' 'localhost' wp_options --allow-root --network"
so that the site root is set correctly - Do steps Allow Multisite and Installing a Network. Add the instructed line to
wp-config.php:~103
:
/**
* Setup multisite
*/
define('WP_ALLOW_MULTISITE', true);
- As instructed in step 6. make sure the following lines are in
wp-config.php:~103
&wp-config.example.php:~103
with the correct domain:
/**
* Setup multisite
*/
define('WP_ALLOW_MULTISITE', true);
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', getenv('WORDPRESS_ENV') == 'development' ? '127.0.0.1' : 'example.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
- As instructed in step 6. make sure the following lines are in
.htaccess
&.htaccess.example
:
# ======
# WordPress
# ======
# BEGIN WordPress
<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).*) wp/$2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ wp/$2 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress
- Change
define('WP_SITEURL', getenv('DEVELOPMENT_URL') . '/wp');
->define('WP_SITEURL', getenv('DEVELOPMENT_URL'));
in inwp-config.php
&wp-config.example.php
to prevent confusion. - Activate plugins you had to deactivate in step 6.
- At this time, in path-based installs you cannot remove the
/blog
slug without manual configuration to the network options in a non-obvious place. Make sure your permalinks are set as wanted with custom structure (e.g./articles/%postname%
) or you can remove the/blog
which is not recommended. - Update your database dump once you have created network and added sub blogs with
$ make db-commit
. Remember to commit all your changes.
In production my WordPress home is located in a subdir (e.g. mysite.com/myhome). How to make it work?
- In wp-config.php
- Change
define('WP_SITEURL', 'mysite.com/wp');
todefine('WP_SITEURL', 'mysite.com/myhome/wp');
- Change
define('WP_CONTENT_URL', 'https://' . $_SERVER['HTTP_HOST'] . '/wp-content');
todefine('WP_CONTENT_URL', 'https://' . $_SERVER['HTTP_HOST'] . '/myhome/wp-content');
- Change
define('ABSPATH', dirname( __FILE__ ) . '/wp/');
todefine('ABSPATH', dirname( __FILE__ ) . '/myhome/wp/');
- If using WPMS change
define('PATH_CURRENT_SITE', getenv('WORDPRESS_ENV') == 'development' ? '/' : '/');
todefine('PATH_CURRENT_SITE', getenv('WORDPRESS_ENV') == 'development' ? '/' : '/myhome/');
- Change
- In .env add your home dir to
PRODUCTION_WP_HOME
(e.g.PRODUCTION_WP_HOME=/myhome
) so that replacing databases works correctly - In .htaccess make sure rewritebase is
RewriteBase /myhome
(not needed in WPMS)
Try to add export COMPOSE_INTERACTIVE_NO_CLI=1
to your shell and if it works you should add it to your bash profile. https://github.com/docker/compose/issues/5696