For all of our web hosting you can change all settings when it comes to the global php.ini file on the server. We recommend php.ini settings are done via cPanel under "PHP selector" as shown in the guide on step 4.
Apache / LiteSpeed
There is a difference when it comes to settings on these servers and therefore the options within php.ini is different to a certain degree. Check your client portal to see on which type of server your hosting is located.
The php.ini-file is stored in the root folder on your account. The file must be placed in the folder /home/username/ where username is your cPanel username. The file will apply to all domains and subfolders on the web hosting account. If you have subdomains or addondomains you can insert seperate php.ini files into the root folder of the domains which will overide the php.ini file in the root folder if it is also located there.
The php.ini file must be created and placed in the root folder of your account. The file must be placed in the folder /home/username/ where username is your cPanel username. The file will apply to all domains and subfolders on the web hosting account.
Content of the php.ini file
When it comes to the content of the php.ini file, you need to be aware of the following:
- Being able to change the php.ini file also makes it possible to abuse the servers resources. If you have made changes in php.ini which later causes massive usage of resources, your account will immediately be suspended. The account will not be opened until we are sure you have taken the necessary precautions in order to prevent this from occuring again.
- The configuration lines you do not include in your php.ini file will have PHPs standard value. The file only needs to contain the configurations you wish to change, but some of the not included values will be low or missing. If you need these, please contact support for a copy of the servers php.ini file.
- The changes you include in php.ini will normally apply immediately after the changes has been made. In some cases where the php process is already runningt this will need to finish first. It can take up to 0-2 minutes before the process is completed and the changes are made.
To see the existing configuration in PHP you can place the following code in a PHP-file (for example test.php) and access the file in your webbrowser:
The list of ini directives can be found here.
Classic examples of changing php.ini values
The examples below is classic examples of what our clients wants to change in php.ini. The examples contains only the change we want to make in the php.ini. All the other lines can also be included in the php.ini file. Error messages referred to under is found in the error_log file or on the site you are displaying if you have approved for error messages to appear.
- Changing upload_max_filesize (to 20Mb) is often necessary when uploading files. upload_max_filesize specifies the max file size available for upload.
upload_max_filesize = 50M;
- Changing post_max_size (to 20Mb) is often necessary when uploading files. post_max_size specifies the maximum file size available for upload by POST.
post_max_size = 50M;
- Changing max_file_uploads (to 30) is often necessary when uploading files. max_file_uploads specifies how many files maximum available for upload.
max_file_uploads = 50;
- Changing memory_limit (to 756Mb) is often necessary for PHP scripts with a larger requirement for memory than standard.
memory_limit = 756M;
You will typically see this error message if memory_limit is too low:
PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 8192 bytes) in /home/username/public_html/one_or_another_file.php on line 573
- Changing max_execution_time (to 90 seconds) is often necessary for PHP scripts that needs to run for a longer time to complete all code:
max_execution_time = 90;
You will typically see this error messsage if max_execution_time is too low:
PHP Fatal error: Maximum execution time of 60 seconds exceeded in /home/username/public_html/one_or_another_file.php on line 33
- Changing register_globals (to on) can be necessary for older scripts or scripts with special needs:
register_globals = On;
- Changing display_errors (to on) can be necessary for testing when programming in order for error messages to display on website:
display_errors = On;
- Changing session.save_path to store sessions somewhere else than /tmp which is standard:
session.save_path = /home/username/min_tmp;
- Changing magic_quotes_gpc to not make changes in GET/POST/Cookie data (is turned off for our newest servers - required by Joomla 3.0):
magic_quotes_gpc = Off;