Advanced PHP Configuration

We are please to announce that we now not only support the choice of PHP4 and PHP5 on a per domain basis, but also choosing the PHP mode/environment on the following shared servers:

Supported Servers:

web10.pipeten.co.uk

  • PHP4 fastcgi (default) or cgi
  • PHP5 libphp5 (default), fastcgi or cgi

dweb4.pipeten.co.uk

  • PHP4 fastcgi (default) or cgi
  • PHP5 libphp5 (default), fastcgi or cgi

dweb16.pipeten.co.uk

  • PHP4 fastcgi (default) or cgi
  • PHP5 libphp5 (default), fastcgi or cgi

dweb30.pipeten.co.uk

  • PHP4 fastcgi (default) or cgi
  • PHP5 libphp5 (default), fastcgi or cgi

Customers using our Integrated Cloud or Physical Servers should contact support if this functionality is required.

Mode configuration:

For customers wanting speed and simplicity with PHP5 should choose mode libphp5. libphp5 runs as the web server user httpd.httpd and as such you may need to reset the ownership on uploaded files occasionally or chown/chgrp them after upload.

For customers wanting improved security but with a trade-off of slightly reduced performance should choose PHP4 or PHP5 mode fastcgi. fastcgi runs as your own user.group which improves the security of writeable files and directories.

For customers with application specific needs should only choose mode cgi as performance can highly be degraded during periods of high load.

Additional configuration:

If you are looking to further tweak PHP then all PHP versions and modes now support .htaccess based over-ride. Some common examples of these are below, other items may be restricted due to nature of shared hosting.

Hide all PHP errors

php_flag display_startup_errors off
php_flag display_errors off

Display all PHP errors

php_flag display_startup_errors on
php_flag display_errors on
php_value error_reporting 2147483647

Logging PHP errors to file

# you will need to create the ‘sessions’ directory in your accounts FTP root with appropriate permissions.
php_flag  log_errors on
php_value error_log  /hsphere/local/home/username/PHP_errors.log

Turn on register_globals (not generally recommened):

php_flag register_globals 1

Store PHP session data in target directory:

# you will need to create the ‘sessions’ directory in your accounts FTP root with appropriate permissions.
php_value session.save_path /hsphere/local/home/username/sessions/

Turn on zlib/gzip compression:

php_flag zlib.output_compression 1
php_value zlib.output_compression_level 8
php_flag display_errors 1

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml
AddOutputFilterByType DEFLATE application/javascript application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary

ExpiresActive On
ExpiresDefault A300
ExpiresByType image/x-icon A2592000
ExpiresByType application/x-javascript A3600
ExpiresByType text/css A3600
ExpiresByType image/gif A604800
ExpiresByType image/png A604800
ExpiresByType image/jpeg A604800
ExpiresByType text/plain A300
ExpiresByType application/x-shockwave-flash A604800
ExpiresByType video/x-flv A604800
ExpiresByType application/pdf A604800
ExpiresByType text/html A300

If you think of any other handy PHP related .htaccess tricks our customers might benefit from, please let us know add we’ll and them here.

Otherwise you can find more general .htaccess tricks in our .htaccess cheat sheet post.

This entry was posted in Linux & PHP, Reseller, Tips & Tricks and tagged , . Bookmark the permalink.

One Response to Advanced PHP Configuration

  1. Pingback: Logging PHP Errors using .htaccess | Web Hosting Resource

Leave a Reply

Please DO NOT use this form to submit support requests, all information submitted will be PUBLICLY VISIBLE.

Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>