Admin php mod user

Содержание
  1. # PHP Options
  2. # mod_php
  3. # php-fpm
  4. # fastcgi
  5. # suphp
  6. # Where is my php.ini?
  7. # How to increase the max upload filesize
  8. # Fatal error: Allowed memory size exhausted
  9. # How to use per-domain or per-path settings for php
  10. # 1. Per-domain settings
  11. # 2. Per-path settings
  12. # How to allow If you have scripts with the php tags: but php isn’t parsing the code between those tags, php may be set to require: You can force php to allow the short tags by setting the following in your php.ini: # How to disable magic-quotes If you need to disable magic quotes, the easiest way is to edit your php.ini and set: Another way is to edit your php configure file and remove the line: # Testing which uid php is running as to debug read/write issues Often times, a php script needs write access to disk. Most new installs will use mod_ruid2+cli, suPHp, fastcgi or php-fpm, which should all run php as the given User, rather than as «apache». To determine what uid a php process is running as, you can use this script to get a definitive answer: Save this to an info.php file in a path you’re trying to debug, then view it through Apache. Note that this requires that both «system» and «phpinfo» not be set in your disable_functions list in your php.ini. Источник Admin php mod user When using PHP as an Apache module, you can also change the configuration settings using directives in Apache configuration files (e.g. httpd.conf ) and .htaccess files. You will need «AllowOverride Options» or «AllowOverride All» privileges to do so. There are several Apache directives that allow you to change the PHP configuration from within the Apache configuration files. For a listing of which directives are PHP_INI_ALL , PHP_INI_PERDIR , or PHP_INI_SYSTEM , have a look at the List of php.ini directives appendix. Sets the value of the specified directive. Can be used only with PHP_INI_ALL and PHP_INI_PERDIR type directives. To clear a previously set value use none as the value. Note: Don’t use php_value to set boolean values. php_flag (see below) should be used instead. Used to set a boolean configuration directive. Can be used only with PHP_INI_ALL and PHP_INI_PERDIR type directives. php_admin_value name value Sets the value of the specified directive. This can not be used in .htaccess files. Any directive type set with php_admin_value can not be overridden by .htaccess or ini_set() . To clear a previously set value use none as the value. php_admin_flag name on|off Used to set a boolean configuration directive. This can not be used in .htaccess files. Any directive type set with php_admin_flag can not be overridden by .htaccess or ini_set() . Example #1 Apache configuration example php_value include_path ".:/usr/local/lib/php" php_admin_flag engine on php_value include_path ".:/usr/local/lib/php" php_admin_flag engine on PHP constants do not exist outside of PHP. For example, in httpd.conf you can not use PHP constants such as E_ALL or E_NOTICE to set the error_reporting directive as they will have no meaning and will evaluate to 0. Use the associated bitmask values instead. These constants can be used in php.ini Changing PHP configuration via the Windows registry When running PHP on Windows, the configuration values can be modified on a per-directory basis using the Windows registry. The configuration values are stored in the registry key HKLM\SOFTWARE\PHP\Per Directory Values , in the sub-keys corresponding to the path names. For example, configuration values for the directory c:\inetpub\wwwroot would be stored in the key HKLM\SOFTWARE\PHP\Per Directory Values\c\inetpub\wwwroot . The settings for the directory would be active for any script running from this directory or any subdirectory of it. The values under the key should have the name of the PHP configuration directive and the string value. PHP constants in the values are not parsed. However, only configuration values changeable in PHP_INI_USER can be set this way, PHP_INI_PERDIR values can not, because these configuration values are re-read for each request. Other interfaces to PHP Regardless of how you run PHP, you can change certain values at runtime of your scripts through ini_set() . See the documentation on the ini_set() page for more information. If you are interested in a complete list of configuration settings on your system with their current values, you can execute the phpinfo() function, and review the resulting page. You can also access the values of individual configuration directives at runtime using ini_get() or get_cfg_var() . Источник
  13. # How to disable magic-quotes
  14. # Testing which uid php is running as to debug read/write issues
  15. Admin php mod user
  16. Changing PHP configuration via the Windows registry
  17. Other interfaces to PHP
Читайте также:  Html сделать отступы по краям

# PHP Options

With the many different types of php modes, this means the method of adding custom per-domain changes can vary greatly. Check your custombuild options.conf to determine which php1_mode you’re using, and find the related guide below.

# mod_php

