You are not logged in.
I put this question into this subcategory because I think it is a php-related problem.
I have a server on which I maintain my own wiki using Mediawiki.
Until an update a week ago, the whole wiki worked perfectly, but since the update I get an error message that the database cannot be accessed.
I have set up my wiki with the following components:
mediawiki with php8
sqlite as database
lighttpd as webserver
The following updates were made during the update on 05/03/25 (php-cgi & php-sqlite always have the same version number as php):
mediawiki: 1.42.1-1 -> 1.43.1-1
php: 8.3.9-1 -> 8.4.6-2
sqlite: 3.46.0-1 -> 3.49.1-1
lighttpd: 1.4.76-1 -> 1.4.79-2
On 10.05. I carried out another update as part of a troubleshooting process:
mediawiki: 1.43.1-1
php: 8.4.6-2 -> 8.4.7-1
sqlite: 3.49.1-1 -> 3.49.2-1
lighttpd: 1.4.79-2
The error persisted. After each update of Mediawiki I have performed
php maintenance/run.php update
.
After activating the corresponding flag in
LocalSettings.php
I get the following error message:
MediaWiki internal error.
Original exception: [b923ab9115bdc4186a4ba4d9] /mediawiki/index.php?title=Hauptseite Wikimedia\Rdbms\DBConnectionError: Cannot access the database: Error 14: unable to open database file
Function: Wikimedia\Rdbms\DatabaseSqlite::open
Query: PRAGMA synchronous = NORMAL
Backtrace:
from /usr/share/webapps/mediawiki/includes/libs/rdbms/database/Database.php(1221)
#0 /usr/share/webapps/mediawiki/includes/libs/rdbms/database/DatabaseSqlite.php(230): Wikimedia\Rdbms\Database->newExceptionAfterConnectError()
#1 /usr/share/webapps/mediawiki/includes/libs/rdbms/database/Database.php(263): Wikimedia\Rdbms\DatabaseSqlite->open()
#2 /usr/share/webapps/mediawiki/includes/libs/rdbms/database/DatabaseFactory.php(157): Wikimedia\Rdbms\Database->initConnection()
#3 /usr/share/webapps/mediawiki/includes/language/LCStoreDB.php(143): Wikimedia\Rdbms\DatabaseFactory->create()
#4 /usr/share/webapps/mediawiki/includes/language/LCStoreDB.php(56): LCStoreDB->getWriteConnection()
#5 /usr/share/webapps/mediawiki/includes/language/LocalisationCache.php(566): LCStoreDB->get()
#6 /usr/share/webapps/mediawiki/includes/language/LocalisationCache.php(612): LocalisationCache->isExpired()
#7 /usr/share/webapps/mediawiki/includes/language/LocalisationCache.php(479): LocalisationCache->initLanguage()
#8 /usr/share/webapps/mediawiki/includes/language/LocalisationCache.php(381): LocalisationCache->loadItem()
#9 /usr/share/webapps/mediawiki/includes/language/Language.php(567): LocalisationCache->getItem()
#10 /usr/share/webapps/mediawiki/includes/title/MediaWikiTitleCodec.php(120): MediaWiki\Language\Language->needsGenderDistinction()
#11 /usr/share/webapps/mediawiki/includes/title/Title.php(1157): MediaWiki\Title\MediaWikiTitleCodec->getNamespaceName()
#12 /usr/share/webapps/mediawiki/includes/page/Article.php(494): MediaWiki\Title\Title->getNsText()
#13 /usr/share/webapps/mediawiki/includes/actions/ViewAction.php(78): Article->view()
#14 /usr/share/webapps/mediawiki/includes/actions/ActionEntryPoint.php(733): ViewAction->show()
#15 /usr/share/webapps/mediawiki/includes/actions/ActionEntryPoint.php(510): MediaWiki\Actions\ActionEntryPoint->performAction()
#16 /usr/share/webapps/mediawiki/includes/actions/ActionEntryPoint.php(146): MediaWiki\Actions\ActionEntryPoint->performRequest()
#17 /usr/share/webapps/mediawiki/includes/MediaWikiEntryPoint.php(200): MediaWiki\Actions\ActionEntryPoint->execute()
#18 /usr/share/webapps/mediawiki/index.php(58): MediaWiki\MediaWikiEntryPoint->run()
#19 {main}
Exception caught inside exception handler: [b923ab9115bdc4186a4ba4d9] /mediawiki/index.php?title=Hauptseite Wikimedia\Rdbms\DBConnectionError: Cannot access the database: Error 14: unable to open database file
Function: Wikimedia\Rdbms\DatabaseSqlite::open
Query: PRAGMA synchronous = NORMAL
Backtrace:
from /usr/share/webapps/mediawiki/includes/libs/rdbms/database/Database.php(1221)
#0 /usr/share/webapps/mediawiki/includes/libs/rdbms/database/DatabaseSqlite.php(230): Wikimedia\Rdbms\Database->newExceptionAfterConnectError()
#1 /usr/share/webapps/mediawiki/includes/libs/rdbms/database/Database.php(263): Wikimedia\Rdbms\DatabaseSqlite->open()
#2 /usr/share/webapps/mediawiki/includes/libs/rdbms/database/DatabaseFactory.php(157): Wikimedia\Rdbms\Database->initConnection()
#3 /usr/share/webapps/mediawiki/includes/language/LCStoreDB.php(143): Wikimedia\Rdbms\DatabaseFactory->create()
#4 /usr/share/webapps/mediawiki/includes/language/LCStoreDB.php(56): LCStoreDB->getWriteConnection()
#5 /usr/share/webapps/mediawiki/includes/language/LocalisationCache.php(539): LCStoreDB->get()
#6 /usr/share/webapps/mediawiki/includes/language/LocalisationCache.php(403): LocalisationCache->loadSubitem()
#7 /usr/share/webapps/mediawiki/includes/language/LocalisationCache.php(419): LocalisationCache->getSubitem()
#8 /usr/share/webapps/mediawiki/includes/language/MessageCache.php(1267): LocalisationCache->getSubitemWithSource()
#9 /usr/share/webapps/mediawiki/includes/language/MessageCache.php(1209): MessageCache->getMessageForLang()
#10 /usr/share/webapps/mediawiki/includes/language/MessageCache.php(1103): MessageCache->getMessageFromFallbackChain()
#11 /usr/share/webapps/mediawiki/includes/Message/Message.php(1554): MessageCache->get()
#12 /usr/share/webapps/mediawiki/includes/Message/Message.php(1036): MediaWiki\Message\Message->fetchMessage()
#13 /usr/share/webapps/mediawiki/includes/Message/Message.php(1127): MediaWiki\Message\Message->format()
#14 /usr/share/webapps/mediawiki/includes/exception/MWExceptionRenderer.php(253): MediaWiki\Message\Message->text()
#15 /usr/share/webapps/mediawiki/includes/exception/MWExceptionRenderer.php(399): MWExceptionRenderer::msg()
#16 /usr/share/webapps/mediawiki/includes/exception/MWExceptionRenderer.php(107): MWExceptionRenderer::reportOutageHTML()
#17 /usr/share/webapps/mediawiki/includes/exception/MWExceptionHandler.php(135): MWExceptionRenderer::output()
#18 /usr/share/webapps/mediawiki/includes/exception/MWExceptionHandler.php(239): MWExceptionHandler::report()
#19 /usr/share/webapps/mediawiki/includes/MediaWikiEntryPoint.php(222): MWExceptionHandler::handleException()
#20 /usr/share/webapps/mediawiki/includes/actions/ActionEntryPoint.php(82): MediaWiki\MediaWikiEntryPoint->handleTopLevelError()
#21 /usr/share/webapps/mediawiki/includes/MediaWikiEntryPoint.php(206): MediaWiki\Actions\ActionEntryPoint->handleTopLevelError()
#22 /usr/share/webapps/mediawiki/index.php(58): MediaWiki\MediaWikiEntryPoint->run()
#23 {main}
Opening the corresponding database with
sqlite bp_wiki.sqlite
as root and checking the database with
sqlite> .database
gives
main: /usr/share/webapps/data/bp_wiki.sqlite r/w
showing that the database is present and also readable and writeable. The database is owned by user and group http.
So it seems, that the database containing the wiki content is not accessable by php.
What could be the cause of this error?
Last edited by mrpaul (2025-05-31 18:58:36)
Offline
Opening the corresponding database with sqlite bp_wiki.sqlite as root
Try to open the database from command line as http user, not as root. E.g. with
$ cd /
$ sudo setpriv --reuid http --regid http --clear-groups sqlite /path/to/bp_wiki.sqlite
The database is owned by user and group http.
Are all leading directories readable by http user?
Offline
Open the database with your suggested settings
$ cd / $ sudo setpriv --reuid http --regid http --clear-groups sqlite /path/to/bp_wiki.sqlite
works. The only thing I changed was to use sqlite3.
Doing this and checking the database gives
$ sudo setpriv --reuid http --regid http --clear-groups sqlite3 /usr/share/webapps/data/bp_wiki.sqlite
sqlite> .database
main: /usr/share/webapps/data/bp_wiki.sqlite r/w
Are all leading directories readable by http user?
Yes. Checking the whole path shows
$ ls -l /
drwxr-xr-x 8 root root 4096 13. Mai 20:13 usr
$ ls -l /usr
drwxr-xr-x 93 root root 4096 10. Mai 20:48 share
$ ls -l /usr/share
drwxr-xr-x 4 root root 4096 20. Feb 2022 webapps
$ ls -l /usr/share/webapps
drwxrwxr-x 4 root http 4096 13. Mai 20:34 data
$ ls -l /usr/share/webapps/data
-rw-r--r-- 1 http http 3960832 13. Mai 20:34 bp_wiki.sqlite
Offline
(I see this was cross-posted to https://stackoverflow.com/questions/796 … mediawiki)
lighttpd 1.4.79 hardened the systemd lighttpd.service, and that lighttpd.service is install by Arch Linux
https://gitlab.archlinux.org/archlinux/ … =heads#L87
The lighttpd 1.4.79 release notes highlighted this in BEHAVIOR CHANGES: see https://redmine.lighttpd.net/projects/l … ase-1_4_79
See the "# systems capability hardening" section in https://git.lighttpd.net/lighttpd/light … ervice#L29
Please post which of those setting is causing trouble for your setup and let us submit some updated instructions to MediaWiki install docs.
Offline
you can find the solution of this problem follwing the link of the discussion on StackOverflow https://stackoverflow.com/questions/796 … mediawiki)
Short answer:
The key
ProtectSystem=full
of the lighttpd-service does not allow to write to directories under
/usr
where the database resides.
Offline
@mrpaul, thank you for the update. Please file a bug to MediaWiki. General best practices for unix filesystem have for decades recommended against putting databases under `/usr`. Instead, `/var` or some other location is preferable for shared, read-only mounts of `/usr`, as well as for filesystem backup management purposes, and for other reasons.
Offline