25fa Lighttpd : PHP : Sqlite3 [Archive] - The FreeBSD Forums

PDA

View Full Version : Lighttpd : PHP : Sqlite3


lordmor
April 14th, 2009, 21:07
Hi all,

I have a problem with PHP and Sqlite3 combination running on Lighttpd.

The problem is that when I'm trying to open the webpage I get the following error:

Fatal error: Call to undefined function sqlite_open() in /usr/local/www/m4tr1x/db2.php on line 3


But in CLI is everything running okay. I mean when I run:

php db2.php


I did some investigation and I found that PHP under Lighttpd is not loading it's .ini file, ...

Configuration File (php.ini) Path /usr/local/etc
Loaded Configuration File (none)
Scan this dir for additional .ini files /usr/local/etc/php
additional .ini files parsed (none)


...but in CLI it is okay

php -i | grep \.ini
Configuration File (php.ini) Path => /usr/local/etc
Loaded Configuration File => /usr/local/etc/php.ini
Scan this dir for additional .ini files => /usr/local/etc/php
additional .ini files parsed => /usr/local/etc/php/extensions.ini
Classes => AppendIterator, ArrayIterator, ArrayObject, BadFunctionCallException, BadMethodCallException, CachingIterator, DirectoryIterator, DomainException, EmptyIterator, FilterIterator, InfiniteIterator, InvalidArgumentException, IteratorIterator, LengthException, LimitIterator, LogicException, NoRewindIterator, OutOfBoundsException, OutOfRangeException, OverflowException, ParentIterator, RangeException, RecursiveArrayIterator, RecursiveCachingIterator, RecursiveDirectoryIterator, RecursiveFilterIterator, RecursiveIteratorIterator, RecursiveRegexIterator, RegexIterator, RuntimeException, SimpleXMLIterator, SplFileInfo, SplFileObject, SplObjectStorage, SplTempFileObject, UnderflowException, UnexpectedValueException


So this (I think) is why I'm getting the above mentioned error.
Do anyone have idea what could be wrong and how can I fix it?

I tried rebuilding Sqlite, PHP and Lighttpd, but the result is still the same :(

Here is list of PHP, Sqlite and Lighttpd related ports that I have installed on my system:

(ttyp2) root@core /usr/local/www/m4tr1x # pkg_version -v | grep php 21:52:28
php5-5.2.9 = up-to-date with port
php5-ctype-5.2.9 = up-to-date with port
php5-curl-5.2.9 = up-to-date with port
php5-dom-5.2.9 = up-to-date with port
php5-extensions-1.3 = up-to-date with port
php5-gd-5.2.9 = up-to-date with port
php5-imap-5.2.9 = up-to-date with port
php5-mbstring-5.2.9 = up-to-date with port
php5-mcrypt-5.2.9 = up-to-date with port
php5-mysql-5.2.9 = up-to-date with port
php5-mysqli-5.2.9 = up-to-date with port
php5-pcre-5.2.9 = up-to-date with port
php5-pdo-5.2.9 = up-to-date with port
php5-pdo_sqlite-5.2.9 = up-to-date with port
php5-posix-5.2.9 = up-to-date with port
php5-session-5.2.9 = up-to-date with port
php5-simplexml-5.2.9 = up-to-date with port
php5-spl-5.2.9 = up-to-date with port
php5-sqlite-5.2.9 = up-to-date with port
php5-xml-5.2.9 = up-to-date with port
php5-xmlreader-5.2.9 = up-to-date with port
php5-xmlwriter-5.2.9 = up-to-date with port
php5-zlib-5.2.9 = up-to-date with port
(ttyp2) root@core /usr/local/www/m4tr1x # pkg_version -v | grep sqlite 21:58:43
php5-pdo_sqlite-5.2.9 = up-to-date with port
php5-sqlite-5.2.9 = up-to-date with port
sqlite3-3.6.11 = up-to-date with port
(ttyp2) root@core /usr/local/www/m4tr1x # pkg_version -v | grep lighttpd 22:01:29
lighttpd-1.4.22 = up-to-date with port


And system related info

(ttyp2) root@core /usr/local/www/m4tr1x # uname -a 22:02:17
FreeBSD core.m4tr1x.ath.cx 7.1-RELEASE-p4 FreeBSD 7.1-RELEASE-p4 #1: Sat Apr 4 21:01:35 CEST 2009 root@core.matrix.net:/usr/obj/usr/src/sys/CORE i386



Thanks a lot for any help,
LM

lordmor
April 15th, 2009, 08:54
Ok, so I fixed the problem with loading .ini files. They are now properly loaded (problem was that webserver didn't had rights for reading those files).

But modules (sqlite and others) are not loaded anyway, any idea about that?


Thanks,
LM

Carpetsmoker
April 15th, 2009, 19:37
Is ``display_startup_errors'' enabled in php.ini?
Anything useful in the lighttpd logfile?

Also, please attach your lighttpd.conf and php.ini.

lordmor
April 15th, 2009, 20:02
Hi Carpetsmoker,

I have "display_startup_errors" disabled, the only thing I could find in log was:

2009-04-15 20:37:06: (mod_fastcgi.c.2618) FastCGI-stderr: PHP Fatal error: Call to undefined function sqlite_open() in /usr/local/www/m4tr1x/test.php on line 5

But finally this issue is solved.
The problem was that the webserver didn't had sufficient rights for reading .ini files and loading modules. I mean that I had to do:


#chmod o=r /usr/local/etc/php.ini
#chmod o=rx /usr/local/etc/php
#chmod o=r /usr/local/etc/extensions.ini
#chmod o=rx /usr/local/lib/php
#chmod o=rx /usr/local/lib/php/20060613 //this is where the modules are stored


This was probably caused by having umask set to 027 in .tcshrc

Thank you all for your time.
LM

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PS: I admit that this was very stupid issue, but I'm still learning :stud

Carpetsmoker
April 15th, 2009, 21:32
This was probably caused by having umask set to 027 in .tcshrc

Having a umask of 027 is usually fine ... Just not for installing ports.
Always set umask to 022 when installing ports ... In fact, you will get a warning is umask != 022

lordmor
April 15th, 2009, 21:49
In fact, you will get a warning is umask != 022

Yes I noticed that there is this warning, but I never had a problem so I successfully ignored it. Until now...

So thanks for the advice, I will be changing my umask before building ports from now on and will hope that I won't run into similar problems in the future :)

copypaiste
April 19th, 2009, 00:24
This thread has saved my life. Long live FreeBSD forums! :)

0