? Earlier 4 items total Later ?

On this page:?

Parse .html files as PHP

To parse files with a .html extension as PHP, add this line to httpd.conf, your VirtualHost container, or .htaccess:
AddHandler application/x-httpd-php .html

You can substitute your own arbitrary file extensions for .html if you want to use, for example, filename.foo on your site.

Disallow serving of PHP pages if mod_php is not loaded

If mod_php doesn't load for some reason, your PHP files may be served unparsed, as plain text. This presents the possibility that your database passwords or other senstive information may be visible. Adding the following to your httpd.conf, VirtualHost container, or .htaccess file will deny access to any PHP files if the PHP module is not loaded.


    
        Order allow,deny
        Deny from all
        Allow from none
    


Turn off (mostly) useless apache modules

When I first ported my old Php app to Textdrive, I got all manners of weird errors. Many of these were from weird Apache modules that are enabled by default here.

My solution was to turn off most of these things in my .htaccess file. Here it goes:

# let Apache recognize the ".php" extension
AddType application/x-httpd-php .php
DefaultType application/x-httpd-php

# make php use this very uncool default charset I had been using for years
php_value default_charset iso-8859-1

# make php define old style global variables
php_flag register_long_arrays On

# stop Apache from spewing "Charset: utf-8"
AddDefaultCharset Off

# stop Apache from silently mangling urls
CheckSpelling Off

# stop Apache from denying perfectly legitimate requests
SecFilterEngine Off

Suexec'ed PHP-FastCGI on Apache2

A PHP cgi binary compiled with fcgi support

> /usr/local/www/cgi-bin/php5-fcgi -v
PHP 5.0.3 (cgi-fcgi) (built: Dec 30 2004 22:44:32)


Central config in httpd.conf


FastCgiIpcDir /usr/local/www/fcgi_ipc/tmp
AddHandler fastcgi-script .fcgi
FastCgiSuexec /usr/local/sbin/suexec
FastCgiConfig -singleThreshold 100 -killInterval 300 -autoUpdate -idle-timeout 240 -pass-header HTTP_AUTHORIZATION


Options ExecCGI        
SetHandler fastcgi-script



In a virtual host

SuexecUserGroup ${USER} ${GROUP}
ScriptAlias /php-fastcgi/ ${HOME}/php-fastcgi/ 
AddType application/x-httpd-fastphp .php
Action application/x-httpd-fastphp /php-fastcgi/php5-fcgi


And then the ${HOME}/php-fastcgi/php5-fcgi wrapper

#!/bin/sh 
PHPRC="/usr/local/etc" 
export PHPRC 
PHP_FCGI_CHILDREN=8 
export PHP_FCGI_CHILDREN 
PHP_FCGI_MAX_REQUESTS=5000 
export PHP_FCGI_MAX_REQUESTS 
exec /usr/local/www/cgi-bin/php5-fcgi 


The PHPRC environment sets the directory where php.ini is to be found

? Earlier 4 items total Later ?