Thursday, October 4, 2012

Install PHP sqlite on RHEL and CentOS

RHEL and CentOS do not have native packages for PHP sqlite, but you don't have to recompile all of PHP to use the sqlite lib.

Run php -version to get your current PHP version.  At the time of this post, the current version on RHEL 6 is PHP 5.3.3.  Download the corresponding PHP source from:

Unpack the source and navigate to ext/sqlite3/, then build and install the plugin.

tar xvfz php-5.3.3.tar.gz
cd php-5.3.3/ext/sqlite3
cp config0.m4 config.m4
make install
Edit /etc/php.d/sqlite3.ini and add:
Restart Apache and you should now be able to use sqlite from PHP.  To confirm, look at phpinfo() and you should see information about the sqlite3 plugin.

No comments: