Code Monkey home page Code Monkey logo

wordpress-docker-compose's Introduction

Deploy Wordpress on Localhost and in Production using Docker Compose

Related blog post:

The installation tool kit, provided here, include:

  • Nginx web server
  • MariaDB/MySQL used for Wordpress database
  • phpMyAdmin interface to connect to your MySQL database
  • WP-Cli: Wordpress Command Line Interface
  • Makefile directives for automatization.

You can automatically deploy a local docker wordpress site in 5 minutes using the following commands:

# Download a wordpress docker-compose example
git clone https://github.com/kassambara/wordpress-docker-compose
cd wordpress-docker-compose
# Build and start installation
docker-compose up -d --build

Visit your site at http://localhost and your database via phpMyAdmin at http://localhost:8080.

Default identification for your wordpress website admin:

  • Username: wordpress and
  • Password: wordpress

Default identification for the phpMyAdmin interface:

  • Username: root and
  • Password: password

Useful set of commands to know:

# Stop and remove containers
docker-compose down
# Build, and start the wordpress website
docker-compose up -d --build
# Reset everything
docker-compose down
rm -rf certs/* certs-data/* logs/nginx/* mysql/* wordpress/*

References

wordpress-docker-compose's People

Contributors

kassambara 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

wordpress-docker-compose's Issues

wpcli Makefile error in --title=${WORDPRESS_WEBSITE_TITLE}

Hi @kassambara ,

I'm using a Manjaro Linux - KDE Edition and I found an error when trying to run the make autoinstall. Please see below error.

⚙️ Configuring Wordpress parameters...
wp core install
--url=http://localhost
--title=My Blog Renamed 1
--admin_user=wordpress
--admin_password=wordpress
--admin_email=[email protected]
Error: Too many positional arguments: Blog Renamed 1
make: *** [/scripts/Makefile:5: configure] Error 1
make: *** [Makefile:16: autoinstall] Error 2

It seems that Makefile doesn't like spaces so I tried to add a " " with the variables from
--title=${WORDPRESS_WEBSITE_TITLE} to --title="${WORDPRESS_WEBSITE_TITLE}".

And it works so far but I'm not entirely sure if it's a good idea to enclose all variables in the Makefile with " ".

add quotation marks in the title and admin_user

Hi, please add quotation marks in the title and admin_user:

install: configure

configure:

	@echo "⚙️ Configuring Wordpress parameters..."
	wp core install \
		--url=${WORDPRESS_WEBSITE_URL_WITHOUT_HTTP} \
		--title="$(WORDPRESS_WEBSITE_TITLE)" \
		--admin_user="${WORDPRESS_ADMIN_USER}" \
		--admin_password=${WORDPRESS_ADMIN_PASSWORD} \
		--admin_email=${WORDPRESS_ADMIN_EMAIL}

	wp option update siteurl ${WORDPRESS_WEBSITE_URL}
	wp rewrite structure $(WORDPRESS_WEBSITE_POST_URL_STRUCTURE)

This doesn't work on production.

I'm following your tutorial to deploy Wordpress using Docker on a Ubuntu server.

It's important to mention that I already have two subdomains at this point, one for the Wordpress site and another for the phpMyAdmin site.

However the letsencrypt certificates seem to not be generated properly. I can access the website via http, but not https, and when I look at the certificate it doesn't look correct. In fact it doesn't seem to have one for my website.

[https://i.stack.imgur.com/38SzG.png](Image of how the "cert looks")

To make everything easier I created a script to run all the steps fast:

#!/bin/bash

web_dir=/srv/www
myusername=root
domain_name=subdomain.domain.com
website_folder=/srv/www/$domain_name

nginx_proxy_repo=https://github.com/kassambara/nginx-multiple-https-websites-on-one-server
nginx_folder=/srv/www/nginx-multiple-https-websites-on-one-server/nginx-proxy
final_nginx_folder=/srv/www/nginx-proxy

echo ---INSTALL REQUIRED COMPONENTS----
sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
sudo apt update
apt-cache policy docker-ce
sudo apt install docker-ce docker-compose git
sudo systemctl status docker

echo ---CREATE AND GIVE PERMISSIONS TO WEBSITES DIR----
sudo mkdir -p $web_dir
# 2. set your user as the owner
sudo chown -R $myusername $web_dir
# 3. set the web server as the group owner
sudo chgrp -R www-data $web_dir
# 4. 755 permissions for everything
sudo chmod -R 755 $web_dir
# 5. New files and folders inherit 
# group ownership from the parent folder
chmod g+s $web_dir

echo ---INSTALL NGINX PROXY----
git clone $nginx_proxy_repo $web_dir
rm -rf $web_dir/nginx-proxy/nginx.tmpl
curl -s https://raw.githubusercontent.com/jwilder/nginx-proxy/master/nginx.tmpl > $web_dir/nginx-proxy/nginx.tmpl
cd $web_dir
rm -rf your-website-one.com your-website-two.com README.Rmd .gitignore .Rbuildignore .git README.md

echo ---INSTALL WORDPRESS----
cd $web_dir
git clone https://github.com/kassambara/wordpress-docker-compose $domain_name

echo ---CONFIGURE DOCKER COMPOSE FOR ONLINEHOST----
cd $website_folder
mv docker-compose-onlinehost.yml docker-compose.yml

echo ---FINAL TOUCHES----
cd $website_folder
vi ./setup-onlinehost.sh
chmod +x setup-onlinehost.sh && ./setup-onlinehost.sh
vi .env
vi docker-compose.yml

cd $final_nginx_folder
docker network create nginx-proxy
docker-compose up -d

cd $final_nginx_folder
cd vhost.d
echo "client_max_body_size 64M;" > $domain_name

cd $website_folder
docker-compose up -d --build
docker-compose -f docker-compose.yml -f wp-auto-config.yml run --rm wp-auto-config

When the time comes I setup the setup-onlinehost.sh like this:

project_name="wordpress"
user_name="wordpress"
pass_word="wordpress"
email="[email protected]"
website_title="My Blog"
website_url="https://subdomain.domain.com"
phmyadmin_url="sqlsubdomain.domain.com"
env_file=".env"
compose_file="docker-compose.yml"

Then I remove the redirectnonwww container from the docker-compose.yml file since I don't want the redirect non-www to www behavior.

Then after everything is completed, I can access the websites over http but not over https. When I try to access it over https I receive a message about This connection is not private and the certificate seems to be wrong at this point.

Also If I let continue my browser to visit the website I got to the Nginx 500 Internal Server Error.

I'm not sure if I'm doing something wrong or if I should be doing something else that is not listed on the tutorial.

Thanks.

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.