terça-feira, 21 de abril de 2009

(Script Shell) Instalar o eAccelerator 0.9.5.3 no Apache 2.2.11 e PHP 5.2.6 no Debian e Ubuntu

Criar o seu arquivo de Shell Script e copiar em baixo:

#!/bin/sh

###########################################
##### Instalar o eaccelerator no PHP5 #####
###########################################

## Variaveis de comandos ##
APACHE=$(which apache2)
PHP5=$(which php5)
PHPIZE5=$(which phpize5)
PHPCONFIG5=$(which php-config5)
WGET=$(which wget)
CHMOD=$(which chmod)
TAR=$(which tar)
MAKE=$(which make)

if [ "$USER" = 'root' ] ; then
if ! [ -x $APACHE ] ; then
aptitude install apache2
fi

if ! [ -x $PHP5 -a -x $PHPIZE5 -a -x $PHPCONFIG5 ] ; then
aptitude install php5 php5-dev build-essential
fi

if ! [ -f /etc/php5/conf.d/eaccelerator.ini ] ; then
cd /opt/
$WGET -c http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2
$CHMOD +x eaccelerator-0.9.5.3.tar.bz2
$TAR xvfj eaccelerator-0.9.5.3.tar.bz2
cd /opt/eaccelerator-0.9.5.3

$PHPIZE5
./configure --with-eaccelerator-shared-memory --with-eaccelerator-sessions --with-php-config=php-config5
$MAKE
$MAKE install

echo 'extension="eaccelerator.so"' > /etc/php5/conf.d/eaccelerator.ini
echo 'eaccelerator.shm_size="16"' >> /etc/php5/conf.d/eaccelerator.ini
echo 'eaccelerator.cache_dir="/var/cache/eaccelerator"' >> /etc/php5/conf.d/eaccelerator.ini
echo 'eaccelerator.enable="1"' >> /etc/php5/conf.d/eaccelerator.ini
echo 'eaccelerator.optimizer="1"' >> /etc/php5/conf.d/eaccelerator.ini
echo 'eaccelerator.check_mtime="1"' >> /etc/php5/conf.d/eaccelerator.ini
echo 'eaccelerator.debug="0"' >> /etc/php5/conf.d/eaccelerator.ini
echo 'eaccelerator.filter=""' >> /etc/php5/conf.d/eaccelerator.ini
echo 'eaccelerator.shm_max="0"' >> /etc/php5/conf.d/eaccelerator.ini
echo 'eaccelerator.shm_ttl="0"' >> /etc/php5/conf.d/eaccelerator.ini
echo 'eaccelerator.shm_prune_period="0"' >> /etc/php5/conf.d/eaccelerator.ini
echo 'eaccelerator.shm_only="0"' >> /etc/php5/conf.d/eaccelerator.ini
echo 'eaccelerator.compress="1"' >> /etc/php5/conf.d/eaccelerator.ini
echo 'eaccelerator.compress_level="9"' >> /etc/php5/conf.d/eaccelerator.ini

mkdir /var/cache/eaccelerator
chown www-data:www-data /var/cache/eaccelerator
/etc/init.d/apache2 restart

rm -Rf /opt/eaccelerator-0.9.5.3
rm /opt/eaccelerator-0.9.5.3.tar.bz2

echo 'Sucesso instalado!';
else
echo 'Já está instalado!'
fi
else
echo 'Precisar entrar com root!';
fi

Pode testar o info PHP "<?php phpinfo(); ?>".