converting standard wordpress into a SQLite powered multi user blogging platform


wordpress is one of the very popular blogging platforms which is not only free but also released as a open source project. officially wordpress runs only on mysql. so if you want to run it with SQLite, you will not find any official support for that. but fortunately justin addie has written an excellent plugin (pdo for wordpress) which will work as an adapter just between the wordpress DAL and mysql. this plugin hooks all the SQL queries which are sent to execute on mysql by wordpress, convert those into PDO compatible statements and then execute them. currently PDO for WordPress is written to work smoothly with mysql and sqlite.

on the other hand, WPMU (wordpress mu or multi-user) is another version of wordpress which uses the core wp with some modifications and convert any single user wordpress blog into a multi user blogging platform. in this blog post i will show you how you can convert a general installation of wordpress into multi user blogging platform (like WPMU, but fully featured) and take advantage of SQLite :) – so let the fun begin.

step 1: check if your domain support wildcard A record. if so, then create a “*” A record and point it to your server. if it works, now you can point http://.. to your server :) – that is very much required. alo please check that in your webserver it has “pdo” and “pdo_sqlite” php extensions enabled. you can check that using phpinfo(); – needless to say, you need PHP5

step 2: install wordpress

step 3: install pdo for wordpress
download the pdo_for_wordpress plugin. inside it you will find one file named “db.php” and a folder named “pdo”.
put the db.php inside “wp-content” directory
now put the “pdo” folder inside “wp-content” directory

open wp-config.php
find the following line

define('DB_COLLATE', '');

add the following line just below that line

define('DB_TYPE', 'sqlite'); 

step 4: create a directory named “userdb” anywhere in your server, make sure to give it write access. in this example we’ve created one as /opt/userdb – DONT FORGET TO ASSIGN WRITE PERMISSION to this “userdb” directory.

step 5: now we will be modifying that “db.php” which we had copied into “wp-content” folder.

find the line in db.php where it says

define ('FQDBDIR', ABSPATH .'/wp-content/database/');
define ('FQDB', FQDBDIR .'MyBlog.sqlite');

now change those lines as below

define ('FQDBDIR', '/opt/userdb/');
define ('FQDB', FQDBDIR ."{$_SERVER['SERVER_NAME']}.sqlite");

and tada – you are done. now point your browser to any subdomain under your domain and it will comeup with registration page. register some blog and check it out :) (at the bottom of this post you can find the link of a live demo)

now you can extract some themes in the wp-content/themes folder or some plug-ins into wp-content/plugins folder. all users will be able to choose only from those pre installed themes and plugins, and everyones data and configuration will remain separate from others, as everyone is running from their own database. set only “read” access to “wp-content/themes” and “wp-content/plugins” folders to avoid any security loophole.

happy blogging.

[note - i've checked it against latest wordpress 2.8.4 and it runs okay]

To check out a live example of a running wordpress 2.8.4 on SQLite – click on http://anything.twistats.com/wp/ – and to create your own – just go to this url http://<any_subdomain&gt;.twistats.com/wp and register your one :) . You can select from six pre installed themes too :)

About these ads

19 thoughts on “converting standard wordpress into a SQLite powered multi user blogging platform

  1. very helpful and valuable information, Thanks for this boss.

    but if this is work using PDO then it may be also works with other database also (PDO works with a lot likt Microsoft SQL Server , Sybase, Oracle etc )

  2. @arifulnr – yes it would work, but you need to write an adapter object to convert mysql specific queries for that DB again.

    currently the package has adapters for only mysql and sqlite.

    interested in writing one for pgsql? :) that would be great!

  3. Pingback: Hasin Hayer’s Blog: Converting standard wordpress into a SQLite powered multi user blogging platform | Webs Developer

  4. Thanks Hasin vai for this information, i will google it for that. but i have another problem and need your help. i am now studying your facebook book but i find the facebook application Edit Settings section is changes during last 1 and 1/2 (as you book published may 2008) i works on facebook tools a lot and try it on a real server but fail to configure the the application so that it works on facebook . can you write a post for all of us on configuring facebook application.

  5. from the SQLite website:

    Website Database. Because it requires no configuration and stores information in ordinary disk files, SQLite is a popular choice as the database to back small to medium-sized websites.

    If your blog becomes bigger you should use MySQL… I don’t think there is something wrong with the default WP setup

  6. Hi Olaf

    Yeah, MySQL is best choice for a bigger blog, but still, i think SQLite still will be able to manage quite a load.

    And by the way, SQLite is able to handle moderate load in a medium level of concurrency.

    Porting WP to SQLite is fun :) – so it’s just a fun project :)

  7. There are a number of reasons why a user might want to use SQLite in place of mysql. Off the top of my head:

    1. portability (just pick up the sqlite file and go)
    2. backup (no db scripts, just ftp the sqlite file)
    3. their host has a generous file space limit but lousy mysql limits (1 & 1 uk for example, on my package, allows gigs of file space but only 100MB of mysql db).
    4. running the blog on a NAS or hacked router which is underpowered for running mysql
    5. looking for a really low memory footprint

    there are probably more …

    i am running into issues bringing PDO for WordPress up to speed with 2.9 at the moment. i am going to have to play quite a bit with the install routine which is aggravating.

    a fellow internaute has written a driver for MSsql if anyone is interested. i suspect that the SQLite driver will work fine for postgres. not tested though. perhaps the create statement rewrites might need a bit of tweaking.

    on benchmarking: we do a lot of PCRE work on queries, and PDO is much less efficient than native mysql_* calls (in most cases), so we are overall slower the native. SQLite benchmarks on its own very close to mysql for normal-mid-range applications, however. I have not noticed any major performance problems on any of my sqlite blogs, but then again the internet latency is so long compared to programme execution that it hardly matters until your site gets _really_ busy!

    best
    Justin

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s