Welcome to Blazingfibre - web hosting, website development, custom software, network administration, technical support - London-based
+44-7944-731-092

How to use PHP and PERL with your webhosting service

  knowledgebase  :: network status

Both PHP and PERL are enabled by default; there's nothing to enable to start using them. There are, however a few crucial details, which we list below.

More information on troubleshooting scripts with the server can be found in the knowledgebase.

PHP notes

  • By default, the webserver only parses PHP code if the file's extension is .php (for example, info.php). To allow the webserver to parse PHP inside HTML files, create a text file called .htaccess and place it in the root of your webspace. This file must contain the following line:
    AddType application/x-httpd-php .php .php3 .phtml .html .htm
    
  • Many modules are installed, including GD and ImageMagick. Run an "info" script to see the complete PHP configuration, such as this:
    <?php phpinfo(); ?>
    
  • For security reasons, support for extra headers in PHP's mail() function, including BCC, have been disabled. To work around this, use one of the following methods:

    • send the mail twice, once to the intended recipient, then again, to the BCC recipient (using the To: field, not BCC)
    • add the address to the To: field instead of the BCC field
    • use a third-party email library such as PHPMailer

  • By default, PHP 5.6 will process PHP files, however alternative versions are available:

    PHP version.htaccessCLI
    5.2AddType application/x-httpd-php52 .php/usr/local/php52/bin/php
    5.3AddType application/x-httpd-php53 .php/usr/local/php53/bin/php
    5.4AddType application/x-httpd-php54 .php/usr/local/php54/bin/php
    5.5AddType application/x-httpd-php55 .php/usr/local/php55/bin/php
    7.0AddType application/x-httpd-php70 .php/usr/local/php70/bin/php
    7.1AddType application/x-httpd-php71 .php/usr/local/php71/bin/php
    7.2AddType application/x-httpd-php72 .php/usr/local/php72/bin/php

    To use a version of PHP other than the default, place the above .htaccess code into into your .htaccess file. To use a different version of PHP on the commandline, call the binary listed in the CLI column above.

PERL notes

  • The path to the PERL interpreter is /usr/bin/perl
  • Your PERL scripts must be uploaded to the /cgi-bin directory.
  • When you upload PERL scripts, ensure to use ASCII or text tranfer mode. Exercise caution with "automatic" transfer modes, as these are not always able to detect the filetype correctly. If you're using a Windows system and you upload a file in ASCII mode, the uploaded file may get slightly smaller in size - this is normal (it's because your linebreaks are having their CR removed).
  • Once you have uploaded a PERL script, you must also set permissions on it to 755. You'll need an FTP client which lets you set permissions, we recommend Total Commander. Here are permissions 755 in English:
    owner:	[X] read
    	[X] write
    	[X] execute
    group:	[X] read
    	[ ] write
    	[X] execute
    world:	[X] read
    	[ ] write
    	[X] execute
    
  • If you see '500 Internal Server Error' when you try to access your script, check that you've uploaded the script in ASCII mode, and changed the permissions on it to 755; also check that the permissions of your cgi-bin directory are set to 755.
  • If you see '500 Internal Server Error' onscreen, and in the Apache errorlog, the messages 'failed to open log file' and 'fopen: Permission denied' are listed, check that the first line of your script is pointing at the correct PERL interpreter. The first line should say:
    #!/usr/bin/perl