[peruser] Tip for using MySQL with PHP

Blaubaer blaubaer at dyntux.net
Sat Jul 16 04:13:36 MDT 2005


Hi

i have a little hack for using MySQL with PHP.

standart when the host "localhost" by mysql_connect is defined. the mysqllib 
want to use the mysql.sock file.
But when we use chroot with peruser, we have no access on this file. We can 
type 127.0.0.1 or the original server ip, but its not a nice work.

So when u edit the <php_source>/ext/mysql/php_mysql.c near

line 643 (in PHP-4.4.0)
#if MYSQL_VERSION_ID < 32200
        mysql_port = port;
#endif

        if (!MySG(allow_persistent)) {
                persistent=0;
        }

and add
        if (strcmp(host,"localhost")==0)
            host="127.0.0.1";

This will fix this small disturbing thing. mysql_connect no more mysql.sock 
will use.

/ Blaubaer




More information about the Peruser mailing list