I kept getting the following error over and over.
exception 'Exception' with message 'Unable to open database: out of memory' in /var/www/...
by using the code
$database = new SQLite3('myDatabase.sqlite', SQLITE3_OPEN_CREATE);
I couldn’t find an answer anywhere. I figured it was a permissions issue so I spent hours trying different permission configurations. Finally, I just changed it to
$database = new SQLite3('myDatabase.sqlite');
and the db was created. What I did was to set the web folder user to myself and the group to www-data. I also gave myself permissions for the www-data group. I think giving myself permissions to that group were not necessary, but I wanted them. The important thing was giving the web folder group to www-data.