Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Problem with database connection on archlinux #59

Leopes · · author
#1

Hello. I'm trying to run rompr on an archlinux installation. Arch's php is configured a little different than debian/ubuntu. However I seem to have everything in place. I've checked this with phpinfo.php, where I get the sqlite3 info. However, rompr gives me a 'No database connection was possible' error. I've tested different versions with both php7.4 an php8.0, and get the same result. Any ideas what could be wrong here?

  • replies 9
  • views 760
  • likes 0
#2

Sounds like a necessary php module is missing. I need A debug log and the debug info as described under Troubleshooting in the docs.

Leopes · · author
#3

I don't know how to get the debug info (since I only can get to the setup page), but I've added the debug log (sorry about the mess, there don't seem to be newlines between the comments). I have installed rompr on a system directory, as I got 'forbidden' errors when I installed it on a user directory. There seem to be some setting in systemd which prevents nginx from working outside the system directories (although I was not able to find out how exactly).

2021/04/19 22:33:05 [error] 55879#55879: *1 FastCGI sent in stderr: "PHP message: MARK : INIT : : Setting Pref currenthost to DefaultPHP message: MARK : INIT : : Setting Pref mpd_host to localhostPHP message: MARK : INIT : : Setting Pref mpd_port to 6600PHP message: MARK : INIT : : Setting Pref mpd_password to PHP message: MARK : INIT : : Setting Pref unix_socket to PHP message: MARK : INIT : : Setting Pref http_port_for_mopidy to 6680PHP message: MARK : INIT : : Setting Pref cleanalbumimages to 1PHP message: MARK : INIT : : Setting Pref bing_api_key to PHP message: MARK : INIT : : Setting Pref mysql_host to localhostPHP message: MARK : INIT : : Setting Pref mysql_port to 3306PHP message: MARK : INIT : : Setting Pref mysql_database to romprdbPHP message: MARK : INIT : : Setting Pref mysql_user to romprPHP message: MARK : INIT : : Setting Pref mysql_password to romprdbpassPHP message: MARK : INIT : : Setting Pref proxy_host to PHP message: MARK : INIT : : Setting Pref proxy_user to PHP message: MARK : INIT : : Setting Pref proxy_password to PHP message: MARK : INIT : : Setting Pref debug_enabled to 6PHP message: MARK : INIT : : Setting Pref custom_logfile to PHP message: MARK : INIT : : Setting Pref do_not_show_prefs to PHP message: MARK : INIT :
2021/04/19 22:33:05 [error] 55879#55879: *1 FastCGI sent in stderr: "abase()
#2 {main}PHP message: LOG : SQL_CONNECT : (probe_database) : Attempting to use SQLite DatabasePHP message: WARN : SQL_CONNECT : : Couldn't use SQLite Either - PDOException: SQLSTATE[HY000] [14] unable to open database file in /usr/share/nginx/html/rompr/backends/sql/data_base.class.php:39
Stack trace:
#0 /usr/share/nginx/html/rompr/backends/sql/data_base.class.php(39): PDO->__construct()
#1 /usr/share/nginx/html/rompr/index.php(53): data_base::probe_database()
#2 {main}PHP message: PHP Warning: Undefined array key "collection_type" in /usr/share/nginx/html/rompr/includes/functions.php on line 142PHP message: LOG : SETUP : (include) : Displaying Setup ScreenPHP message: LOG : LANGUAGE : (load_translations) : Loading TranslationsPHP message: LOG : INTERNATIONAL : (load_translations) : Translation en-US does not exist. Defaulting to EnglishPHP message: PHP Warning: file_put_contents(prefs/prefs.var): Failed to open stream: Read-only file system in /usr/share/nginx/html/rompr/includes/prefs.class.php on line 235PHP message: ERROR! : COULD NOT SAVE PREFS" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "POST /rompr/index.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "localhost", referrer: "http://localhost/rompr/"
2021/04/19 22:33:06 [error] 55879#55879: *1 FastCGI sent in stderr: "PHP message: LOG : INIT : (require_once) : Player backend pref is not set at load timePHP message: CORE : REQUEST : (require_once) : /rompr/gettheme.phpPHP message: CORE : INIT : (require_once) : Using MPD Host DefaultPHP message: CORE : INIT : (require_once) : Using skin as set by Cookie: desktopPHP message: CORE : INIT : (require_once) : Using skin : desktopPHP message: LOG : THEME : : Theme : Numismatist.cssPHP message: LOG : THEME : : Font : Nunito.cssPHP message: LOG : THEME : : Font Size : 02-Normal.cssPHP message: LOG : THEME : : Cover Size : 40-Large.cssPHP message: LOG : THEME : : Icons : New-Dark-Circled" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /rompr/gettheme.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "localhost", referrer: "http://localhost/rompr/index.php"

2021/04/19 22:33:10 [error] 55879#55879: *1 FastCGI sent in stderr: "PHP message: MARK : INIT : : Setting Pref currenthost to DefaultPHP message: MARK : INIT : : Setting Pref mpd_host to localhostPHP message: MARK : INIT : : Setting Pref mpd_port to 6600PHP message: MARK : INIT : : Setting Pref mpd_password to PHP message: MARK : INIT : : Setting Pref unix_socket to PHP message: MARK : INIT : : Setting Pref http_port_for_mopidy to 6680PHP message: MARK : INIT : : Setting Pref cleanalbumimages to 1PHP message: MARK : INIT : : Setting Pref bing_api_key to PHP message: MARK : INIT : : Setting Pref mysql_host to localhostPHP message: MARK : INIT : : Setting Pref mysql_port to 3306PHP message: MARK : INIT : : Setting Pref mysql_database to romprdbPHP message: MARK : INIT : : Setting Pref mysql_user to romprPHP message: MARK : INIT : : Setting Pref mysql_password to romprdbpassPHP message: MARK : INIT : : Setting Pref proxy_host to PHP message: MARK : INIT : : Setting Pref proxy_user to PHP message: MARK : INIT : : Setting Pref proxy_password to PHP message: MARK : INIT : : Setting Pref debug_enabled to 6PHP message: MARK : INIT : : Setting Pref custom_logfile to PHP message: MARK : INIT : : Setting Pref do_not_show_prefs to PHP message: MARK : INIT :
2021/04/19 22:33:10 [error] 55879#55879: *1 FastCGI sent in stderr: "abase()

#2 {main}PHP message: LOG : SQL_CONNECT : (probe_database) : Attempting to use SQLite DatabasePHP message: WARN : SQL_CONNECT : : Couldn't use SQLite Either - PDOException: SQLSTATE[HY000] [14] unable to open database file in /usr/share/nginx/html/rompr/backends/sql/data_base.class.php:39
Stack trace:
#0 /usr/share/nginx/html/rompr/backends/sql/data_base.class.php(39): PDO->__construct()
#1 /usr/share/nginx/html/rompr/index.php(53): data_base::probe_database()
#2 {main}PHP message: PHP Warning: Undefined array key "collection_type" in /usr/share/nginx/html/rompr/includes/functions.php on line 142PHP message: LOG : SETUP : (include) : Displaying Setup ScreenPHP message: LOG : LANGUAGE : (load_translations) : Loading TranslationsPHP message: LOG : INTERNATIONAL : (load_translations) : Translation en-US does not exist. Defaulting to EnglishPHP message: PHP Warning: file_put_contents(prefs/prefs.var): Failed to open stream: Read-only file system in /usr/share/nginx/html/rompr/includes/prefs.class.php on line 235PHP message: ERROR! : COULD NOT SAVE PREFS" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "POST /rompr/index.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "localhost", referrer: "http://localhost/rompr/"
2021/04/19 22:33:10 [error] 55879#55879: *1 FastCGI sent in stderr: "PHP message: LOG : INIT : (require_once) : Player backend pref is not set at load timePHP message: CORE : REQUEST : (require_once) : /rompr/gettheme.phpPHP message: CORE : INIT : (require_once) : Using MPD Host DefaultPHP message: CORE : INIT : (require_once) : Using skin as set by Cookie: desktopPHP message: CORE : INIT : (require_once) : Using skin : desktopPHP message: LOG : THEME : : Theme : Numismatist.cssPHP message: LOG : THEME : : Font : Nunito.cssPHP message: LOG : THEME : : Font Size : 02-Normal.cssPHP message: LOG : THEME : : Cover Size : 40-Large.cssPHP message: LOG : THEME : : Icons : New-Dark-Circled" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /rompr/gettheme.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "localhost", referrer: "http://localhost/rompr/index.php"

#4

Ah yes I didn't think about how you'd get the debug info when nothing can run. Never mind.

"Unable to open database file" suggests that the webserver doesn't have write access to the prefs directory. However the fact it's setting preferences suggests it does. I would check that, maybe empty the prefs directory and set it as read/write by everybody. If that diesn't work I can only think of 2 things. Either PHP is missing the sqlite module for the PDO extension, or there is some annoying security nonsense going on in Arch, maybe to do with systemd or selinux or something like that. Some distros have some crazy security thing where write access to a directory requires you to have write access to the entire tree starting from /.

I've never used Arch, but the debug log points to it being permissions related, so that's about all the help I can give.

#5

ah and now I've read it again ERROR COULD NOT SAVE PREFS means it is definitely a write permissions problem. The webserver does not have write access to rompr/prefs

Leopes · · author
#6

I had i feeling it should be something like this. The strange thing is that prefs has 777 permission, and I can write on it as the http-user, I just checked. I'll investigate further and let you know if I've made progress.

Leopes · · author
#7

OK, I've got it worked out.
First, the reason why installation on a user-dir didn't work: /home/user has permission set to 700 in arch. This means that the contents are not readable by other users. The (not set) executable bit is inherited by sub-folders, preventing access by other users to the subfolders too, regardless of the permission settings of that subfolder (see: https://wiki.archlinux.org/index.php/File_permissions_and_attributes). Resulting in the Forbidden error's I got, trying to reach rompr.

Second, there indeed appears to be a systemd setting, preventing php-fpm to write to subfolders in the /usr tree. It is the ProtectSystem=yes setting in /usr/lib/systemd/system/php-fpm.service, which makes /usr and /boot read-only to the application (see: https://www.redhat.com/sysadmin/mastering-systemd).

So, now knowing what the problems are, I can think of several ways to a solution. I think I'll start a discussion on archwiki and see what the developers think.

#8

Thanks. In the past I did try to put up instructions for RedHat-like distros, but with so much fragmentation and disagreement it's just impossible for one person to find the will to do it.

If you do get it to work I'm sure it would help other people if you shared your findings here.

Leopes · · author
#9

Yeah, I have it running by creating a /var/www directory and installing rompr there.

Archlinux is by no means a RedHat-like distro, btw. I'm sure most archers are competent enough to work it out themselves, when pointed in the right direction, just as I did. Most is said in my last post: permission setting 700 of /home/user is a problem as is installing rompr somewhere in the /usr tree. An easy way out is to set home permission to for instance 755 or out-comment the ProtectSystem=yes setting in /usr/lib/systemd/system/php-fpm.service. Depending on ones situation this may or may not be acceptable. I choose another system location outside the /usr tree, thus not breaking the security settings.

One slight adjustment I made is that I didn't make prefs and albumart world readable and writable, as in the standard instructions, but changed ownership to http, the system user that runs the webpage:

sudo chown http:http prefs
sudo chown http:http albumart

This is a little neater (and can also be done in debian/ubuntu).
The configuration of nginx also needs some adjustments, but they can pretty much be found in the nginx archwiki page.
Last point is that php in archlinux has some modules built-in, but these need to be enabled in /etc/php/php.ini:

extension=curl
extension=gd
extension=intl
extension=pdo_sqlite
extension=sqlite3

That should work.

Btw: there's also a rompr package in the Arch User repository (AUR), but this doesn't do more than unzipping the package and creating the prefs and albumart dirs (using a solution with soft-links - another possibility). The configuration still has to be done by hand.

#10

Thanks for posting that. I'll add a link to this on the setup pages.

The sheer number of different distros, each with their own quirks and ways of doing things, is a source of great pain to web developers who just want a stable platform on which to do the interesting stuff. So it's helpful to have posts like this to fill in the chasms. Cheers.