Chroot and php.ini

Discussion in 'General' started by yulia, Apr 18, 2009.

  1. yulia

    yulia New Member

    Chrooting

    I'm currently playing around with the chroot function, but can't seem to figure out how to load php.ini

    I've tried lots of ways, none worked yet. Is there a trick? Current build:

    Code:
    ./configure'  '--prefix=/opt/lsws/chroot/usr' '--with-litespeed' '--with-config-file-path=../php' ...
    EDIT: Figured it out.
    Last edited: Apr 18, 2009
  2. yulia

    yulia New Member

    New problem... How do you get MySQL to work in a chroot environment?
    Last edited: Apr 18, 2009
  3. yulia

    yulia New Member

    Well after some research I found you can change the MySQL sock to the tmp location in the chroot, but can't get MySQL to restart. Is it typically better to reinstall MySQL in the chroot?
  4. mistwang

    mistwang LiteSpeed Staff

    Changing the MYSQL socket location wont make MySQL to fail.
    I think it is not a easy task to install MySQL in chroot, and it is not necessary.
  5. yulia

    yulia New Member

    is there a certain location i should change the MySQL sock to? I've been setting it in the tmp under the chroot, but MySQL like fails to start when i change it.
  6. mistwang

    mistwang LiteSpeed Staff

    check your mysql server log for errors. maybe a permission problem?
  7. yulia

    yulia New Member

    Code:
    host:~# ls -la /opt/lsws/chroot/tmp
    total 304
    drwxrwxrwt  3 root  root    4096 Apr 22 12:44 .
    drwxr-xr-x 11 root  root    4096 Apr 22 12:38 ..
    drwx------  3 lsws  lsws    4096 Apr 22 12:50 lshttpd
    srwxrwxrwx  1 mysql mysql      0 Apr 22 12:40 mysqld.sock
    my.cnf
    Code:
    [client]
    port            = 3306
    #socket          = /var/run/mysqld/mysqld.sock
    socket          = /opt/lsws/chroot/tmp/mysqld.sock
    [mysqld]
    port            = 3306
    #socket          = /var/run/mysqld/mysqld.sock
    socket          = /opt/lsws/chroot/tmp/mysqld.sock
    (only error I can really find)
    When attempting to log in via phpMyAdmin:
    #2002 - The server is not responding (or the local MySQL server's socket is not correctly configured)
  8. Viz0n

    Viz0n New Member

    You actually solved the problem in your first post. Think chroot. ;)

    Basically, what we need to do is tell php how to connect to MySQL in the chroot.

    Open your php.ini and scroll down looking for [MySQL] and set the following:
    Code:
    mysql.default_socket = /tmp/mysqld.sock
    mysql.default_host = localhost
    Should work just fine.
    Last edited: Apr 22, 2009
  9. yulia

    yulia New Member

    Thanks, worked.

    On a side note, I guess if you compiled PHP after I changed the socked location then I would not need to make the php.ini edit?

Share This Page