Setting PHP parameters

On a VPS server, PHP runs in mod_php mode by default. You can also enable mod_cgi mode following this instruction.

In mod_php mode, PHP runs as an Apache module. To configure PHP, changes are made to the .htaccess file.

In mod_cgi mode, the php-cgi interpreter is launched. To configure PHP, changes are made to the .php.ini file in the site's cgi-bin directory.

Setting options in the .htaccess file

All directives must be added at the beginning or at the end of the file. Do not add directives between <IfModule> ... </IfModule> code blocks.

apc.cache_by_default

apc improves performance through caching. It is also sometimes necessary to disable the apc accelerator, for example, when the cache is full.

To enable the apc accelerator run the command:

php_flag apc.cache_by_default on

To disable apc run the command:

php_flag apc.cache_by_default off

default_charset

The default_charset directive sets the default charset for all rendered pages. For example utf-8, cp1251, koi8-r.

To add a directive, enter:

AddDefaultCharset koi8-r

php_value default_charset koi8-r

display_errors

The display_errors directive allows you to hide or display errors.

To enable error output, enter:

php_value display_errors 1

To disable error output, enter:

php_value display_errors 0

log_errors

The log_errors directive enables php errors loging and saving to a user-defined file.

To enable the directive, enter:

php_value log_errors on

php_value error_log /home/u/user/path-to-file/errors.log

Where user is the username and u is the first letter of the username.

magic_quotes_gpc

The magic_quotes_gpc option enables escaping PHP script data. The backslash (\), single quotes ('), and double quotes (") are automatically escaped.

To enable magic_quotes_gpc enter:

php_flag magic_quotes_gpc on

To disable magic_quotes_gpc enter:

 php_flag magic_quotes_gpc off

mail.add_x_header

The mail.add_x_header option enables logging of sending mail from site scripts. The logs contain the path to the script, recipient address and headers.

To enable mail.add_x_header enter:

php_value mail.add_x_header 1

php_value mail.log /home/u/user/public_html/mail.log

Where user is the username and u is the first letter of the username.

max_input_vars

The max_input_vars directive sets the maximum number of input variables that can be accepted in one request.

For example, if the maximum number of input variables is 9000, enter:

php_value max_input_vars 9000

mbstring.func_overload, mbstring.internal_encoding

Usually the directives mbstring.func_overload and mbstring.internal_encoding are used to optimize the work of sites on CMS Bitrix. For this CMS enter:

php_value mbstring.func_overload 2

php_value mbstring.internal_encoding UTF-8

For other CMS it is recommended to use the following values:

php_value mbstring.func_overload 0

php_value mbstring.internal_encoding UTF-8

opcache.revalidate_freq

The opcache.revalidate_freq setting is required for CMS Bitrix. To disable the option enter:

php_value opcache.revalidate_freq 0

pcre.recursion_limit

This directive allows you to set a limit on recursion.

php_value pcre.recursion_limit 12000

post_max_size

The post_max_size directive sets the maximum amount of data sent by the POST method:

php_value post_max_size 100M

To upload large files, post_max_size must be greater than upload_max_filesize.

register_globals

The register_globals directive is used to manage global variables.

To enable global variables, enter:

php_flag register_globals on

To disable global variables, enter:

 php_flag register_globals off

request_order

The request_order directive sets the order in which the Cookie, POST and GET variables are added to the _REQUEST array:

 php_value request_order CPG

upload_max_filesize

This directive allows you to set the maximum size of the uploaded file.

php_value upload_max_filesize 100M

Setting options in php.ini file

allow_url_fopen

The allow_url_fopen option enables URL wrappers (support for URL wrappers). This allows you to work with URL objects via ftp/http as with regular files.

To enable allow_url_fopen enter:

allow_url_fopen = 1

To disable allow_url_fopen enter:

 allow_url_fopen = 0

apc.cache_by_default

apc improves performance through caching. It is also sometimes necessary to disable the apc accelerator, for example, when the cache is full.

To enable the apc accelerator run the command:

apc.cache_by_default = 1

To disable apc run the command:

 apc.cache_by_default = 0

default_charset

The default_charset directive sets the default charset for all rendered pages. For example utf-8, cp1251, koi8-r.

To add a directive, enter:

default_charset = " koi8-r"

display_errors

The display_errors directive allows you to hide or display errors.

To enable error output, enter:

display_errors = on

To disable error output, enter:

 display_errors = off

magic_quotes_gpc

The magic_quotes_gpc option enables escaping PHP script data. The backslash (\), single quotes ('), and double quotes (") are automatically escaped.

To enable magic_quotes_gpc enter:

magic_quotes_gpc = 1

To disable magic_quotes_gpc enter:

magic_quotes_gpc = 0

mail.add_x_header

The mail.add_x_header option enables logging of sending mail from site scripts. The logs contain the path to the script, recipient address and headers.

To enable mail.add_x_header enter:

mail.add_x_header = on

mail.log = /home/u/user/public_html/mail.log

Where user is the username and u is the first letter of the username.

max_input_vars

The max_input_vars directive sets the maximum number of input variables that can be accepted in one request.

For example, if the maximum number of input variables is 9000, enter:

max_input_vars = 9000

mbstring.func_overload, mbstring.internal_encoding

Usually the directives mbstring.func_overload and mbstring.internal_encoding are used to optimize the work of sites on CMS Bitrix. For this CMS enter:

mbstring.internal_encoding = UTF-8

mbstring.func_overload = 2

For other CMS it is recommended to use the following values:

mbstring.internal_encoding = UTF-8

mbstring.func_overload = 0

opcache.revalidate_freq

The opcache.revalidate_freq setting is required for CMS Bitrix. To disable the option enter:

 opcache.revalidate_freq = 0

pcre.recursion_limit

This directive allows you to set a limit on recursion.

 pcre.recursion_limit = 12000

post_max_size

The post_max_size directive sets the maximum amount of data sent by the POST method:

post_max_size = 100M

To upload large files, post_max_size must be greater than upload_max_filesize.

register_globals

The register_globals directive is used to manage global variables.

To enable global variables, enter:

register_globals = 1

To disable global variables, enter:

 register_globals = 0

request_order

The request_order directive sets the order in which the Cookie, POST and GET variables are added to the _REQUEST array:

 request_order = CPG

upload_max_filesize

This directive allows you to set the maximum size of the uploaded file.

upload_max_filesize = 100M

Options that cannot be changed

When using a virtual server, the following php settings cannot be changed:

  • apc.ttl
  • apc.user_entries_hint
  • memory_limit
  • apc.shm_size
  • apc.num_files_hint

View php parameters

To find out php parameters for a site, create an info.php file in its directory and add to it:

<?php

phpinfo();

?>

Next, to view the details, follow the link http://your.website.name/info.php.

If you have any questions, please create a ticket to technical support.