User Docker to Create WordPress Site with SQLiter (No MySQL Needed)
Deploying WordPress is not a easy task which you will need to install web service, database and all dependencies. And usually you will need to deal with MySQL/MariaDB installation and be familiar with creating db and users, which make it even more complex and consume more resources by running DB in backend.
Can we using sQLite to run WordPress? Answer is yes. Here is one project I found from Github and DockerHub: WordPress with SQLite, ready to use out of the box.
- Github: https://github.com/soulteary/docker-sqlite-wordpress
- Based on official image, Easier and more sustainable solution.
- DockerHub Page: https://hub.docker.com/r/soulteary/sqlite-wordpress
Benefits to use SQLite:
On the lower end of the spectrum, there are small and simple sites. These are numerous and consist of all the blogs, company pages, and sites that don’t have thousands of users or thousands of posts, etc. These websites don’t always need the complexities of a MySQL/MariaDB database. The requirement of a dedicated MySQL server increases their hosting cost and the complexity of installation. On lower-end servers, it also decreases performance since the same “box” needs to cater to both a PHP and a MySQL/MariaDB server.
SQLite is the perfect fit:
- It is the most widely used database worldwide
- It is cross-platform and can run on any device
- It is included by default on all PHP installations (unless explicitly disabled)
- WordPress’s minimum requirements would be a simple PHP server, without the need for a separate database server.
- SQLite support enables lower hosting costs, decreases energy consumption, and lowers performance costs on lower-end servers.
Installation Pre-requirements
Free resources you might need to complete this docker project:
- Server: Oracle Free VPS, Azure Free VPS, Google Cloud Free VPS, and others
- Create a Free Tier Windows/Linux Azure VPS VM
- [Free VPS] GCP (Google Cloud Platform) Tips and Tricks (Free 16G RAM, 4 vCPU VPS)
- System: Cloud Vendor Ubuntu, Debian, or DD an original version
- SWAP size increase:
- wget https://raw.githubusercontent.com/51sec/swap/main/swap.sh && bash swap.sh
- Enable Password ssh login
- Enable BBR
- systemctl restart docker
- Domain: (Optional) EU.ORG to get a free one, free Cloudflare account to manage your domain
- Confirm port has not been used (you might need to install lsof using command : apt install lsof):
- lsof -i:8088
- Check cpu & memory info
- lscpu
- cat /proc/cpuinfo
- htop / top / free
Pre-installed services:
- Docker,
- apt update
- apt install docker.io
- apt install docker-compose
- apt upgrade docker.io
- mkdir /root/data/docker_data/<docker_name>
- Docker-Compose (Using Ubuntu OS for the commands)
- Docker-compose down
- Optional command : use following command to backup your Docker data. You might need to change your folder name based on your docker configuraiton
- cp -r /root/data/docker_data/<docker_name> /root/data/docker_data_backup/<docker_name>
- docker-compose pull
- docker-compose up -d
- docker image prune
- Portainer (Optional)
- docker volume create portainer_data
- docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
- Install some applications: apt install wget curl sudo vim git (Optional)
- aapanel with Nginx (Optional)
- Nginx Proxy Manager (Optional)
- Install screen (Optional)
- Install screen (Depends on the Linux Distribution if it came pre installed or not) : yum install screen
- Initiate a Screen : screen or screen -S <screen name> <command to execute>
- Detach from the screen : "CTRL+A,D" not "CTRL+A+D"
- List all the screen currently working : screen -ls
- Reattach to a screen : screen -r <session number> or screen -r <screen name>
- Kill specific screen: screen -X -S <screen name> quit
- Kill all screens : pkill screen
- Monitoring Usage
- Docker stats
Steps
1 Get your own VPS, which you can get one from Azure, GCP or Oracle
- [Free VPS] Create a Free Tier Windows/Linux Azure VPS VM
- Run Free Arm-based Oracle Linux (Install Docker/Docker Compose/Portainer/Ubuntu Virtual Desktop)
- [Free VPS] GCP (Google Cloud Platform) Tips and Tricks (Free 16/8G RAM, 4/2 vCPU VPS)
- Create a MySQL Computer Engine VM Instance Using Ubuntu in Google Cloud
2 Update system, install docker and docker-compose
We are using Ubuntu 22.04 LTS version as an example.
- apt update
- apt install docker.io
- apt install docker-compose
3 Lauch Docker which has WordPress and SQlite
Method 1: Use the following command to quickly launch the wordpress with port 8080
docker run --rm -it -d -p 8080:80 -v `pwd`/wordpress:/var/www/html soulteary/sqlite-wordpress:6.5.2
Method 2: You can also use docker compose to start wordpress:
version: '3' services: wordpress: image: soulteary/sqlite-wordpress:6.5.2 restart: always ports: - 8080:80 volumes: - ./wordpress:/var/www/html
Save the file as docker-compose.yml
and then execute docker compose up
, then use browser access to localhost:8080
.
4 Open Firewall Rule in your cloud environment for port 8080
Browser to open url https://<VPS Public IP>:8080
Use Your Own Domain for your WordPress
Videos
References
- https://hub.docker.com/r/soulteary/sqlite-wordpress
- PDO (SQLite) For WordPress - https://wordpress.org/plugins/pdo-for-wordpress/
- Let’s make WordPress officially support SQLite
- https://soulteary.com/2024/04/
21/wordpress-sqlite-docker- image-packaging-details.html - https://soulteary.com/2024/04/17/say-goodbye-to-mysql-docker-sqlite-wordpress.html
共有 0 条评论