Giter VIP home page Giter VIP logo

wordpress-sqlite's Introduction

wordpress-sqlite

Lightweight Wordpress on Alpine with php-fpm ondemand and SQLite instead of MySQL.

docker pull milanb/wordpress-sqlite

Docker Hub milanb/wordpress-sqlite

Can be used in conjunction with wordpress-nginx (Docker Hub milanb/wordpress-nginx) to provide a full lightweight Wordpress solution.

Example docker-compose.yml for both:

version: '2'
services:
    wp:
        image: milanb/wordpress-sqlite
        environment:
            - WP_HOME=https://mysite.com
            - WP_SITEURL=https://mysite.com
        volumes:
            - db:/var/www/db
            - uploads:/var/www/html/wp-content/uploads
        restart: always
    http:
        image: milanb/wordpress-nginx
        links:
            - wp:wordpress
        volumes_from:
            - wp
        ports:
            - "8081:80"
volumes:
    db:
        external: true
    uploads:
        external: true

Migrating an existing website

  1. Tar/Zip up the web root directory e.g. /var/www/html
  2. Get a dump of the MySQL database for example with mysqldump
  3. Use mysql2sqlite to convert your MySQL dump to a new SQLite database
  4. Change the domain name in ingress.yaml and then apply to a new namespace with kubectl apply -f kubernetes/
  5. When the pod is up and running, copy your backups into the container with commands like
kubectl cp -c wordpress db.db wordpress-0:/var/www/db/
kubectl cp -c wordpress backup.zip wordpress-0:/var/www/
  1. You can then "exec" into the container with kubectl exec -it -c wordpress wordpress-0 -- /bin/bash
  2. Now you're in the container you need to ensure that the database has the right owner with chown www-data. /var/www/db/db.db
  3. Extracting the backup is a little more fiddly but you can do something like
rm -r *
mv ../backup.zip .
unzip backup.zip
rm backup.zip
chown -R www-data. .
  1. You now need to modify your old Wordpress installation to use SQLite. First copy the driver PHP file to the right location with cp /usr/src/wordpress/wp-content/db.php wp-content/
  2. You will now need to edit the wp-config.php file. You can either use vi in the container for this, or kubectl cp it out, edit it in your favourite editor and then kubectl cp it back in. Just make sure it is still owned by www-data:www-data. For my environment I had to remove the DB_NAME, DB_USER, DB_PASSWORD and DB_HOST definitions and add in the following lines
define('DB_FILE', 'db.db');    
define('DB_DIR', '/var/www/db/');   
  1. Because I'm using HTTPS behind a Kubernetes Ingress I also found I had to add these lines to wp-config to get everything working correctly
// Reverse proxy https fix
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
    $_SERVER['HTTPS'] = 'on';
if (isset($_SERVER['HTTP_X_FORWARDED_HOST']))
    $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];

wordpress-sqlite's People

Contributors

milanboers avatar cablespaghetti avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.