httpd with PHP and sqlite3 with SELinux

mkdir /var/www/data

semanage fcontext -a -t httpd_sys_rw_content_t “/var/www/data(/.*)?”

restorecon -Rv /var/www

chown -R apache:apache data

 

<?php

$dbhandle = new SQLite3(‘/var/www/data/mysqlitedb.db’);
$sql = “CREATE TABLE IF NOT EXISTS foo (id INTEGER PRIMARY KEY¬† AUTOINCREMENT, bar STRING)”;
$result = $dbhandle->query($sql);