User Docker to Create Wordpress Site with SQLiter (No MySQL Needed) - NETSEC

Latest

Learning, Sharing, Creating

Cybersecurity Memo

Saturday, May 4, 2024

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.



 

Benefits to use SQLite:

Scenario:
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:


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


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

 

1  Create dns A record in your DNS admin center
I am using cloudflare. 


2 Use NPM (Nginx Proxy Manager) to create a proxyed host record


3 Enable SSL for your NPM 


4 Change Your Wordpress site settings.

Videos

 







References




No comments:

Post a Comment