Running PHP as a CGI
If you need to run an older version of PHP in order to maintain compatibility with your legacy software, you may run PHP as a CGI. See below for instructions that apply to your hosting account type. The instructions in this article are written assuming that the intended version of PHP is 8.0, but may work for other versions as well.
If you have a Shared hosting account created BEFORE June 1, 2011, a VPS Account, or a Dedicated server:
If you have a Shared hosting account, VPS account, or Dedicated servers with FastCGI:
With System CGI Enabled
Add the following lines to your web directory's .htaccess file:
AddType application/x-httpd-php8 .php
Action application/x-httpd-php8 /cgi-sys/php8.cgi
Any custom PHP settings that were previously set in .htaccess will need to be ported to a php.ini located in the same directory as the php8.cgi file. The syntax for setting custom PHP settings in the php.ini file requires that the string "php_value" or "php_flag" is removed. Instead, an equals sign is placed after the settings attribute and before the desired value The following chart illustrates some common custom PHP settings and the new syntax required:
.htaccess Syntax | php.ini Syntax |
---|---|
php_value memory_limit 64M | memory_limit = 64M |
php_flag allow_url_fopen on | allow_url_fopen = on |
php_value upload_max_filesize 64M | upload_max_filesize = 64M |
php_value post_max_size 64M | post_max_size = 64M |
php_flag register_globals off | register_globals = off |
php_flag magic_quotes_gpc 0 | magic_quotes_gpc = off |
Without System CGI
Place a copy of php8.cgi in your domain's cgi-bin directory:
- Connect to your account via SSH and copy the CGI version of PHP into your own cgi-bin directory with the following command:
cp /usr/www/cgi-bin/php8.cgi ~/public_html/cgi-bin/
(Note that this command may need to be changed if the domain name's cgi-bin has been mapped to a different directory via the ACC.)
- Create a .htaccess file in the directory where your PHP files reside, and add these lines:
AddType application/x-httpd-php8 .php Action application/x-httpd-php8 /cgi-bin/php8.cgi
Any custom PHP settings that were previously set in .htaccess will need to be ported to a php.ini located in the same directory as the php8.cgi file. The syntax for setting custom PHP settings in the php.ini file requires that the string "php_value" or "php_flag" is removed. Instead, an equals sign is placed after the settings attribute and before the desired value The following chart illustrates some common custom PHP settings and the new syntax required:
.htaccess Syntax | php.ini Syntax |
---|---|
php_value memory_limit 64M | memory_limit = 64M |
php_flag allow_url_fopen on | allow_url_fopen = on |
php_value upload_max_filesize 64M | upload_max_filesize = 64M |
php_value post_max_size 64M | post_max_size = 64M |
php_flag register_globals off | register_globals = off |
php_value magic_quotes_gpc 0 | magic_quotes_gpc = off |
Using PHP-CGIWrap
Place a copy of php8.cgi in your top-level cgi-bin directory:
- Connect to your account via SSH and copy the CGI version of PHP into your own cgi-bin directory with the following command:
cp /usr/www/cgi-bin/php8.cgi ~/public_html/cgi-bin/
- Create a .htaccess file in the directory where your PHP files reside, and add these lines:
AddType application/x-httpd-php8 .php Action application/x-httpd-php8 /cgi-sys/php-cgiwrap/USERNAME/php8.cgi
Replace USERNAME with your Pair Networks account username.
Using FastCGI
- Create a php8_wrapper.sh script in your top level fcgi-bin directory, with the following script contents:
#!/bin/sh exec /usr/www/cgi-bin/php8.cgi
- You'll need to make the script executable with the following command:
chmod 700 $HOME/public_html/fcgi-bin/php8_wrapper.sh
- Create a .htaccess file in the directory where your PHP files reside, and add these lines:
AddType application/x-httpd-php8 .php Action application/x-httpd-php8 /fcgi-bin/php8_wrapper.sh