Using Devilbox for Local WordPress Development

Using Devilbox for Local WordPress Development

Amazing!

HOST_PATH_HTTPD_DATADIR = e
HTTPD_DOCROOT_DIR = x
TLD_SUFFIX = loc
TIMEZONE = UTC

Why not use Docker Desktop?

  1. Maybe I will use Podman in future inside WSL2
  2. Decrease in memory consumption; five times as per source

Using Docker in WSL2 without Docker Desktop

Almost exactly follow this guide.

  1. Remove Docker completely from Windows
# uninstall in normal way

# remove residues if exist
rmdir "%ProgramFiles%\\Docker" /s /q
rmdir "%ProgramData%\\DockerDesktop" /s /q
rmdir "%USERPROFILE%\\.docker" /s /q
rmdir " FILE%\\AppData\\Local\\Docker" /s /q
rmdir "%USERPROFILE%\\AppData\\Roaming\\Docker" /s /q
rmdir "%USERPROFILE%\\AppData\\Roaming\\Docker Desktop" /s /q
  1. Remove Docker completely from WSL2 Complete cleanup Linux guide

    # uninstall old versions
    sudo apt purge -y docker.io docker-compose containerd runc
    sudo apt purge -y docker docker-engine docker-ce docker-ce-cli containerd.io
    
    # delete all residues
    sudo rm -rf /var/lib/docker /var/lib/containerd /etc/docker ~/.docker /etc/apparmor.d/docker /var/run/docker.sock /usr/local/bin/docker-compose
    sudo groupdel docker
    
  2. Install Docker in WSL2 from official Docker repository It is similar to official setup

    # set up the repository
    sudo apt update && sudo apt -y upgrade && sudo apt autoremove --purge
    
    sudo apt install -y apt-transport-https ca-certificates curl gnupg-agent 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 $(lsb_release -cs) stable"
    
    # install docker engine
    sudo apt update
    sudo apt install docker-compose # this will install everything
    
    # verify
    sudo docker-compose -v
    sudo service docker start
    sudo docker version
    sudo docker run hello-world
    

We actually don’t need Docker Desktop to run Docker inside WSL2 Install Docker on Windows (WSL) without Docker Desktop - DEV Community 👩‍💻👨‍💻

Docker on Windows (WSL 2) without Docker Desktop : devops

What is Podman?

Using podman instead of docker on Windows Subsystem for Linux (WSL 2) - DEV Community 👩‍💻👨‍💻 Podman Podman is pretty much a drop-in replacement for Docker when it comes to running images.

Why Podman is worth a look

Docker runs on a client-server architecture, while Podman runs on a daemonless architecture. The Podman architecture by contrast allows you to run the containers under the user that is starting the container (fork/exec), and this user does not need any root privileges.

alias docker=podman


WSL2 Basic Config

From cmd execute:

# shutdown
wsl --shutdown
# ensure nothing is runnning
wsl -l --running

# create/edit WSL config file
notepad "%USERPROFILE%/.wslconfig"

Basic directives:

[wsl2]
memory=8GB  # limit memory inside WSL2
swap=0      # no swap file

Wordpress on Devilbox

cd ~
git clone https://github.com/cytopia/devilbox
cd devilbox
cp env-example .env

# configure some interesting variables
id -u; id -g
grep -E "^HOST_PATH_HTTPD_DATADIR|^HTTPD_DOCROOT_DIR|^TLD_SUFFIX|^TIMEZONE|^NEW_" .env
vi .env

# grep -E "^PHP_MODULES_DISABLE" .env
# PHP_MODULES_DISABLE=xdebug

sudo docker-compose up -d
sudo docker-compose stop
sudo docker-compose rm -f





# so from now on
# once after boot
sudo service docker start
# start
cd ~/devilbox/
# sudo docker-compose up -d
sudo docker-compose up -d bind httpd php mysql redis memcd
# work inside devilbox environment
sudo ./shell.sh
# end
sudo docker-compose stop


cd /shared/httpd
mkdir "weihnachtszeit-dev.de" && cd "$_"
git clone https://github.com/WordPress/WordPress www

mysql -u root -h 127.0.0.1 -p -e "DROP DATABASE IF EXISTS wordpress_b; CREATE DATABASE wordpress_b CHARACTER SET utf8 COLLATE utf8_general_ci; GRANT ALL PRIVILEGES ON wordpress_b.* TO 'wordpress_8' IDENTIFIED BY 'tj7Bo#18PF' WITH GRANT OPTION"

wp db import dump.sql
wp search-replace 'weihnachtszeit-dev.de' 'weihnachtszeit-dev.loc' --all-tables --dry-run --report-changed-only --precise



wp search-replace 'mobilehr.rs' 'meritplan.loc' --all-tables --report-changed-only
# when I was using `--precise` it didn't replace some Oxygen values?




---



    cd ~/devilbox/cfg/vhost-gen/`
    cp nginx.yml-example-vhost nginx.yml
    # change this line: server_name *.__VHOST_NAME__;
    # server_name __VHOST_NAME__ *.__VHOST_NAME__;
    # Whenever you adjust nginx.yml, you need to restart the Devilbox
date 05. May 2021 | modified 13. May 2024
filename: 2021-05-05 Temp » 2021 Devilbox for Local WP Dev