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:
- 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.
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
Self Hosted Docker 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
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
Remove Docker and Related folders
- docker stop <Docker Name> # stop the docker but not remove anything.
- docker rm -f <Docker Name> # remove speficic container, but will not delete mapped volumes
- rm -rf /root/data/docker_data/<Docker Mapped Volumns> # remove all mapped volumes
Restrick Journal Log File Size:
- journalctl --vacuum-size=100M
- Limit it to 25M:
SystemMaxUse=25M
systemctl restart systemd-journald.service
sudo bash -c 'echo "SystemMaxUse=100M" >> /etc/systemd/journald.conf'
sudo systemctl restart systemd-journald
Enable IPv6 and Limit Log File Size (Ubuntu)
sudo sh -c 'truncate -s 0 /var/lib/docker/containers/*/*-json.log'
cat > /etc/docker/daemon.json << EOF
{
"log-driver": "json-file",
"log-opts": {
"max-size": "20m",
"max-file": "3"
},
"ipv6": true,
"fixed-cidr-v6": "fd00:dead:beef:c0::/80",
"eixperimental":true,
"ip6tables":true
}
EOF
Restart Docker service:
systemctl restart docker
Limit number of log files:
cat /etc/logrotate.d/rsyslog
/var/log/syslog
/var/log/mail.info
/var/log/mail.warn
/var/log/mail.err
/var/log/mail.log
/var/log/daemon.log
/var/log/kern.log
/var/log/auth.log
/var/log/user.log
/var/log/lpr.log
/var/log/cron.log
/var/log/debug
/var/log/messages
{
rotate 4
weekly
missingok
notifempty
compress
delaycompress
sharedscripts
postrotate
/usr/lib/rsyslog/rsyslog-rotate
endscript
}
You can change 4
to some other value, such as 1
, so that only one file is stored.
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
No comments:
Post a Comment