Spencer Bliven

Thoughts and Research

WordPress with Sqlite on PHP 5.1

November 12, 2010 | Posted in Metablog, Tagged , ,

After a long plod, I finally got wordpress running on acsweb! This is exciting, since it means it is possible to comment on posts, link to them, google for them, etc. Setting up wordpress was made challenging at every turn by my crappy UCSD server, which is outdated or badly configured in a number of respects:

  • No MySQL, so I had to use the PDO plugin with a Sqlite database
  • PHP 5.1, which should be compatible with PDO, but is missing the preg_last_error() function
  • Error logging and printing is disabled, making discovering the previous error an hours-long debugging process

For anyone else trying to setup wordpress on a similar setup, here were the steps that worked for me:

  1. Run phpinfo() to make sure php is running properly and you can access the webserver. Make sure PDO support is enabled, which should result in a section called ‘pdo_sqlite’.
  2. Download and unpack wordpress
  3. Download PDO for WordPress. Copy all the contents of the zip file into wordpress/wp-content/.
  4. Set up wp-config.php, as described in the PDO instructions
  5. Apache needs permission to create the sqlite database file in your wordpress directory. For now, I just
    chmod -R a+w wordpress
  6. If you are running PHP version 5.0-5.1 (PHP 4 is SOL due to PDO requirements), then edit the file wp-content/pdo/driver_sqlite/pdo_sqlite_driver_create.php. Look for the function addQuery($query) around line 207. Comment out the line with preg_last_error():
    private function addQuery($query) {
        $this->_query[] = $query;
        //$this->_errors[] = preg_last_error(); // PHP >= 5.2;
    }
    
  7. Look at your wordpress install from a browser. It should guide you through the “easy” install process and set you up with an admin account. Make sure everything works right.
  8. Eventually you probably want to remove that global write permission we added to the wordpress directory, except for the database and the uploads folder.
    chmod -R go-w wordpress
    mkdir -p wordpress/wp-content/uploads
    chmod -R go+w wordpress/wp-content/uploads

Note that these instructions were tested with WordPress 3.0.1 with PDO plugin 2.7.0. I submitted a patch to PDO for wordpress, so hopefully future versions will be compatible with PHP 5.1.

14 Responses to “WordPress with Sqlite on PHP 5.1”



  1. tw says:

    What wordpress version are you using? As far as I know, the plugin does not work for version 3.03.

  2. Louis says:

    Am I able to create a database without using plugin or wordpress?

    • Spencer says:

      I’m not sure what you mean, Louis–this post was specific to wordpress. Naturally you can use databases for other things. Sqlite or MySQL are popular databases. You should google them to see if they are appropriate for your application.

  3. TechDay says:

    Is there way to use Multi-Database ?

  4. Hello, I thought your article was great!

  5. cool games says:

    Versin 3.0.3 is not good most of plugins are not working fine..

  6. Micheal says:

    Always Always Remember to Delete phpinfo() due to security risks on your server after testing.

  7. You should upgrade to PHP 5.3

  8. OpenWebStuff says:

    Is it compatible with WP 3.5.1 ?

    • Spencer says:

      Sadly, the PDO project seems to have been abandoned. I would recommend against using it now. Migrating a database from sqlite to mysql is non-trivial, so it’s extremely difficult to upgrade wordpress now that PDO is not receiving updates.

  9. i want it to be compatible with latest wordpress



Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam protection by WP Captcha-Free