Skip to content

PHP

PHP is an object-oriented programming language designed to generate web pages and build web applications in real time.

Initial domain configuration

To run a website written in PHP you must first ensure the correct configuration of the domain itself. Before proceeding to the next steps, make sure that:

  • The domain is correctly added and configured in our system DNS,
  • WWW page with indication of type PHP has been added.

PHP configuration

Configuration of the PHP interpreter is in the file /usr/home/LOGIN/.user.ini. You can set your own .user.ini file for each directory separately. You can define the configuration visible in phpinfo(), the one in the list of directives described as PHP_INI_PERDIR orPHP_INI_ALL and some additional module variables.

Examples

The following example will set the variable error_reporting for the domain DOMAIN. To do this, write the contents to the file /usr/home/LOGIN/domains/DOMAIN/.user.ini:
error_reporting = E_ALL | E_WARNING

Increasing the amount of memory for the PHP interpreter:
memory_limit = 768M

Increase max_execution_time:
max_execution_time = 360

Increase max_input_vars:
max_input_vars = 600

Saving error logs PHP to the file:

display_errors = off
log_errors = on
error_log = /usr/home/LOGIN/domains/DOMAIN/phperror.log

Change the default location of the temporary files directory (/tmp):
upload_tmp_dir = path/to/directory

Loading additional PHP modules

Loading additional PHP modules is possible through an entry in the .user.ini file: anp.extensions = "MODULENAME"

The module must be previously installed by the administration in the system. Currently available modules: amqp,sodium (PHP 7.1: libsodium, PHP 7.2 to PHP 8.2:sodium), phalcon,grpc, yaml.

To restrict PHP file operations to a specific directory tree, use open_basedir. To do this, write the contents to the file /usr/home/LOGIN/domains/DOMAIN/.user.ini (the path indicates the directory tree):
open_basedir = "path:/tmp"

It is recommended to use the open_basedir configuration available directly in the Details panel at the given PHP website.

Changing PHP settings for PHP CLI

In order to change options for PHP CLI, a configuration file .user.ini with its contents must be created in the home directory. After creating it, you should issue the command:

echo "export PHP_INI_SCAN_DIR=/usr/home/${USER}" >> $HOME/.bash_profile && source $HOME/.bash_profile

PHP version

The default PHP version is 8.1.

You can choose the PHP version for your website in the /usr/home/LOGIN/domains/DOMAIN/.htaccess file you created. You should then add one of the following lines to it:

AddType application/x-httpd-php56 .php
AddType application/x-httpd-php70 .php
AddType application/x-httpd-php71 .php
AddType application/x-httpd-php72 .php
AddType application/x-httpd-php73 .php
AddType application/x-httpd-php74 .php
AddType application/x-httpd-php80 .php
AddType application/x-httpd-php81 .php
AddType application/x-httpd-php82 .php
AddType application/x-httpd-php83 .php
AddType application/x-httpd-php84 .php

In addition, there are PHP CLI binaries available on the server under the following commands:

$ php
$ php56
$ php70
$ php71
$ php72
$ php73
$ php74
$ php80
$ php81
$ php82
$ php83
$ php84

To run a given version of PHP CLI without specifying its version in the binary name, the following commands should be issued (example for version 7.1):

mkdir -p ~/bin
ln -s /usr/local/bin/php71 ~/bin/php
echo 'export PATH=$HOME/bin:$PATH' >> $HOME/.bash_profile
source $HOME/.bash_profile

and CGI-FCGI:

$ php-cgi
$ php56-cgi
$ php70-cgi
$ php71-cgi
$ php72-cgi
$ php73-cgi
$ php74-cgi
$ php80-cgi
$ php81-cgi
$ php82-cgi
$ php83-cgi
$ php84-cgi

Unlimited PHP scripts

PHP scripts without time limits can be run after login via SSH. To run a script, use the PHP CLI, for example: php ~/domains/shop.example.com/public_html/product_import.php

The second way is to run the embedded web server in PHP. To do this:

  1. Reserve TCP port.
  2. Log in to SSH.
  3. Go to the directory with PHP scripts (for example public_html of the selected domain) cd /usr/home/LOGIN/domains/DOMAIN/public_html
  4. Start the server on the reserved port using command: php73 -S 0.0.0.0:RESERVED_PORT
  5. You can also select a different PHP version in this step, for example php72.
  6. For the server to work after logging out, start it on the screen: screen -dm sh -c "php73 -S 0.0.0.0:RESERVED_PORT"
  7. Optional: add WWW page of PROXY type to the reserved port.

Access to the scripts is possible via the address http://sX.serv00.com:RESERVED_PORT. For example, on the server s4.serv00.com, the reserved port 12345, the access to the previously mentioned script is http://s4.serv00.com:12345/product_import.php.

Using the mail() function

Before using the mail() function, please read the rules that apply to it.