I just had the craziest experience. I was working with my rustic old Apache, getting ready to switch to Nginx. I set up php-fpm and created an application per user. As not to change too many things I switched Apache over to use php-fpm before setting Nginx up to use php-fpm. Once I got everything over to Nginx I decided I wanted to do a quick side by side page loading experience. To my surprise my low dynamic content PHP site took .27 seconds longer on Nginx (which it consistently had done) versus my decrepit, monolithic Apache server!
Come to find out all the tests you may have seen before, which showed Apache being absolutely destroyed by Nginx, seem to have a single flaw; mod_php sucks, a lot. There’s no mod_php for Nginx so the comparison between the two web servers is vastly exaggerated. In my case the Apache server was running faster than Nginx for page load times. Next time you see speed comparisons, it may pay to look and make sure you’re comparing apples to apples. You just might find that you’re comparing a software stack that utilizes better processes and isn’t necessarily incompatible with the stack you’re currently running.
I’m very happy that the results were what they were because after I setup Nginx I totally forgot that it isn’t compatible with .htaccess files! WordPress loaded but wasn’t too keen on functioning properly without it’s precious mod_rewrite rules it generated. While that wouldn’t necessarily be a problem for me I couldn’t leave my users hanging and I’m not going to rewrite their WordPresses myself.
SEPTEMBER 2ND, 2010
By VEX
This was an interesting problem I just encountered. While moving a virtual host from an older Apache server to a more modern Apache server the customer’s site on the new server wanted us to download all the htm files. On initial inspection the first oddity I discovered was that they were registering .htm and .html files with the x-httpd-php mod_php module in their .htaccess file.
AddType application/x-httpd-php .html .htm
After over coming the initial wave
of announce I started checking the obvious things. First I made sure php was working at all. Because .php files were loading I knew that mod_php was loaded for this virtual host. I checked the handler for it to make certain that x-httpd-php was being used. I also tried x-httpd-php5. Upon downloading the files I noticed that they were unprocessed by php. Lastly I checked the AllowOverride directive, only finding that our server allows all overrides.
Finally I stumbled on to the problem. There already was an AddType for .html and .htm files along with .shtml .shtm files. The mod_include, the server side include or ssi for short, module was registering them and Apache was not replacing that with what was in the vhost’s .htaccess file. The first solution to the problem was to remove the .htm and .html files from mod_include. The problem with my first solution was that if anyone was using mod_include and using .htm and .html files they would just stop working.
My final solution to the problem was to RemoveType .htm and .html before AddType .htm and .html . Keep in mind that most browsers cache the file and the mime type. I had to clear my browser cache before I was successfully able to view the site. Below is the final configuration.
RemoveType .htm .html
AddType application/x-httpd-php .html .htm