Wordpress: Wordpress Environment for Multi-Site Setup

Created on 7 Jan 2017  路  7Comments  路  Source: docker-library/wordpress

Hi There,

I am new to creating and extending docker images. I would like to build a wordpress container with the multi-site feature. The current and usual one is the default wordpress setting.

Can you please direct me on how to go about it.

Thanks.

Most helpful comment

If you just need to deploy a WordPress multi-site instance, I'd recommend using this image as-is and then modifying the wp-config.php of your installed instance to include define( 'WP_ALLOW_MULTISITE', true );, as described over in https://codex.wordpress.org/Create_A_Network#Step_2:_Allow_Multisite.

If you instead need a repeatable image you can deploy in many places with Multisite pre-enabled, then you'll need to modify the file /usr/src/wordpress/wp-config-sample.php. Something like this _should_ do the trick:

FROM wordpress

RUN sed -r -e 's/\r$//' /usr/src/wordpress/wp-config-sample.php \
    | awk '/^\/\*.*stop editing.*\*\/$/ { print("define( \"WP_ALLOW_MULTISITE\", true );") } { print }' > temp.php \
    && chown --reference /usr/src/wordpress/wp-config-sample.php temp.php \
    && mv temp.php /usr/src/wordpress/wp-config-sample.php

All 7 comments

If you just need to deploy a WordPress multi-site instance, I'd recommend using this image as-is and then modifying the wp-config.php of your installed instance to include define( 'WP_ALLOW_MULTISITE', true );, as described over in https://codex.wordpress.org/Create_A_Network#Step_2:_Allow_Multisite.

If you instead need a repeatable image you can deploy in many places with Multisite pre-enabled, then you'll need to modify the file /usr/src/wordpress/wp-config-sample.php. Something like this _should_ do the trick:

FROM wordpress

RUN sed -r -e 's/\r$//' /usr/src/wordpress/wp-config-sample.php \
    | awk '/^\/\*.*stop editing.*\*\/$/ { print("define( \"WP_ALLOW_MULTISITE\", true );") } { print }' > temp.php \
    && chown --reference /usr/src/wordpress/wp-config-sample.php temp.php \
    && mv temp.php /usr/src/wordpress/wp-config-sample.php

Thank you so much for your reply. I was able to use your suggestion in the second paragraph. I couldn't get it done with the first advice as I could not locate the wp-config.php file. I will be glad if Can you please direct me on how to locate it?

In general, wp-config.php doesn't present in the image, it gets created by docker-php-entrypoint startup script during first run of the container. that's why you have to operate on wp-config-sample.php.

Thank you all for the reply. I am still having a bit of problem with wordpress multisite. I have been able to enable the multi site features. But whenever I create a new site, it doesn't allow me to access it ( It shows as a broken page). I can only access the main site in the multisite page. Is this because I am using docker? I am only allowed to use the sub directory form of creating multisite

That likely depends on how you're routing traffic to it -- how are your domain names set up? Do you have something like NGINX in front, or are you simply letting the WordPress container listen directly on port 80? Is traffic for all your domains being routed to the container appropriately?

Thank you for your reply. I am not using nginx, the wordpress container listens directly on port 80 and the database container listens on port 8181.
So the docker-compose file looks like this

wordpresscontainer:
 build: ./php/
 links:
  - wordpressdb:mysql
 ports:
 - 80:80
wordpressdb:
 image: mariadb
 environment:
  MYSQL_ROOT_PASSWORD: password
phpmyadmincontainer:
 image: corbinu/docker-phpmyadmin
 links:
 - wordpressdb:mysql
 ports:
 - 8181:80
 environment:
  MYSQL_USERNAME: root
  MYSQL_ROOT_PASSWORD: password

I don't understand your last question about traffice routed to the container. Also, the setup allows me to only use sub-directory for the multi-site setup.

Thanks and look forward to your reply.

Sorry for the delay. The only thing I can recommend from here is reading through https://codex.wordpress.org/Create_A_Network and making sure you've followed the steps as described.

In the future, these sorts of questions/requests would be more appropriately posted to the Docker Community Forums, the Docker Community Slack, or Stack Overflow (or even the WordPress forums, to try and catch more WordPress users than these Docker forums might).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chrissound picture chrissound  路  5Comments

charltones picture charltones  路  5Comments

uda picture uda  路  4Comments

andheiberg picture andheiberg  路  5Comments

ptrdlbrg picture ptrdlbrg  路  5Comments