備忘技術分享

Dreamhost 安裝APC

[code lang=”shell”]
#!/bin/sh
#————————————————————————
#
# Dreamhost APC Install Script for PHP 5.3 Domains
# by Gary Saunders (http://www.bookerthedog.com)
#
#————————————————————————

# Exit if there’s an error
set -e

# Clear the screen
clear

echo Setting up…
# Modify as required, defaults work for 99% of things.
LOGILE=apcinstall.log
PHPDIR=$HOME/.php/5.3
APCVERSION=3.1.9
APCURL=http://pecl.php.net/get/APC-$APCVERSION.tgz
APCDIR=$HOME/APC-$APCVERSION

echo Downloading and extracting APC-$APCVERSION.tgz…
# Change into user home directory, download and extract the APC files
cd $HOME
wget $APCURL
tar -xvf APC-$APCVERSION.tgz
cd $APCDIR

echo PHPIZE and building APC…
# Prepare and install the modules
phpize
./configure –with-php-config=/usr/local/php53/bin/php-config; make
mkdir -p $PHPDIR
cp modules/apc.so $PHPDIR
echo extension=$PHPDIR/apc.so >> $PHPDIR/phprc

echo Done, cleaning up the stuff we downloaded…
# Delete the downloaded APC files, don’t need them anymore
rm $HOME/APC-$APCVERSION.tgz
rm $HOME/package.xml
rm -rf $APCDIR

echo Killing any existing PHP5 stuff just incase.
# Kill the PHP stuff, just in case it’s running
killall php5.cgi 1> /dev/null
killall php53.cgi 1> /dev/null

exit 0
[/code]

執行完後會在
/user/username/.php/5.3/裡產生apc.so
接著再編輯phprpc

[code lang=”php”]
extension=/home/username/.php/5.3/apc.so
[apc]
apc.enabled=1
apc.shm_segments=1
apc.shm_size=16
apc.ttl=7200
apc.user_ttl=7200
apc.num_files_hint=1024
apc.mmap_file_mask=/home/username/tmp/apc.XXXXXX
apc.enable_cli=1
[/code]

接著再執行

[code lang=”shell”]
killall -9 php53.cgi
[/code]

然後稍等約2~3分鐘後,就支援APC了!