php.ini file not being read

#1
Just loaded Litespeed Standard and am trying to figure out why my php.ini file is not being loaded. The phpinfo.php file shows the right location, but the file still doesn't get loaded.

Configuration File (php.ini) Path = /home/myusername/configs
Loaded Configuration File = (none)

I added a file in the same directory called test.php with the following code in it:

<?php
$filename = "/home/myusername/configs/php.ini";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
fclose ($handle);
echo "$contents";
?>

It outputs the contents of php.ini just fine, so it does not appear to be a permissions issue. Anything else I can look at to try and find out why the config file is not being read, though?
 

mistwang

LiteSpeed Staff
#4
try command from command line

cd lsws/fcgi-bin
sudo -u <user_name> ./lsphp5 -i

user_name is the user that lsphp run as. "./lsphp5" should match your lsphp binary.

If it show the same value as your phpinfo() output, try

sudo -u <user_name> strace ./lsphp5 -i

you should be able to figure out what is wrong.
 
#5
Man, I wish I could read that. I don't see anything that sticks out right at me. This is what I do see:

---
write(1, "Configure Command", 17Configure Command) = 17
write(1, " => ", 4 => ) = 4
write(1, " \'./configure\' \'--prefix=/usr/l"..., 262 './configure' '--prefix=/usr/local/php5' '--with-litespeed' '--with-mysql' '--with-mysqli' '--enable-exif' '--enable-ftp' '--with-gd' '--with-jpeg-dir=..' '--with-png-dir=..' '--enable-mbstring' '--with-imagick' '--with-config-file-path=/home/myuser/configs') = 262
write(1, "\n", 1
)
---

---
write(1, "Configuration File (php.ini) Pat"..., 33Configuration File (php.ini) Path) = 33
write(1, " => ", 4 => ) = 4
write(1, "/home/myuser/configs", 22/home/myuser/configs) = 22
write(1, "\n", 1
)
write(1, "Loaded Configuration File", 25Loaded Configuration File) = 25
write(1, " => ", 4 => ) = 4
write(1, "(none)", 6(none)) = 6
write(1, "\n", 1
)
---

---
access("/usr/local/lsws/fcgi-bin/lsphp", X_OK) = 0
open("./php-litespeed.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/lsws/fcgi-bin/php-litespeed.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/php5/lib/php-litespeed.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("./php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/lsws/fcgi-bin/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/php5/lib/php.ini", O_RDONLY) = -1 ENOENT (No such file or directory)
---

Any ideas? It looks to me like it is looking all over for this file, but not finding it. Only problem is that there doesn't seem to be anything showing that it is actually looking where it is supposed to look.
 
Last edited:
#7
Hmmm....

Creating a symbolic link in /usr/local/lsws/fcgi-bin/php.ini pointing to /home/myuser/configs/php.ini fixed the issue for me. But I still don't see why after I compiled PHP to look in the right folder that it couldn't find it where it was at.
 

mistwang

LiteSpeed Staff
#8
If you added the configuration file path option later, you need to rebuild PHP completely. Otherwise, PHP may still looking for configuration file in the old location while showing the new configuration parameter in the phpinfo() output.
 
#9
Nope, I added the configuration file path at the time I built PHP. Maybe a rebuild is needed, but do you see any problems with just leaving the symbolic link in place?

After all, I am just now getting down to setting up my Virtual Hosts and don't want to have to change anything. I must say, I am very impressed with Litespeed so far.
 
Top