设置PHP & MySQL参数

iTop需要对临时目录有写权限,该路径可以通过PHP功能 sys_get_temp_dir() 找到。检查权限,也就是检查 openbase_dir在PHP中的参数

当编辑存在很多关系对象时,iTOP创建一个大的框架来容纳所有的关系。因此,在一些情况下,传递到PHP服务器变量的数量可能超过1000。针对这种现象,一项配置用以保护PHP。对在php.ini文件中的参数 max_input_vars 的参数进行配置,该默认值为1000。

确保 max_input_vars (在 php.ini)参数被设置为足够大的值(例如 5000)

类似的做法是安装Suhosin的时候。参考 iTop and Suhosin 获取更多信息。

iTop能够作为各种对象(单据,配置项等)的附件上传和存储文档(例如 文件)。这些文档已二进制blob型存储在iTop数据库中。为了安全地上传和存储文档,一些配置在整个的PHP和MySQL中必须调整保持一致。

在PHP中,某些变量控制文件的上传:

file_uploads设置为 1 以允许文件上载,设置为 0 以防止所有文件上载。
upload_tmp_dir临时位置(在服务器上)将存储上传的文件。确保此参数指向运行 Web 服务器的进程(或在使用 Windows 内置身份验证的 IIS 中的最终用户)可访问(和可写)的位置,并且还剩下足够的空间。
upload_max_filesize上载文件允许的最大大小。该值以字节表示。您可以使用 K 表示千字节(±1024 字节)、M 表示兆字节和 G 表示千兆字节。示例:4M 代表 4 MB。
max_file_uploads可以在单个网页中同时上载的最大文件数。iTop 通常一次只上传一个文件。您可以安全地使用默认值,即 20。
post_max_size可以通过 POST 请求发送到服务器的最大数据量。此值必须大于 upload_max_filesize,因为同一请求将包含一些更多信息(文档的标题、操作代码...)。因此,最好在这里提出更大的价值。例如,如果upload_max_filesize为 4M,则将 5M 用于post_max_size。
memory_limit上载到服务器上后,文件将在内存中读取,然后再存储在数据库中。因此,请确保memory_limit(如果启用)远远大于upload_max_filesize。
max_input_time此值定义服务器读取其输入的最大时间。这包括上传文件所花费的时间。通过慢速连接上传大文件可能会超过 60 秒的默认值。

上传的文件被存储在MySQL数据库,每个文件在一个查询。然而,一个查询最大被容许的尺寸必须大于长传文件的最大尺寸。该参数通过在my.cnf配置文件(在MySQL服务器上)中变量max_allowed_packe进行配置。

好的经验是遵循下列各种配置之间的关系:

upload_max_filesize<post_max_size<max_allowed_packet<memory_limit
php.ini php.ini my.cnf php.ini

如果遇到mysqldump相关的问题,你可以调整另一个参数, max_allowed_packet,在my.cnf文件里的[mysqldump]部分。

自iTop2.5,字符集使用 utf8mb4_general_ci替代utf8mb4。允许iTop正确处理字符串,必须满足下列要求:

  • MySQL 版本 5.5.3 及以上

  • innodb_default_row_format 变量设置为 DYNAMIC (默认值) 或 COMPRESSED

  • innodb_large_prefix 设置为 true

MySQL 建议

my.cnf
  innodb_buffer_pool_size = 512M
  query_cache_size = 32M
  query_cache_limit = 1M

PHP 建议

php.ini
  memory_limit = 256M

原创链接:https://www.itophub.io/wiki/page?id=2_7_0%3Ainstall%3Aphp_and_mysql_configuration

PHP, MySQL / MariaDB settings

iTop needs write access to the temp dir (this path is retrieved using the PHP function sys_get_temp_dir()). Check rights and also the openbase_dir PHP parameter !

When editing objects with many relations, iTop creates one big form containing all the relations. Therefore in some cases the number of variables passed to the PHP server may exceed 1000. A configuration setting protects PHP against such a situation. This behavior is configurable using the parametermax_input_vars in php.ini, which default value is 1000.

Make sure that the parameter max_input_vars (in php.ini) is set to a large enough value (for example 5000)

This very same behavior may happen when Suhosin is installed. Refer to iTop and Suhosin for more information

iTop is capable of uploading and storing documents (i.e files) as attachments to various objects (Tickets, CIs…). These documents are stored as binary blobs in the iTop database. In order to to safely upload and store documents, several settings must be adjusted consistently across PHP and MySQL.

In PHP, several variables govern the upload of files:

file_uploadsSet to 1 to allow file upload, to zero to prevent all file uploads.
upload_tmp_dirThe temporary location (on the server) were the uploaded files will be stored. Make sure that this parameter points to a location that is accessible (and writable) by the process running the web server (or by the end users in case of IIS with the Windows built-in authentication) and that there is enough space left.
upload_max_filesizeThe maximum size allowed for an uploaded file. The value is expressed in bytes. You can use units like K for kilobytes (=1024 bytes), M for megabytes and G for gigabytes. Example: 4M stands for 4 megabytes.
max_file_uploadsThe maximum number of files that can be uploaded simultaneously in a single web page. iTop should normally upload only one file at a time. You can safely use the default value, which is 20.
post_max_sizeThe maximum amount of data that can be sent to the server via a POST request. This value MUST BE bigger than upload_max_filesize, since the same request will contain some more information (the title of the document, an operation code…). So it’s better to put a bigger value here. For example, if upload_max_filesize is 4M, then put 5M for post_max_size.
memory_limitAfter being uploaded on the server, the file will be read in memory before being stored in the database. Therefore make sure that memory_limit (if enabled) is far bigger than upload_max_filesize.
max_input_timeThis value defines the maximum time allowed for the server to read its input. This includes the time spent uploading the files. The default of 60 seconds may be exceeded for uploading big files over slow connections.

The uploaded files are stored into the MySQL database, each file in one query. Therefore the maximum size allowed for a query MUST BE BIGGER than the maximum size of the uploaded file. This is configured via the variable max_allowed_packet in the my.cnf configuration file (on the MySQL server).

It is good practice to have the following relation between the various settings:

upload_max_filesize<post_max_size<max_allowed_packet<memory_limit
php.ini php.ini my.cnf php.ini

If you ever have an issue linked with mysqldump, there is another parameter max_allowed_packet you can act on, in the same file my.cnf but under [mysqldump] section

As of iTop 2.5, the charset used is utf8mb4 with utf8mb4_general_ci collation. To allow iTop to correctly handle strings, the following requirements must be met :

  • MySQL version 5.5.3 or newer

  • innodb_default_row_format variable set to DYNAMIC (default value) or COMPRESSED

  • innodb_large_prefix set to true

MySQL / MariaDB recommandations

my.cnf
 
  innodb_buffer_pool_size = 512M
  query_cache_size = 32M
  query_cache_limit = 1M

PHP recommandations

php.ini
 
  memory_limit = 256M
标签:
由 superadmin 在 2020/08/27, 15:55 创建
    

需要帮助?

如果您需要有关XWiki的帮助,可以联系:

深圳市艾拓先锋企业管理咨询有限公司