-
Notifications
You must be signed in to change notification settings - Fork 163
Using SQLite
SQLite is a nice file based database that uses very few resources and can be utilized by Cypht for authentication, sessions, and user settings.
Setting up the SQLite database for Cypht is slightly different than other traditional database back-ends because SQLite uses a local file and no host or port or user credentials. You need to properly configure 2 settings in the hm3.ini file to use SQLite:
db_driver=sqlite
db_socket=/path/to/sqlite/file
The db_socket path is important and has some restrictions. Cypht enables special protections in PHP against opening files on the system (called "open basedir") which limits the ability of Cypht code to access the file system. However directories defined in the hm3.ini file for Cypht assets are white-listed from the open basedir restrictions, so we can use one of these locations with the correct ownership and permissions.
For example if we have the following in our hm3.ini file:
app_data_dir=/var/lib/hm3/app_data
db_driver=sqlite
db_socket=/var/lib/hm3/app_data/cypht.db
And our webserver software runs as the user www-data
on a Linux like system, we can put the SQLite database in the app_data directory. The www-data user must have full permission to the app_data directory (read/write/execute) and at least read/write permissions to the file itself. For example:
sudo touch /var/lib/hm3/app_data/cypht.db
sudo chown -R www-data /var/lib/hm3/app_data
sudo chmod 744 /var/lib/hm3/app_data
sudo chmod 644 /var/lib/hm3/app_data/cypht.db
Notes:
- the group and world permissions of "4" in chmod are not required
- you need to create the cypht tables in the db file per the instructions in the hm3.ini flie