News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Ben_S - How do you have APC configured ?

Started by Niteblade, June 12, 2006, 08:39:29 PM

Previous topic - Next topic

Niteblade

Ben_S, I've been noticing from your posts that you like APC a lot. And you wouldn't like it if it didn't work - especially with SMF. I'm curious to know what *your* APC settings look like (mainly because I'm inferior when it comes to programming and the like). Also, when I set the cache level to "3," I definately see a CPU usage increase (400 CPU seconds per day) as is warned in the server settings menu inside the SMF admin menu -- therefore I set it back to "1" and have seen a great decrease (80-90 CPU seconds per day).

Here's my APC configuration :

apc.cache_by_default = On
apc.enable_cli = Off
apc.enabled = On
apc.file_update_protection = 2
apc.filters = no value
apc.gc_ttl = 3600
apc.max_file_size = 1M
apc.mmap_file_mask = no value
apc.num_files_hint = 1000
apc.optimization = Off
apc.shm_segments = 1
apc.shm_size = 64
apc.slam_defense = Off
apc.stat = On
apc.ttl = 0
apc.user_entries_hint = 100
apc.user_ttl = 0

I'm on shared hosting, btw.

THANKS!
affiliate blog

Teckinno

#1
Could you be kind and post your APC install steps on Dreamhost shared host?
I use a custom PHP script installer that I wrote, for 5.1.4 version.
I got working easy eAccelerator on Dreamhost, but prefer APC.

This is what I did so far:
[server]$ mkdir src
[server]$ cd src
[server]$ wget http://pecl.php.net/get/APC-3.0.10.tgz
[server]$ gunzip -c APC-3.0.10.tgz | tar xf –
[server]$ cd APC-3.0.10
[server]$ /home/dreamuser/local/bin/phpize
[server]$ ./configure –enable-apc –enable-apc-mmap –with-php-config=/home/dreamuser/local/bin/php-config
[server]$ make
[server]$ make install
[server]$ cp /home/dreamuser/local/lib/php/extensions/no-debug-non-zts-20050922/apc.so /home/dreamuser/local/lib

Once the apc.so [nofollow] is in /home/dreamuser/local/lib, I don't need to define the extension_dir, since it's looking there for the files. eaccelerator.so [nofollow] is there and working fine.

In php.ini, I added the following lines, under Dynamic Extensions:
; APC
extension = "apc.so"


I should also define the --with apxs=/path/here option(?), but I don't know where is located the Apache server.
Waiting with a response from Dreamhost.

Thank you helping out.

Ben_S

I'm running the default config, only thing I've changed is setting apc.shm_size to 64.

Depending on the server, your milage with different levels will vary so it's probably best to experiment and see what works best. Level 3 works fine for me.
Liverpool FC Forum with 14 million+ posts.

Niteblade

Quote from: Teckinno on June 13, 2006, 02:45:10 AM
Could you be kind and post your APC install steps on Dreamhost shared host?

Everything I have is here. Just experiment like I did. What I have here worked for me, and I'm not sure if it'll work for you too.
affiliate blog

Teckinno

Thanks, I will try it. So far, you did what I did. :)
I contacted Dreamhost, they will post the apxs path and they will restart Apache for me.
I will post the results, once I have them.

Cheers.

Niteblade

SMF says that I have APC installed. However, I never used the --with apxs=/path/here switch to install APC. Therefore, I don't know if SMF is giving me a false positive where it thinks APC is installed, but APC really isn't doing anything.
affiliate blog

Ben_S

Copy the apc.php file to a web accessable directory and browse to it to see if it is being used.
Liverpool FC Forum with 14 million+ posts.

Niteblade

Ben_S,

I have it here : http://www.pennyquick.com/apc.php .

Free: 63.6 MBytes (99.4%)
Used: 391.8 KBytes (0.6%)

And it never has once deviated from these numbers. Should it deviate ?
affiliate blog

Niteblade

