Skip to content

Laradock as a base for Wordpress hosting

Notifications You must be signed in to change notification settings

DJviolin/laradock-wordpress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

laradock-wordpress

Installation

Add these lines to your hosts file:

127.0.0.1 laradock.test
127.0.0.1 *.laradock.test

This project can be used with any Linux/Mac environment with Docker installed. WSL2 + Docker Desktop is recommended for Windows users.

Prepare WSL2:

PS wsl --set-default-version 2
PS wsl --install --distribution Ubuntu
# Username: user
# Password: secret
PS wsl --set-default Ubuntu
PS wsl -l -v
PS wsl --update
$ sudo apt update && sudo apt upgrade -y

Usage

Enter project folder (for example in WSL2), actual path can be vari depending on your setup

$ cd /mnt/c/www-docker/laradock-wordpress

Copy .env file into it's place:

$ cp .env.example .env

You can define in ./.env file, which web server you want to use, apache2 or nginx. For shared hosting target environment, apache2 is preferred. Another diferrence is, nginx can only host a single site, while apache2 can host multiple sites.

# apache2 or nginx
WEBSERVER=apache2

You also need to define your websites. This is crucial for mass backup & restore shell scripts to work:

SITES=site1,site2
# Examine config
$ ./bin/compose.sh config

# Pull Laradock repository
$ ./bin/compose.sh preinstall

# Start docker-compose
$ ./bin/compose.sh up

# Bootstrap the environment
$ sudo mkdir -p ~/.laradock/backup
$ sudo chown -R $(id -u):$(id -u) ~/.laradock/backup
$ ./bin/compose.sh bootstrap

# Stop the service
$ ./bin/compose.sh down

# Stop the service and destroy everything
$ ./bin/compose.sh prune
# If you want to remove your database and project files, run this command
$ sudo rm -rf ~/.laradock
# To only cleanup Portainer
$ sudo rm -rf ~/.laradock/data/portainer_data

# Backup webserver files & databases
# TODO: copy .htaccess
$ ./bin/compose.sh backup_all

# Restore webserver files & databases
# First, you need to manually delete the project's folder in ~/.laradock/data/html
# then place your backups in ~/.laradock/backup
$ sudo mkdir -p ~/.laradock/backup
$ sudo chown -R $(id -u):$(id -u) ~/.laradock/backup
$ ./bin/compose.sh restore_all

# Backup single website
$ ./bin/backup_single_site.sh -s [sitename]

# Restore single website
$ ./bin/restore_single_site.sh -s [sitename] -l /mnt/[filepath]/backup_[filename].tar.gz

# WP CLI usage
# https://make.wordpress.org/cli/handbook/guides/running-commands-remotely/
$ docker exec laradock-workspace-1 wp --allow-root --help
$ docker exec laradock-workspace-1 wp --allow-root package install wp-cli/restful
$ docker exec laradock-workspace-1 wp --allow-root --http=mesziair.hu --user=mesziair rest user list

FileZilla settings for SFTP access

Create a link which pointing to insecure_id_rsa.ppk key inside Laradock's workspace folder.

FileZilla settings for SFTP access - General tab

FileZilla settings for SFTP access - Advanced tab

URLs

Reading

Laradock: documentation, repository

GitHub issues regarding this project

Self:

Others:

wp-content should be owned by www-data:

WSL2 slow filesystem performance: solution is to copy application files into WSL filesystem.

TODO

  • Implement Ansible deployment to the Raspberry Pi
  • Set UID:GID to 1000 in nginx image
  • Create production build from Laradock
  • Implement Varnish Cache with nginx: Article, Proxy Cache Purge, FakerPress

Misc

# Example to enter a running container
$ docker-compose exec workspace bash
$ docker exec -it {workspace-container-id} bash

GTMetrix optimization guides

About

Laradock as a base for Wordpress hosting

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published