[GH-ISSUE #353] Documentation not clear enough where to put the sqlite path #302

Closed
opened 2026-02-25 21:34:41 +03:00 by kerem · 6 comments
Owner

Originally created by @domeniko-gentner on GitHub (Jul 2, 2019).
Original GitHub issue: https://github.com/cypht-org/cypht/issues/353

Originally assigned to: @jasonmunro on GitHub.

💬 Question

I have enabled sqlite as PDO driver, but the comments in the h3m.ini file are not clear enough in where to pass the path to cypht. I'd use db_name for it, but I am not sure what you have intended. So, how do I use an sqlite database for authentication, settings et al?

Environment:
latest Raspbian on a Pi3
PHP 7.0
SQLite 3
Apache 2

Originally created by @domeniko-gentner on GitHub (Jul 2, 2019). Original GitHub issue: https://github.com/cypht-org/cypht/issues/353 Originally assigned to: @jasonmunro on GitHub. ## 💬 Question <!-- Describe your Question in detail. Include screenshots and drawings if needed. --> I have enabled sqlite as PDO driver, but the comments in the h3m.ini file are not clear enough in where to pass the path to cypht. I'd use `db_name` for it, but I am not sure what you have intended. So, how do I use an sqlite database for authentication, settings et al? Environment: latest Raspbian on a Pi3 PHP 7.0 SQLite 3 Apache 2
kerem 2026-02-25 21:34:41 +03:00
  • closed this issue
  • added the
    docs
    label
Author
Owner

@jasonmunro commented on GitHub (Jul 2, 2019):

The poorly named db_socket config setting is the right place for the sqlite path. I will update the ini file to make that more clear. Let me know if you run into any issues.

<!-- gh-comment-id:507773747 --> @jasonmunro commented on GitHub (Jul 2, 2019): The poorly named db_socket config setting is the right place for the sqlite path. I will update the ini file to make that more clear. Let me know if you run into any issues.
Author
Owner

@domeniko-gentner commented on GitHub (Jul 2, 2019):

This is my config:

465 ; Database Support
466 ; ----------------
467 ; Cypht can use a database for 3 different purposes: authentication, sessions,
468 ; and user settings. Each requires the following settings to be configured and
469 ; the correct table to be created. CREATE TABLE SQL statements for Mysql and
470 ; Postgresql are below.
471 ;
472 ; Connection type. Can be "host" to connect to a hostname, or "socket" to
473 ; connect to a unix socket.
474 db_connection_type=socket
475
476 ; Database host name or ip address. If db_connection_type is set to "socket",
477 ; this value is ignored
478 db_host=127.0.0.1
479
480 ; If db_connection_type is set to "socket", this should be the filesystem
481 ; location of the unix socket file. If db_connection_type is set to "host"
482 ; this value is ignored.
483 db_socket=/home/www-data/mail/
484
485 ; Name of the database with the required tables
486 db_name=cypht.sqlite
487
488 ; User to connect to the database with
489 db_user=test
490
491 ; Password to connect to the database with
492 db_pass=test
493
494 ; Database type. can be any supported PDO driver ; (http://php.net/manual/en/pdo.drivers.php)
495 db_driver=sqlite

I am still getting this when trying to make a user:

Array
(
    [0] => SQLSTATE[HY000] [14] unable to open database file
    [1] => Unable to connect to the DB auth server 127.0.0.1
)
Array
(
)

Database:

sqlite> .tables
hm_user           hm_user_session   hm_user_settings

cypth.sqlite has chmod 600 (rw) and the directory chmod 700 (rwx) for www-data. The db does not have a user, however, the script reports errors without those values filled.

<!-- gh-comment-id:507780064 --> @domeniko-gentner commented on GitHub (Jul 2, 2019): This is my config: ``` 465 ; Database Support 466 ; ---------------- 467 ; Cypht can use a database for 3 different purposes: authentication, sessions, 468 ; and user settings. Each requires the following settings to be configured and 469 ; the correct table to be created. CREATE TABLE SQL statements for Mysql and 470 ; Postgresql are below. 471 ; 472 ; Connection type. Can be "host" to connect to a hostname, or "socket" to 473 ; connect to a unix socket. 474 db_connection_type=socket 475 476 ; Database host name or ip address. If db_connection_type is set to "socket", 477 ; this value is ignored 478 db_host=127.0.0.1 479 480 ; If db_connection_type is set to "socket", this should be the filesystem 481 ; location of the unix socket file. If db_connection_type is set to "host" 482 ; this value is ignored. 483 db_socket=/home/www-data/mail/ 484 485 ; Name of the database with the required tables 486 db_name=cypht.sqlite 487 488 ; User to connect to the database with 489 db_user=test 490 491 ; Password to connect to the database with 492 db_pass=test 493 494 ; Database type. can be any supported PDO driver ; (http://php.net/manual/en/pdo.drivers.php) 495 db_driver=sqlite ``` I am still getting this when trying to make a user: ``` Array ( [0] => SQLSTATE[HY000] [14] unable to open database file [1] => Unable to connect to the DB auth server 127.0.0.1 ) Array ( ) ``` Database: ``` sqlite> .tables hm_user hm_user_session hm_user_settings ``` `cypth.sqlite` has `chmod 600` (rw) and the directory `chmod 700` (rwx) for `www-data`. The db does not have a user, however, the script reports errors without those values filled.
Author
Owner

@domeniko-gentner commented on GitHub (Jul 2, 2019):

I have found the reason: Looked through your code. I am using PHP 7.0 and SQLITE via PDO is deprecated since 5.4 or something. So, my only option right now is downgrade my PHP, which breaks my own projects or install MariaDB I guess.

https://www.php.net/manual/en/ref.pdo-sqlite.php

<!-- gh-comment-id:507785279 --> @domeniko-gentner commented on GitHub (Jul 2, 2019): I have found the reason: Looked through your code. I am using PHP 7.0 and SQLITE via PDO is deprecated since 5.4 or something. So, my only option right now is downgrade my PHP, which breaks my own projects or install MariaDB I guess. https://www.php.net/manual/en/ref.pdo-sqlite.php
Author
Owner

@jasonmunro commented on GitHub (Jul 2, 2019):

sqlite works for PHP 7 as far as I know - I have a travis build that should be using it here: https://travis-ci.org/jasonmunro/cypht/jobs/541951862

Looking at my Ubuntu PHP 7.2 install I see it in the PDO driver list (Ubuntu has both a php-sqlite3 and a php7.2-sqlite3 packages):

jason [ ~/cypht ]$ php -r 'print_r(PDO::getAvailableDrivers());'
Array
(
    [0] => mysql
    [1] => pgsql
    [2] => sqlite
)
<!-- gh-comment-id:507792885 --> @jasonmunro commented on GitHub (Jul 2, 2019): sqlite works for PHP 7 as far as I know - I have a travis build that _should_ be using it here: https://travis-ci.org/jasonmunro/cypht/jobs/541951862 Looking at my Ubuntu PHP 7.2 install I see it in the PDO driver list (Ubuntu has both a php-sqlite3 and a php7.2-sqlite3 packages): ``` jason [ ~/cypht ]$ php -r 'print_r(PDO::getAvailableDrivers());' Array ( [0] => mysql [1] => pgsql [2] => sqlite ) ```
Author
Owner

@jasonmunro commented on GitHub (Jul 3, 2019):

Just rereading your config and I noticed you have the db_socket value set to a directory (?). For sqlite this should be the path to the db file itself I think.

<!-- gh-comment-id:507898175 --> @jasonmunro commented on GitHub (Jul 3, 2019): Just rereading your config and I noticed you have the db_socket value set to a directory (?). For sqlite this should be the path to the db file itself I think.
Author
Owner

@domeniko-gentner commented on GitHub (Jul 3, 2019):

Yeah, I changed that after reading the db.php file. I didn't know how you programmed it. The key part was regenerating the site after. Didn't know you had to do that every time you change the config.

I am sorry, but the documentation is really sparse here and I don't mean that as an attack, but it was a bit hard to set up. I am not familiar with composer-based PHP apps.. The script to add a user finally works, but I still can't log in. I am going to figure it out though.

<!-- gh-comment-id:507945161 --> @domeniko-gentner commented on GitHub (Jul 3, 2019): Yeah, I changed that after reading the db.php file. I didn't know how you programmed it. The key part was regenerating the site after. Didn't know you had to do that every time you change the config. I am sorry, but the documentation is really sparse here and I don't mean that as an attack, but it was a bit hard to set up. I am not familiar with composer-based PHP apps.. The script to add a user finally works, but I still can't log in. I am going to figure it out though.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cypht#302
No description provided.