Skip to main content

PHP / MySQL

Repair and Optimize MySQL databases in SSH

SSH repair and optimize all MySQL databases:

/usr/bin/mysqlcheck --repair --all-databases --password
/usr/bin/mysqlcheck --optimize --all-databases --password=xxxxxx

RESOLVED: mysqld won't start

In case your mysqld won't work with

# service mysqld restart
or
# service mysqld start
or
# service mysqld stop

do this:

# killall mysqld

followed by:

HOW-TO: Install Eaccelerator (Turck MMCache replacement)

Install/Update eaccelerator:

cd /ea
rm -rf ./eaccelerator*
rm -rf /usr/local/lib/php/extensions/no-debug-non-zts-*
wget http://downloads.sourceforge.net/project/eaccelerator/eaccelerator/eAccelerator%200.9.6.1/eaccelerator...
tar xvfj eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1
export PHP_PREFIX="/usr/local"
$PHP_PREFIX/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
make
make install
cd /tmp
rm -fr /tmp/eaccelerator
mkdir /tmp/eaccelerator
chmod 0777 /tmp/eaccelerator
vi /usr/local/lib/php.ini

Add/Edit right after "Windows Extensions":

zend_extension="/ea/eaccelerator-0.9.5.3/modules/eaccelerator.so"
eaccelerator.shm_size="32"

HOW TO INSTALL/UPGRADE MySQL

rm /var/cpanel/mysqlup

That will stop upcp from touching MySQL.

To upgrade manually

If you upgrade manually you need to remember to create the file:

#touch /etc/mysqlupdisable

(Otherwise upcp will simply downgrade it again.)

PHP OOP tips

SitePoint

MysqlConnectClass (good explanation of thinking the OOP way):
http://www.sitepoint.com/forums/showpost.php?p=683454&postcount=4

Advanced PHP Resources:
http://www.sitepoint.com/forums/showthread.php?t=78687

A HOWTO on Optimizing PHP

source: phplense.com
Last revised 4 Jan 2004.

PHP is a very fast programming language, but there is more to optimizing PHP than just speed of code execution.