translated by Google

Machine-translated page for increased accessibility for English questioners.

How to use PHP on FI

Switching to the new PHP version. If you're creating a new project, use it straight away /packages/run/php/bin/php-next , see section PHP Upgrades .

First, go to our directory /home/xlogin/public_html create a file .htaccess (must have "r" access enabled for others). Let's say that files with the .php extension are scripts and that they should be run as scripts:

DirectoryIndex index.php
AddHandler cgi-script .php
AddType application/x-httpd-php .php

In order to run the PHP script, it must have "x" access for the owner (PHP scripts run under your identity).

If you have the right to manage a site on Aise, which is located elsewhere /home/xlogin/public_html/ , it is necessary for these PHP scripts to allow "x" access for users apachefi , otherwise they will not work. To add this right, use the command

setfacl -m u:apachefi:x soubor.php

Furthermore, its very first line must be a string #!/packages/run/php/bin/php . It is not necessary to insert this string into files that do not run directly, but for example they are just inserted with include .

An example of a PHP script

  echo strftime("%H:%M:%S\n");


If you want to use FastCGI, edit in .htaccess Directive AddHandler :

DirectoryIndex index.php
AddHandler fastcgi-script .php
AddType application/x-httpd-php .php

FastCGI scripts are not newly launched at every request, but serve more. This can cause the application to respond more quickly, but on the other hand, not all applications are ready for this kind of use.

PHP Upgrades

PHP language is constantly evolving and old versions are no longer supported, so once in a while we have to upgrade to a newer version, usually backwards incompatible. To make it easier for you to upgrade, the new version of PHP is available under the name /packages/run/php/bin/php-next .

To test the new version, change the first line of your scripts to:


Implicit /packages/run/php/bin/php then switch to the new version so you can change it php-next back to php .

Do not use a specific version of PHP (e.g. /packages/run.64/php-7.3.2/bin/php-cgi ) may be canceled at any time without notice.

It is currently php-next version 7.3 , while default php is version 5.6 .


The default encoding is set to UTF-8 that applications should use for both program code and eventual HTML files.

In special cases, you can set encoding in PHP (for example, to ISO8829-2 ) by adding this command to the beginning of the program:

<?php ini_set('default_charset', 'ISO8859-2'); >

HTML files can be encoded in a file .htaccess :

AddDefaultCharset ISO-8829-2

For more information see Encoding Czech in Documents .

What to do in case of problems

Apache logs are a useful source of more detailed information about errors. They can be found on the Aisa server located in /var/log/httpd/ , specifically error.log , optionally suexec.apachefi.log .

It is also preferable to use CGI instead of FastCGI when debugging errors. The error logs are then clearer and running the script over the web is more responsive.

The PHP script should also be directly executable on the command line. Example of correct output:

aisa:/home/xlogin/public_html>$ ./index.php
X-Powered-By: PHP/5.6.38
Content-type: text/html; charset=UTF-8


Examples of possible errors in case of unsuccessful execution index.php :

  • -bash: ./index.php: Permission denied
    The PHP script does not seem to have "x" access for the owner.

  • -bash: ./index.php: /packages/run/php/bin/php^M: bad interpreter: No such file or directory
    PHP script has DOS line termination. It can be converted by a utility to Unix line termination dos2unix .

  • Premature end of script headers (in error_log file)
    Check the header Content-type you are typing correctly and followed by a blank line.

Error log security

Error logs they are read-only accessible to the user xlogin under which the script runs.

In addition, you can consider logging errors to your own file. This can be done by creating your own PHP configuration file .user.ini that you place in the directory public_html . This file should have at least the "r" access right for the owner and should contain a line

error_log = /home/xlogin/php.log

Subsequently, error messages should be recorded in the specified file. Of course, it is advisable to protect this file from other users. Therefore, we recommend that you create this file manually with the appropriate privileges, otherwise it will create read-only permissions for everyone when you write the first error. At least the right is necessary w for the owner and file path should be accessible to you - logging again under your identity. Alternatively, if the directory in which you want to save this file is only accessible to you (right x owner only), let the file be created automatically.