Archive for February, 2007

Disable open_basedir checking

Thursday, February 22nd, 2007

in httpd.conf

php_admin_value open_basedir none

Repairing a corrupted MYSQL Index File

Monday, February 19th, 2007

Use this to repair a corrupted Index File (.MYI). In this mode, MySQL re-creates the .MYI file using information from the .frm file

REPAIR TABLE tbl USE_FRM

Installing MySQL

Thursday, February 15th, 2007

./configure \
--with-charset=utf8 \
--with-extra-charsets=big5,gb2312 \
--prefix=/usr/local/mysql \
--enable-local-infile \
--enable-thread-safe-client

make
make install


choose correct config file
cp support-files/my-xxxxx.cnf /etc/my.cnf
./scripts/mysql_install_db
useradd -s /sbin/nologin mysql
chown -R mysql /usr/local/mysql/var
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 3 mysqld on
change root password
/usr/local/mysql/bin/mysqladmin -u root password ‘new-password’

# To Strip mysqld yeilding up to 4% performance gain.
strip /usr/local/mysql/libexec/mysqld

edit /etc/rc.d/init.d/mysqld
add --skip-name-resolve to $bindir/mysqld_safe --datadir=$datadir --pid-file=$pid_file

Mount the file system with noatime
/dev/VolGroup00/LogVol04 /usr/local/mysql/var ext3 rw,noatime 1 2

Compiling Linux Kernel

Saturday, February 10th, 2007

Get Kernel http://www.kernel.org/

make menuconfig
make
make modules_install
make install
rm -f /boot/initrd-2.6.19.1.img
mkinitrd /boot/initrd-2.6.19.1.img 2.6.19.1

Connecting to MSSQL from PHP in Linux

Saturday, February 10th, 2007

Installing FreeTDS

wget ftp://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz
./configure \
–prefix=/usr/local/freetds \
–enable-msdblib
make
make install

Configuring php

./configure \
–with-apxs2=/usr/local/apache/bin/apxs \
–with-openssl \
–enable-track-vars \
–with-mysql=/usr/local/mysql/ \
–with-mssql=/usr/local/freetds

Sample Code

$s = “server:1433”;
$u = “sa”;
$p = “password”;

$msconnect=mssql_connect ($s,$u,$p);
$msdb=mssql_select_db(“Northwind”,$msconnect);
$msquery = “select titleofcourtesy,firstname,lastname from employees”;
$msresults= mssql_query($msquery);
$msconnect=mssql_connect ($s,$u,$p);
$msdb=mssql_select_db(“Northwind”,$msconnect);
$msquery = “select titleofcourtesy,firstname,lastname from employees”;
$msresults= mssql_query($msquery);
while ($row = mssql_fetch_array($msresults)) {
echo $row[‘titleofcourtesy’] .” “. $row[‘firstname’] .” “. $row[‘lastname’] ;
}