PHP for maximum performance.

" />
x
Loading
 Loading
Hello, Guest | Login | Register

Optimizing PHP, Part Three

This article shows you how to configure and compile PHP for maximum performance.

Last month’s “Tech Support” column showed you how to install and configure the Alternative PHP Cache to speed up your PHP applications without changing any code. This month, let’s go one level deeper in the stack and tune your PHP installation itself.

While pre-packaged binaries are convenient, high-traffic sites typically need a roll-your-own PHP and Apache to fine-tune features and yield extra performance. Start with the latest version of PHP. The 5.1x branch has finally brought PHP 5 performance up to an acceptable level, and includes many advances over PHP 4. After downloading and unpacking the latest version of PHP 5 (5.1.4 as the magazine went to press), set your CFLAGS, an environment variable for compiler flags that are passed to gcc. The correct compiler flags depend on what kind of machine you have, what kind of CPU you have, how much cache the CPU has, and a variety of other factors.
Here are two examples, the first for the Xeon processor and the other for the Opteron.
$ export CFLAGS="–march=pentium4 –O3 
–pipe –msse2 –mfpmath=sse,387
–mmmx –fomit-frame-pointer
–prefer-non-pic”
$ export CFLAGS="–march=opteron –O3 
–pipe –msse2 –m3dnow
–fomit-frame-pointer –mtune=opteron”
The one major difference between the two commands other the obvious architecture (–march) variance, is the –prefer-non-pic option, which tells the build process to build a non-PIC version of libphp. Non-PIC, or position-independent code, is only supported on the x86 architecture in conjunction with certain…

Please log in to view this content.

Not Yet a Member?

Register with LinuxMagazine.com and get free access to the entire archive, including:

  • Hands-on Content
  • White Papers
  • Community Features
  • And more.
Already a Member?
Log in!
Username

Password

Remember me

Forgotten your password?
Forgotten your username?
Read More
  1. Helpful Tools for Software Developers
  2. The Github Hall of Fame
  3. Book'em, Github.
  4. This Week on Github: Stupid Ruby Tricks
  5. A Veritable Scatter Shot!
Follow Linux Magazine
Rackspace