PHP versions [sphinx only]
The instructions in this section only apply to accounts on sphinx
During recent years PHP has evolved considerably, and scripts written to use
PHP 3 will not necessarily run under PHP 5 and vice versa. If you need to use
a different version of PHP, there are several ways to do this. Scripts with
the extension .php3
, .php4
or .php5
are
run under appropriate version. Giving the scripts a version-specific extension
is one way to select the version of PHP used.
For all newly-created shell accounts, scripts with the extension
.php
will be run as PHP 5; some older accounts defaulted to PHP 4.
(To see what version of PHP your scrips default to, type php-binfmt
-v
.) You can change the default version of PHP by running the following
mkdir -p ~/.alternatives ln -sf /software/bin/php5 ~/.alternatives/php ln -sf /software/bin/php5 ~/.alternatives/php-binfmt
Change php5
to php3
or php4
in the above
if you want an older version of PHP. Note that this will affect all sites
hosted on your account.
If you want to change the version of PHP used by files with a .php
extension for all or part of a website without affecting other sites hosted on
your account, you can do this by creating a specific .alternatives
directory for this one account:
mkdir -p ~/.alternatives cp -r ~/.alternatives ~/.alternatives-for-my-site ln -sf /software/bin/php5 ~/.alternatives-for-my-site/php ln -sf /software/bin/php5 ~/.alternatives-for-my-site/php-binfmt
Then create a file called .htaccess
in the directory containing
the site or part of the site that you want to run with a different
version of PHP. This should contain the following line:
SetEnv HTTP_ALTERNATIVES_DIR /home/username/.alternatives-for-my-site