Posts tagged: php5-sqlite

SQLite and PHP5 in LAMP

It seems that most articles written about SQLite and PHP are at least two years old and might leave some feeling like they are outdated and do not work. Here’s something recently dated (relatively speaking, assuming you’re reading this in 2008).

This article will help you get sqlite working with a directory hosted in your /home that is symlinked to /var/www

Using your favorite package manager, install a LAMP (Linux, Apache, MySQL, Perl) server. Ignore the fact that you are installing M (for MySQL).

Next, use the package manager to install php5-sqlite (NOTE: this is assuming that your package manager installs PHP5 by default)

Restart the apache webserver

sudo /etc/init.d/apache2 restart

And now php5-sqlite should be playing nice with apache.

At this point, I ran into trouble. I couldn’t get any examples of sqlite within PHP to work properly. The problem: permissions.

Create the directory that will host the files.

mkdir ~/mytest

Change the group permission from your username to www-data

sudo chgrp www-data ~/mytest

Create the symlink to the web directory

sudo ln -s ~/mytest /var/www/mytest

Rejoice in an sqlite-capable directory (specifically located at http://localhost/mytest). Give it a test with the example here (but in this example remove the “unsigned” part of “unsigned primary key” first) or here.

Staypressed theme by Themocracy