Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Which of these 2 is easier/faster for a Linux server running Apache to process?

A) A symlink pointing to a php file:

file-sym.php ---> file-orig.php

B) A PHP file (file-inc.php) including another PHP file (file-orig.php) like so:

Contents of file-inc.php


Curious if anyone has done any benchmarks!

share|improve this question
up vote 2 down vote accepted

My gut reaction tells me the symlink will be faster, because you will have to read less data when handling the first link in that chain. I'm not sure there is much of a difference though, try benching the two to see a difference.


  1. read file (on ext2+ symbolic links are included in the inode, hence only one seek)
  2. read other file
  3. execute php


  1. read file
  2. execute php
  3. read other file
  4. execute php

The include() variant is good for Windows users I guess, since they can't have symlinks on their systems.

share|improve this answer
awesome, makes sense and glad you pointed out that there would only be one seek on ext2+ systems. – filip Dec 21 '10 at 18:33

Many administrators disable apache symlinks for security and performance reasons.

For performance purposes, please view this page on apache tuning:

Wherever in your URL-space you do not have an Options FollowSymLinks, or you do have an Options SymLinksIfOwnerMatch Apache will have to issue extra system calls to check up on symlinks. One extra call per filename component. For example, if you had:

 <Directory />
 DocumentRoot /www/htdocs 
 Options SymLinksIfOwnerMatch

and a request is made for the URI /index.html. Then Apache will perform lstat(2) on /www, /www/htdocs, and /www/htdocs/index.html. The results of these lstats are never cached, so they will occur on every single request.

You can see how symlinks can be an exponential performance problem depending on your environment and code.

share|improve this answer
that's quite interesting. Would you suggest that the PHP include(); method may overall be better if symlinks are turned off? – filip Dec 21 '10 at 20:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.