First some background on how I installed PHP, Apache, and some Apache modules:
# apt-get -y install php5 php-pear libapache2-mod-php5 php-apc php5-mysql php5-mcrypt php5-xmlrpc php5-curl php5-imagick php5-gd php5-imap php5-pspell
# apt-get -y install apache2 apache2-doc apache2-utils
# a2enmod setenvif headers deflate filter expires rewrite include
And my httpd.conf file looks like this (i.e. I've essentially disabled .htaccess, and have all the rules in the httpd.conf instead):
<Directory /var/www/example.com/public>
AllowOverride None
[...]
</Directory>
Considering that it'd give you a basic idea of how my webserver is set up, I'd like to go ahead and ask the questions:
-
Is it true that Apache is comparatively slow at serving static content with PHP installed? (I guess.)
-
Lets say, my website's root directory is '/var/www/example.com/public', and I've all the static content (CSS, JS, images) in '/var/www/example.com/public/uploads'; How do I overcome Problem (1) without having to move all static content to a server that doesn't have PHP installed?
Best Answer
It depends on how do you configure apache with php, how you optimize your configuration. If php is configured with CGI interface, then apache will pass only certain type of files to the php externally (same way as done with nginx for example), so there is 0 impact on other files, in case of module it might be faster with dynamic pages, because it's not calling php externally, but might be slower for others because php module is loaded with apache all the time, despite it's still active only for certain type of files (according to mimetype).
Yes/No
Use mod_fcgid with php
Example of php configured as module, which parses only .php files (RHEL5/6, Fedora):