mod_php is the default and the most commonly used. You can use 3 different methods to change php settings:

  1. .htaccess in the public_html to add php_admin_flag / php_admin_value
  2. Admin Level -> Custom Httpd Config, to add php_admin_flag / php_admin_value
  3. php [PATH] or [HOST] sections

# php-fpm

php-fpm is handy for multiple instances of php, allowing the User to change php version from within their User Level area. php-fpm does not support .htaccess changes as php-fpm is it’s own stand-alone php server, but you can use

# fastcgi

The fastcgi mode is effective, but some find it somewhat rigid in it’s flexibility (blend of suphp and php-fpm). To edit per-domain settings, you have 2 options:

  1. Manually create the .ini file at /usr/local/directadmin/data/users/username/php/domain.com.ini and the call to fastcgi will read that in if it exists.

Note that it’s a full replacement and not an ‘addon’ ini, so ensure you have all settings you need in that file, as the default php.ini isn’t used here. Take a look inside the User’s httpd.conf to see which .sh script is called, and the variables passed. Then check inside that .sh script for more info on how it works.

# suphp

suhp is older, end-of-life, but some still use it. Your options are:

  1. per-User suphp setting, although you could just the «SetEnv» to the |CUSTOM| token on a per-domain basis at the Custom Httpd Config. Example:
SetEnv PHP_INI_SCAN_DIR /usr/local/directadmin/data/users/|USER|/php/ 

Note that some settings like disable_functions can only be set once in the main php.ini file, and cannot be overridden by other areas, but this varies per php-mode. php-modes like php-fpm/fastcgi are much more stand-alone php instances, so you can get away with these types of overrides, away from the main php.ini .

# Where is my php.ini?

Depending of a setup the location of php.ini may vary. The easiest trick to find your php.ini would be to ask php itself what it’s using, eg:

/usr/local/bin/php --ini | grep 'Loaded Configuration File' 

which does assume that the php output will be in English.

Usually your php.ini will be located at (XX — PHP version, for example 73):

CustomBuild 2.0 installs will also uses the php.conf.d directory to load miscellaneous .ini files into php. The files that CustomBuild will create are:

You can add your own files there if you need to add settings or load modules into php, for example /usr/local/php74/lib/php.conf.d/11-custom.ini and place custom options inside.

The ever best option is to place phpinfo() page inside a domain DocumentRoot directory, create the file phpmyinfo.php with content:

Next open it in browser: http://example.com/phpmyinfo.php and watch for ‘Loaded Configuration File’ and ‘Scan this dir for additional .ini files’ .

Читайте также:  Hello World program in PHP

# How to increase the max upload filesize

; Maximum allowed size for uploaded files. upload_max_filesize = 2M 

Change the 2M to whatever new value you want, then restart apache.

Note, this setting may also be related:

; Maximum size of POST data that PHP will accept. post_max_size = 8M 

Note, some RoundCube versions have limits set in the file /var/www/html/roundcube/.htaccess so be sure to increase them there as well, if they are set.

# Fatal error: Allowed memory size exhausted

If you see the error like:

Fatal error: Allowed memory size of 123456 bytes exhausted (tried to allocate 234567 bytes) in /path/file.php 

Php is setup is to limit memory usage per process. If you require more, this limit can be increased.

Find where is your php.ini then edit it, search for

to a higher value, like 128M. Save, exit, then restart apache.

# How to use per-domain or per-path settings for php

As suPhp is getting old, and doesn’t have the performance of newer php types, many Admin’s would want to combine the faster methods, while still keeping the ability to have per-item settings to allow custom changes where needed.

If you’re using mod_php (cli), the bulk of the php settings can be set in the Custom Httpd Config with the standard php_admin_flag/php_admin_value settings right in the VirtualHost.

However, you might want even more control, say with a variable that isn’t supported in that way, or with a path, rather than a host.

For this case, CustomBuild 2.0 uses a folder for additional php.ini files, loaded if they exist in the folder. The install path can vary depending on the php mode; in this example, we’ll use /usr/local/lib/php.conf.d but for other php modes, if the php version is 5.6, the path might be:

You can determine where you php.ini and php.conf.d folder is by using the where is my php.ini guide.

Once you know the path, let’s use in our example, you can then create your custom ini file. The load of the ini files is done alphabetically, so we number the files to control in which order they’re loaded in. Usually the order doesn’t matter too much, unless you’re altering settings for a module that should be loaded first.

# 1. Per-domain settings