Quote from: Teckinno on June 13, 2006, 11:15:26 PM
Thanks, I will try it. So far, you did what I did. :)
I contacted Dreamhost, they will post the apxs path and they will restart Apache for me.
I will post the results, once I have them.

Cheers.

Keep me up to date as to what dreamhost tells you. Also, when you have APC working with that apxs switch, do a compare and contrast with in the information contained in my apc.php file your apc.php file. I'm really curious.
affiliate blog

Ben_S

Quote from: nite0859 on June 14, 2006, 05:42:09 PM
Ben_S,

I have it here : http://www.pennyquick.com/apc.php .

Free: 63.6 MBytes (99.4%)
Used: 391.8 KBytes (0.6%)

And it never has once deviated from these numbers. Should it deviate ?

Doesn't look like it's being used to me (unless it's a very lightly loaded server - mine looks like http://www.redandwhitekop.com/forum/apc.php), to check for sure look at the user cache entries page - you will need to set a password within the apc.php itself, just open it with a text editor and find the relevant part.
Liverpool FC Forum with 14 million+ posts.

Niteblade

#10
Quote from: Teckinno on June 13, 2006, 11:15:26 PM
Thanks, I will try it. So far, you did what I did. :)
I contacted Dreamhost, they will post the apxs path and they will restart Apache for me.
I will post the results, once I have them.

Cheers.

I found apxs ... updated my site.

Telnet to your site.
Then do command '$> locate apxs'
You'll see several results. I chose one at random.

I'm now using this as a configuration for APC ..

extension_dir = "/home/****/php/lib/php/extensions/no-debug-non-zts-20050922/"
extension=apc.so
apc.cache_by_default = On
apc.enabled = On
apc.enable_cli = off
apc.file_update_protection = 2
apc.filters = no value
apc.gc_ttl = 3600
apc.max_file_size = 1M
apc.mmap_file_mask = /home/****/tmp/apc.XXXXXX
apc.num_files_hint = 1000
apc.optimization = Off
apc.shm_segments = 1
apc.shm_size = 64
apc.slam_defense = Off
apc.stat = On
apc.ttl = 0
apc.user_entries_hint = 100
apc.user_ttl = 0

We'll see ...
affiliate blog

Teckinno

#11
Something is definitely wrong. Every time you refresh that page, the start time is reset to the time you refreshed the page, showing always 0 minutes of uptime:
http://www.adolympics.com/apc.php [nofollow]

My config:
; APC
extension = "apc.so"
apc.enabled = 1
apc.shm_segments = 1
apc.optimization = 0
apc.shm_size = 32
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


So it's not working. Other then that, the install went perfectly.
It must be related to the PHP compile configuration.
This is what I used to compile PHP (I made my own Unix script):

print_step "Starting the PHP configuration..."
cd ~
cd $HOME/$SRC_DIR/$PHP5
export PATH=$HOME/$PHP_DIR/bin:$PATH
./configure \
--prefix=$HOME/$PHP_DIR \
--enable-calendar \
--enable-exif \
--enable-fastcgi \
--enable-force-cgi-redirect \
--enable-ftp \
--enable-gd-native-ttf \
--enable-mbstring \
--enable-mbregex \
--enable-memory-limit \
--enable-soap \
--enable-sockets \
--enable-sqlite-utf8 \
--enable-wddx \
--with-config-file-path=$HOME/$ETC_DIR \
--with-curl=$HOME/$PHP_DIR \
--with-freetype=$HOME/$PHP_DIR \
--with-gd \
--with-gettext \
--with-iconv=$HOME/$PHP_DIR \
--with-imap=$HOME/$SRC_DIR/$IMAP \
--with-imap-ssl=/usr \
--with-jpeg-dir=/usr \
--with-libxml-dir=/usr \
--with-mcrypt=$HOME/$PHP_DIR \
--with-mhash=$HOME/$PHP_DIR \
--with-mysql=/usr \
--with-mysqli \
--with-openssl=/usr \
--with-png-dir=/usr \
--with-xml \
--with-xsl=/usr \
--with-zlib-dir=$HOME/$PHP_DIR \
--without-pear
make
install_ok
make install
install_ok

Ben_S

Liverpool FC Forum with 14 million+ posts.

Niteblade

with the ionCube PHP Loader v3.1.16, Copyright (c) 2002-2006, by ionCube Ltd.

Maybe APC is conflicting with that because I believe ionCube is already an accelerator ?
affiliate blog

Niteblade

#14
Another possibility : Maybe PHP5 needs to be compiled with apxs, too ...

I'm rebuilding using a new install script ...

#!/bin/bash

# Abort on any errors
set -e

# The domain in which to install the PHP CGI script.
export DOMAIN="pennyquick.com"

# Where do you want all this stuff built? I'd recommend picking a local
# filesystem.
# ***Don't pick a directory that already exists!***  We clean up after
# ourselves at the end!
SRCDIR=${HOME}/source

# And where should it be installed?
INSTALLDIR=${HOME}/php

# Set DISTDIR to somewhere persistent, if you plan to muck around with this
# script and run it several times!
DISTDIR=${HOME}/dist

# Update version information here.
php="php-5.1.4"
LIBICONV="libiconv-1.10"
LIBMCRYPT="libmcrypt-2.5.7"
LIBXML2="libxml2-2.6.24"
LIBXSLT="libxslt-1.1.16"
MHASH="mhash-0.9.6"
ZLIB="zlib-1.2.3"
CURL="curl-7.15.3"
LIBIDN="libidn-0.6.3"
CCLIENT="c-client"
CCLIENT_DIR="imap-2004g" # Another pest!
M4="m4-1.4.4"
LIBTOOL="libtool-1.5.22"
AUTOCONF="autoconf-2.59"
AUTOMAKE="automake-1.9.6"
#ASPELL="aspell-0.60.4"
APC="APC-3.0.10"

# What PHP features do you want enabled?
PHPFEATURES="--prefix=${INSTALLDIR} \
--with-config-file-path=${INSTALLDIR}/etc/php/${DOMAIN} \
--enable-force-cgi-redirect \
--with-xml \
--with-libxml-dir=${INSTALLDIR} \
--enable-soap \
--with-openssl=/usr \
--with-mhash=${INSTALLDIR} \
--with-mcrypt=${INSTALLDIR} \
--with-zlib-dir=${INSTALLDIR} \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-gd \
--enable-gd-native-ttf \
--enable-ftp \
--with-exif \
--enable-sockets \
--enable-wddx \
--with-iconv=${INSTALLDIR} \
--enable-sqlite-utf8 \
--enable-calendar \
--with-curl=${INSTALLDIR} \
--enable-mbstring \
--enable-mbregex \
--with-mysql=/usr \
--with-mysqli \
--with-pear-dir=/home/nite/pear \
--with-gettext \
--with-imap=${INSTALLDIR} \
--with-imap-ssl=/usr \
--enable-fastcgi \
--enable-trans-sid \
--enable-bcmath \
--with-ttf=/usr \
--with-freetype-dir=/usr \
--enable-exif \
--with-apxs=/usr/local/dh/apache2/template/sbin/apxs"
#--with-aspell=${ASPELL}"
# ---- end of user-editable bits. Hopefully! ----

# Push the install dir's bin directory into the path
export PATH=${INSTALLDIR}/bin:$PATH

#setup directories
mkdir -p ${SRCDIR}
mkdir -p ${INSTALLDIR}
mkdir -p ${DISTDIR}
cd ${DISTDIR}

# Get all the required packages
wget -c http://us2.php.net/distributions/${php}.tar.gz
wget -c http://ftp.gnu.org/pub/gnu/libiconv/${LIBICONV}.tar.gz
wget -c http://easynews.dl.sourceforge.net/sourceforge/mcrypt/${LIBMCRYPT}.tar.gz
wget -c http://ftp.acc.umu.se/pub/GNOME/sources/libxml2/2.6/${LIBXML2}.tar.gz
wget -c http://ftp.acc.umu.se/pub/GNOME/sources/libxslt/1.1/${LIBXSLT}.tar.gz
wget -c http://easynews.dl.sourceforge.net/sourceforge/mhash/${MHASH}.tar.gz
wget -c http://www.zlib.net/${ZLIB}.tar.gz
wget -c http://curl.haxx.se/download/${CURL}.tar.gz
wget -c ftp://alpha.gnu.org/pub/gnu/libidn/${LIBIDN}.tar.gz
wget -c ftp://ftp.cac.washington.edu/imap/${CCLIENT}.tar.Z
wget -c http://ftp.gnu.org/gnu/m4/${M4}.tar.gz
wget -c http://ftp.gnu.org/gnu/libtool/${LIBTOOL}.tar.gz
wget -c http://ftp.gnu.org/gnu/autoconf/${AUTOCONF}.tar.gz
wget -c http://ftp.gnu.org/gnu/automake/${AUTOMAKE}.tar.gz
#wget -c ftp://ftp.gnu.org/gnu/aspell/${ASPELL}.tar.gz
wget -c http://pecl.php.net/get/${APC}.tgz

cd ${SRCDIR}
# Unpack them all
tar xzf ${DISTDIR}/${php}.tar.gz
tar xzf ${DISTDIR}/${LIBICONV}.tar.gz
tar xzf ${DISTDIR}/${LIBMCRYPT}.tar.gz
tar xzf ${DISTDIR}/${LIBXML2}.tar.gz
tar xzf ${DISTDIR}/${LIBXSLT}.tar.gz
tar xzf ${DISTDIR}/${MHASH}.tar.gz
tar xzf ${DISTDIR}/${ZLIB}.tar.gz
tar xzf ${DISTDIR}/${CURL}.tar.gz
tar xzf ${DISTDIR}/${LIBIDN}.tar.gz
uncompress -cd ${DISTDIR}/${CCLIENT}.tar.Z |tar x
tar xzf ${DISTDIR}/${M4}.tar.gz
tar xzf ${DISTDIR}/${LIBTOOL}.tar.gz
tar xzf ${DISTDIR}/${AUTOCONF}.tar.gz
tar xzf ${DISTDIR}/${AUTOMAKE}.tar.gz
#tar xzf ${DISTDIR}/${ASPELL}.tar.gz
tar xzf ${DISTDIR}/${APC}.tgz

# Build them in the required order to satisfy dependencies.

# begin custom installation
#m4 - MUST BE FIRST
cd ${SRCDIR}/${M4}
sh ./configure --prefix=${INSTALLDIR}
make
make install

#libtool - MUST BE SECOND
cd ${SRCDIR}/${LIBTOOL}
sh ./configure --prefix=${INSTALLDIR}
make
make install

#autoconf - MUST BE THIRD
cd ${SRCDIR}/${AUTOCONF}
sh ./configure --prefix=${INSTALLDIR}
make
make install

#automake - MUST BE FOURTH
cd ${SRCDIR}/${AUTOMAKE}
sh ./configure --prefix=${INSTALLDIR}
make
make install
# end custom installation

#libiconv
cd ${SRCDIR}/${LIBICONV}
sh ./configure --enable-extra-encodings --prefix=${INSTALLDIR}
# make clean
make
make install

#libxml2
cd ${SRCDIR}/${LIBXML2}
sh ./configure --with-iconv=${INSTALLDIR} --prefix=${INSTALLDIR}
# make clean
make
make install

#libxslt
cd ${SRCDIR}/${LIBXSLT}
./configure --prefix=${INSTALLDIR} \
--with-libxml-prefix=${INSTALLDIR} \
--with-libxml-include-prefix=${INSTALLDIR}/include/ \
--with-libxml-libs-prefix=${INSTALLDIR}/lib/
# make clean
make
make install

#zlib
cd ${SRCDIR}/${ZLIB}
sh ./configure --shared --prefix=${INSTALLDIR}
# make clean
make
make install

#libmcrypt
cd ${SRCDIR}/${LIBMCRYPT}
sh ./configure --disable-posix-threads --prefix=${INSTALLDIR}
# make clean
make
make install

#libmcrypt lltdl issue!!
cd  ${SRCDIR}/${LIBMCRYPT}/libltdl
sh ./configure --prefix=${INSTALLDIR} --enable-ltdl-install
make
make install

#mhash
cd ${SRCDIR}/${MHASH}
sh ./configure --prefix=${INSTALLDIR}
# make clean
make
make install

#libidn
cd ${SRCDIR}/${LIBIDN}
sh ./configure --with-iconv-prefix=${INSTALLDIR} --prefix=${INSTALLDIR}
# make clean
make
make install

#cURL
cd ${SRCDIR}/${CURL}
sh ./configure --with-ssl=${INSTALLDIR} --with-zlib=${INSTALLDIR} \
--with-libidn=${INSTALLDIR} --enable-ipv6 --enable-cookies \
--enable-crypto-auth --prefix=${INSTALLDIR}
# make clean
make
make install

# c-client
cd ${SRCDIR}/${CCLIENT_DIR}
make ldb
# Install targets are for wusses!
cp c-client/c-client.a ${INSTALLDIR}/lib/libc-client.a
cp c-client/*.h ${INSTALLDIR}/include

#PHP 5
cd ${SRCDIR}/${php}
sh ./configure ${PHPFEATURES}
# make clean
make
make install

#APC
cd ${SRCDIR}/${APC}
/home/nite/php/bin/phpize
sh ./configure --prefix=${INSTALLDIR} --enable-apc --enable-apc-mmap --with-apxs=/usr/local/dh/apache2/template/sbin/apxs --with-php-config=/home/nite/php/bin/php-config
make
make install

#copy config file
mkdir -p ${INSTALLDIR}/etc/php/${DOMAIN};
cp ${SRCDIR}/${php}/php.ini-dist ${INSTALLDIR}/etc/php/${DOMAIN}/php.ini

#copy PHP CGI
mkdir -p ${HOME}/${DOMAIN}/cgi-bin
chmod 0755 ${HOME}/${DOMAIN}/cgi-bin
cp ${INSTALLDIR}/bin/php ${HOME}/${DOMAIN}/cgi-bin/php.cgi
echo ---------- INSTALL COMPLETE! ----------


I'll post back with the results in a few minutes.
affiliate blog

Elmacik

And y'all, when we edit a file, it does not affect anything. How to ensure that the new file is used after we edit it?
Home of Elmacik

Teckinno

Quote from: nite0859 on June 15, 2006, 08:32:42 PM
Another possibility : Maybe PHP5 needs to be compiled with apxs, too ...
I'll post back with the results in a few minutes.
It might be the answer... Let me know. Thanks

Niteblade

Quote from: Teckinno on June 15, 2006, 11:22:23 PM
Quote from: nite0859 on June 15, 2006, 08:32:42 PM
Another possibility : Maybe PHP5 needs to be compiled with apxs, too ...
I'll post back with the results in a few minutes.
It might be the answer... Let me know. Thanks

I get a permission denied error.

Since we're on shared hosting and using shared memory, it'd be nice if we can specify that the accelerator use disk-caching or something ... instead of caching files to memory.
affiliate blog

Niteblade

affiliate blog

Teckinno

APC is much better then eAccelerator...
I can get eA working very easy... however it's not as performant as APC.
There is a guy who got working APC on Dreamhost shared, so it is possible to make it work.. I wait for his reply, so far no response.

Advertisement: