php.ini file not being read

Discussion in 'PHP' started by mwbarker, Apr 8, 2008.

  1. mwbarker

    mwbarker Member

    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:

    $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?
  2. mistwang

    mistwang LiteSpeed Staff

    You need to give "r" permission to "configs" directory in addition to "x".
  3. mwbarker

    mwbarker Member

    It's already that way:

  4. mistwang

    mistwang LiteSpeed Staff

    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. mwbarker

    mwbarker Member

    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: Apr 8, 2008
  6. mistwang

    mistwang LiteSpeed Staff

    It does not even look at that directory, I guess you need to rebuild your PHP binary, make sure to do "make clean".
  7. mwbarker

    mwbarker Member


    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.
  8. mistwang

    mistwang LiteSpeed Staff

    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. mwbarker

    mwbarker Member

    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.

Share This Page