If you would like to create per-domain settings for , you could create:

[HOST=example.com] session.save_path=/home/fred/tmp upload_tmp_dir=/home/fred/tmp 

# 2. Per-path settings

Similarly, you can alter settings on a per-path basis, say for User which is handy if you want the settings to apply to a domains under that given path (usually, on a per-User basis), edit the file:

[PATH=/home/fred] session.save_path=/home/fred/tmp upload_tmp_dir=/home/fred/tmp 

In the above examples, it is implying the use of one file for each item you want to separate. This is not required. You can use one additional file to make load times faster, but also to hide the list of domains from the phpinfo() output, as all «additional» loaded php.ini files are displayed, so if you were to use:

you could add many [HOST=xx] entries into the same file, one after the other.

Based on: http://php.net/manual/en/ini.sections.php

# How to allow

If you have scripts with the php tags:

but php isn’t parsing the code between those tags, php may be set to require:

You can force php to allow the short tags by setting the following in your php.ini:

# How to disable magic-quotes

If you need to disable magic quotes, the easiest way is to edit your php.ini and set:

Another way is to edit your php configure file and remove the line:

# Testing which uid php is running as to debug read/write issues

Often times, a php script needs write access to disk. Most new installs will use mod_ruid2+cli, suPHp, fastcgi or php-fpm, which should all run php as the given User, rather than as «apache».

To determine what uid a php process is running as, you can use this script to get a definitive answer:

Save this to an info.php file in a path you’re trying to debug, then view it through Apache.

Note that this requires that both «system» and «phpinfo» not be set in your disable_functions list in your php.ini.

Источник

Admin php mod user

When using PHP as an Apache module, you can also change the configuration settings using directives in Apache configuration files (e.g. httpd.conf ) and .htaccess files. You will need «AllowOverride Options» or «AllowOverride All» privileges to do so.

There are several Apache directives that allow you to change the PHP configuration from within the Apache configuration files. For a listing of which directives are PHP_INI_ALL , PHP_INI_PERDIR , or PHP_INI_SYSTEM , have a look at the List of php.ini directives appendix.

Sets the value of the specified directive. Can be used only with PHP_INI_ALL and PHP_INI_PERDIR type directives. To clear a previously set value use none as the value.

Note: Don’t use php_value to set boolean values. php_flag (see below) should be used instead.

Used to set a boolean configuration directive. Can be used only with PHP_INI_ALL and PHP_INI_PERDIR type directives.

php_admin_value name value

Sets the value of the specified directive. This can not be used in .htaccess files. Any directive type set with php_admin_value can not be overridden by .htaccess or ini_set() . To clear a previously set value use none as the value.

php_admin_flag name on|off

Used to set a boolean configuration directive. This can not be used in .htaccess files. Any directive type set with php_admin_flag can not be overridden by .htaccess or ini_set() .

Example #1 Apache configuration example

 php_value include_path ".:/usr/local/lib/php" php_admin_flag engine on php_value include_path ".:/usr/local/lib/php" php_admin_flag engine on 

PHP constants do not exist outside of PHP. For example, in httpd.conf you can not use PHP constants such as E_ALL or E_NOTICE to set the error_reporting directive as they will have no meaning and will evaluate to 0. Use the associated bitmask values instead. These constants can be used in php.ini

Changing PHP configuration via the Windows registry

When running PHP on Windows, the configuration values can be modified on a per-directory basis using the Windows registry. The configuration values are stored in the registry key HKLM\SOFTWARE\PHP\Per Directory Values , in the sub-keys corresponding to the path names. For example, configuration values for the directory c:\inetpub\wwwroot would be stored in the key HKLM\SOFTWARE\PHP\Per Directory Values\c\inetpub\wwwroot . The settings for the directory would be active for any script running from this directory or any subdirectory of it. The values under the key should have the name of the PHP configuration directive and the string value. PHP constants in the values are not parsed. However, only configuration values changeable in PHP_INI_USER can be set this way, PHP_INI_PERDIR values can not, because these configuration values are re-read for each request.

Other interfaces to PHP

Regardless of how you run PHP, you can change certain values at runtime of your scripts through ini_set() . See the documentation on the ini_set() page for more information.

If you are interested in a complete list of configuration settings on your system with their current values, you can execute the phpinfo() function, and review the resulting page. You can also access the values of individual configuration directives at runtime using ini_get() or get_cfg_var() .

Источник

Оцените статью