Apache, PHP, Programming

Set PHP configuration options in Apache using directives

Apache directives to change the PHP configuration:
php_value name value

Sets the value of the specified directive.

php_flag name on|off

Sets a boolean configuration directive.

php_admin_value name value

Sets the value of the specified directive. This can not be used in .htaccess files.

php_admin_flag name on|off

Used to set a boolean configuration directive. This can not be used in .htaccess files.

Let’s see some examples:

<IfModule mod_php5.c>
  php_value include_path ".:/usr/local/lib/php"
  php_admin_flag engine on
</IfModule>
<Directory /var/www/vhosts/mydomain.com/httpdocs>
php_admin_value open_basedir "/var/www/vhosts/mydomain.com/httpdocs:/var/www/vhosts/mydomain.com/files"
</Directory>
<Directory /var/www/vhosts/mydomain.com/httpdocs>
php_value  include_path         ".:/usr/local/lib/php" 
php_flag   display_errors       Off
php_value  upload_max_filesize  2M
</Directory>