Select Category
Sitemap Help Contact
print article

Change PHP Directives

For Linux Web Hosting packages, 1&1 Managed Servers, and Linux Root servers.

The following article describes how to change PHP directives by editing either the php.ini or .htaccess file.

A full list of PHP directives can be found at PHP: Description of core php.ini directives - Manual

In a PHP script

If you want to make a change in one file then you must use the ini_set function as displayed below. Be sure to add this code to the beginning of your script to implement the change properly.
ini_set("upload_max_filesize","10M");
ini_set("post_max_size","10M");
ini_set("mysql.default_socket","/kunden/tmp/mysql5.sock");
In the php.ini file

Every installation of PHP has a default or global php.ini file for the default PHP settings. Normally it is suggested to leave the default or global php.ini file unaltered and to simply create your own php.ini file wherever needed to override the default settings. You can create the php.ini file using a text editor and saving the file to the folder where the settings should apply.

Please note:
Using a php.ini file to override the default settings will only alter the PHP settings for all PHP files in the directory where it is saved.

This means that any PHP files in subfolders will not recognize the changes you've made in the php.ini file. You will have to copy the file to any subdirectories needed or created symbolic links in subfolders to the custom php.ini file.

Write each directive along with its value on separate lines. Lines starting with a hash symbol (#) are comment lines and have no effect on the settings within the file.

upload_max_filesize = 10M
post_max_size = 10M
mysql.default_socket = "/kunden/tmp/mysql5.sock"

For additional information, you may want to reference: