Adding APC to MediaTemple Grid Service

I have a client that wanted to start his own personal blog. He’s in the IT industry and wanted to use WordPress, he didn’t know what Shared Hosting Provider to go with. I suggested two, dreamhost.com and mediatemple.com

I don’t like shared hosting, why? It’s either slow at time for hours or always slow, so instead I just grab a VPS and pay the $30 or $50 month so my sites load fast. You could even ditch your Grid Service and go with a Dedicated Virtual, and achieve lighting fast page loads on your WordPress/PHP site.

Anyways, lets talk more about how to setup APC properly on the Grid Service. I mean lets really talk about it, because I always forget the steps.

You will need to first download the latest stable version of APC, I’ve had issues with the beta version and the stable version. But far less with the stable version. If you want to pick and choose which version to run visit the APC PECL Website directly at http://pecl.php.net/package/APC

I almost forgot, if you want to follow the instructions in this guide. You will need to have SSH access enabled on your Grid Service account. This guide will assist you.

http://kb.mediatemple.net/questions/16/Connecting+via+SSH+to+your+(gs)+Grid-Service

Once you have access and the URL to the latest stable release of APC (3.0.19 as of this writing). You will want to wget the file to the root of your account.

wget http://pecl.php.net/get/APC-3.0.19.tgz

Decompress and untar the archive, change directory to the extracted contents and phpize the module.

tar -zxvf APC-3.0.19.tgz
cd APC-3.0.19

Next you will want to run phpize. The phpize command prepares the PECL modules build environment.  Once you run phpize you will see something similar to the following:

server@n10:~/APC-3.0.19$ phpize
Configuring for:
PHP Api Version:         20020918
Zend Module Api No:      20020429
Zend Extension Api No:   20050606

Now we want to set the configuration options for the module. You will need to find out what version of PHP your Grid Service is running, you need to know the Major and Minor numbers. You can get this information from phpinfo, you will need to create a new file inside your sites html directory and enter the following:


Make sure the file has a .php extension and then open up a browser and view the file. You should be presented with something like the following.

You can see that we’re running PHP 5.2.14-2, the “-2” is more or less for MediaTemples reference.

Next you want to type out the following command and run it, pay special attention to the “-with-php-config” portion as this is important, make sure you find the right location of this file then run the command.

./configure -enable-apc -enable-apc-mmap -with-apxs2=/usr/sbin/apxs -with-php-config=/usr/local/php-5.2.14-2/bin/php-config

A bunch of text should scroll, hopefully no errors. Now we want to make the module so just type “make”.

xxxxxxx.com@n10:~/APC-3.0.19$ make
/bin/sh /home/xxxxx/users/.home/APC-3.0.19/libtool --mode=compile gcc -I. -I/home/xxxxx/users/.home/APC-3.0.19 -DPHP_ATOM_INC -I/home/xxxxxx/users/.home/APC-3.0.19/include -I/home/113041/users/.home/APC-3.0.19/main -I/home/xxxxxx/users/.home/APC-3.0.19 -I/usr/local/php-5.2.14-2/include/php -I/usr/local/php-5.2.14-2/include/php/main -I/usr/local/php-5.2.14-2/include/php/TSRM -I/usr/local/php-5.2.14-2/include/php/Zend -I/usr/local/php-5.2.14-2/include/php/ext -I/usr/local/php-5.2.14-2/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /home/xxxxxx/users/.home/APC-3.0.19/apc.c -o apc.lo

-------------CUT TO SAVE SPACE--------------

----------------------------------------------------------------------
Libraries have been installed in:
/home/xxxxx/users/.home/APC-3.0.19/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
(It is safe to ignore warnings about tempnam and tmpnam).

Now we just need to make the appropriate directories for the module to reside. The directory you need to find is called “data”, if you follow these steps below you can navigate to the directory. Then make the proper directories, and then copy the module.

cd ~/
cd ../..
cd data
mkdir -p lib/php
cp ~/APC-3.0.19/modules/apc.so

The last step is to modify the php.ini and have PHP load the newly created apc.so module. (Note: in the second example, the ‘xxxx’ stands for your user number, you can find this by running “pwd”)

nano ~/../../etc/php.ini
or
nano /home/xxxx/etc/php.ini

Then just add the following lines:

extension_dir = /home/113041/data/lib/php
extension = apc.so

You should now have APC loaded into PHP, double check by going to the phpinfo page you made and search for APC. It should give you some information and configuration variables. Furthermore, if APC is not being loaded and shown on the phpinfo page, enable the error log (http://wiki.mediatemple.net/w/GS:Read_access_logs_and_error_logs) and see if any error messages are being generated.

Hope you enjoy!

0 Shares:
You May Also Like

Fastcgi and the dreaded aborted: select() failed

I was getting reports of "500 Internal Server Errors" on two of my web servers. And after further investigation it looks like it was related to the following error.

(4)Interrupted system call: FastCGI: comm with server "php-fastcgi.fcgi" aborted: select() failed

After doing some reasearch I stumbled upon the following patch.

http://groups.google.com/group/linux.debian.bugs.dist/browse_thread/thread/3de22bc415d3da02?pli=1

Apples iPhone Firmware 2.0.2 Causes More Issues Than It Fixes

I just saw this article on Slashdot... Slashdot | Apple's IPhone 3G Firmware Update Bombs Yahoo posted the news article... Apple's iPhone 3G Firmware Update Bombs (NewsFactor) by NewsFactor: Yahoo! Tech Both articles comment on the 2.0.1 firmware. However if you read the original article, it speaks about the new firmware which is 2.0.2 and was released on the 18th. NewsFactor Network | Apple Reportedly Plans Another Fix for the iPhone Either way, I don't have problems with my phone aside from MobileChat crashing and other Applications as well.

Bitcoin Miner

Purchased 2x Sapphire 5830’s and a 1000W OCZ refurb. More from my siteiriver W10 revealed on teaser siteOfficeSpot.Net Collaboration Server…