sqlite3 for wordpress

running wordpress with sqlite is quick, easy, and can be much less system administration load as it eliminates the need for a separate database process.

here’s how to run wordpress with sqlite using aaemnnosttv’s drop-in.

set it up

  • extract it into your webroot (something like /var/www)
  • download db.php and add it to /var/www/yoursite/wp-content/
  • follow the normal setup instructions but skip the database fields
  • profit????

nginx config

adjust configs as needed. here’s an example for this site.

snippets/ssl/benharri.org includes the block from certbot that points to the right cert and key.

server {
        listen 80;
        server_name benharri.org;
        return 307 https://$server_name$request_uri;
}

server {
        listen 443 ssl;
        server_name benharri.org;
        include snippets/ssl/benharri.org;
        index index.php index.html;
        root /var/www/benharri.org;
        client_max_body_size 100M;
        location / {
                try_files $uri $uri/ /index.php?$args;
        }

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

        location ~* wp-config.php {
                deny all;
        }

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_intercept_errors on;
                fastcgi_pass unix:/run/php/php8.2-fpm.sock;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }

        location ~ /\.ht {
                deny all;
        }
}

Update: there’s a proposal in wordpress core to merge sqlite support: https://make.wordpress.org/core/2023/04/19/status-update-on-the-sqlite-project/. The recommended way to use sqlite is currently by using the official plugin: https://wordpress.org/plugins/sqlite-database-integration/.


Comments

Leave a Reply