> De : "[email protected]" <[email protected]>

>
OpenBSD 3.9?  Or 4.9?
My mistake, yes it's OpenBSD 4.9


> Quoting Mik J
<[email protected]>:
> 
>>  Hello everyone,
>> 
>>  My problem is that I
cannot execute a php script in CLI. This
>>  test script is supposed to
connect to mysql and retrieve some simple
>>  results
>>  Systeme: OpenBSD 3.9
>>  Packages installed: php5-core-5.2.17,
>>  php5-extensions-5.2.17, 
>>
php5-gd-5.2.17, php5-mysql-5.2.17, php5-snmp-5.2.17,
>>
mysql-server-5.1.54p3, mysql-client-5.1.54p0
>> 
>>  Preparation
>>
-----------------
>>  mysqld is started like this
>>  #
/usr/local/bin/mysqld_safe --user=_mysql
>>  --pid-file=/var/mysql/mysql.pid &
>> 
>>  I have configured /etc/my.cnf in my base
>>  system like this
>>
[mysqld]
>>  socket = /var/www/var/run/mysql/mysql.sock
>>  Once mysqld is
started I have the mysql.sock created in
>>  /var/www/var/run/mysql
>>  # ls
/var/www/var/run/mysql/
>>  mysql.sock
>> 
>>  I hard linked it to
/var/run/mysql/
>>  #
>>  ln /var/www/var/run/mysql/mysql.sock
/var/run/mysql/mysql.sock
>> 
>>  I have
>>  downloaded adodb5 and placed it
in /var/www, then adapted this code for
>>  test
>>  purpose
>>  <?php
>>
include('../adodb5/adodb.inc.php');
>>  $conn =
>>
&ADONewConnection('mysql');
>>  $conn->PConnect('localhost','cacti','cac 
>
tipw','cactidb');
>>  $sql = 'select
>>  hostname,description from host;';
>>
$recordSet = &$conn->Execute($sql);
>>  if
>>  (!$recordSet)
>>   print
$conn->ErrorMsg();
>>  else
>>  while (!$recordSet->EOF) {
>>   print
$recordSet->fields[0].' 
> '.$recordSet->fields[1].'<BR>';
>>   
>>
$recordSet->MoveNext();
>>  }
>>  $recordSet->Close();
>>  $conn->Close();
>>
?>
> 
>> 
>> 
>>  I also
>>  copied /etc/my.cnf in /var/www/etc but changed
the path for the client
>>  [client]
>>  socket = /var/run/mysql/mysql.sock
>>
>> 
>>  The tests
>>  -------------
>>  Case 1: The script is ran without any
chroot consideration => Works
>>  #
>>  /usr/local/bin/php
/var/www/htdocs/adotest.php
>>  127.0.0.1 System1<BR>1.1.1.1
>>  System2<BR>
>> 
>>  Case 2: The script is ran through the apache chrooted server
>>  using
the url http://localhost/adotest.php => Works
>>  127.0.0.1 System1
>>
1.1.1.1
>>  System2
>> 
>>  Case 3: The script is ran in command line and
simulates a user
>>  running it in the chroot (/var/www) => Fails
>>  #
/usr/sbin/chroot /var/www
>>  /bin/php /htdocs/adotest.php
>>  PHP Fatal
error: Call to undefined function
>>  mysql_pconnect() in
/adodb5/drivers/adodb-mysql.inc.php on line 383
>>  Fatal
>>  error: Call to
undefined function mysql_pconnect() in
>>  /adodb5/drivers/adodb-mysql.inc.php
on line 383
>>  Note that: the adotest.php
>>  script was able to include
/adodb5/drivers/adodb-mysql.inc.php
>> 
>> 
>>  I thought
>>  that maybe there
is something wrong with connecting to mysql 
>>  inside the
>>  chroot so I
copied the mysql client inside the chroot 
>>  (/var/www) and the
>>
associated dynamic libraries.
>> 
>>  But everything worked when I tried to
connect
>>  to the database
>>  # /bin/mysql -u cacti -p
>>  Enter password:
>>  Welcome to the MySQL
>>  monitor. Commands end with ; or \g.
>>  Your
MySQL connection id is 6
>> 
>> 
>>  I've
>>  searched for a long time and I
have no clue why it's working when the
>>  script
>>  is executed by Apache
and not working when executed in cli inside
>>  chroot
>>  /var/www. Does
anyone have an idea on how to solve this ?
>> 
>>  If you want to test
>>
just download adodb5 and place it in /var/www
>> 
>
http://sourceforge.net/projects/adodb/files/adodb-php5-only/adodb-514-for-php
>>  5/adodb514.zip/download
>>  Place the php script adotest.php in
/var/www/htdocs
>>  Thank you
>> 
>>   

Reply via email to