Knowledge base
1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Editing the server configuration of a site (.user.ini ; .htaccess)
This guide explains how to change the server configuration of a site with a Web hosting and a managed Cloud Server.
The difference between the .user.ini and .htaccess files
- Apache is the HTTP server. It is configured with a .htaccess file placed in the root of the website.
- PHP is a programming language used to create dynamic web pages via an HTTP server. It is possible to customise the PHP commands using a .user.inifile, these changes will be effective in the folder and sub-folders where the .user.ini file is located
- modification of the .user.ini file requires several minutes to be effective
- the PHP commands must imperatively be placed in the .user.ini file to be taken into account
We will now illustrate 3 ways to modify the server configuration of a site.
1. Changing the PHP configuration via Manager
Certain settings (e.g. allow_url_fopen or memory_limit) can be configured via Manager
- open Manager (manager.infomaniak.com)
- go to Hosting
- click on the hosting/domain name concerned
- under Sites below click on the domain name of the site concerned
- click on Advanced parameters
- under the PHP and Apache tabs, adjust the configuration of the site as needed
- save
2. Changing the PHP configuration via the .user.ini file
To customise the PHP commands using a Web browser, you must define the values desired in the .user.ini file
The following example illustrates changing the max_input_vars variable
max_input_vars=3000
3. Changing the PHP configuration in CLI
To customise the PHP commands using command line interface (CLI) or in CRON tasks, you must define the desired values in a .user.ini file and than call the PHP executable with the -c .user.inioption
The following example illustrates changing the memory available for PHP:
~/web$ echo -e '<?php echo "memory_limit: " . ini_get("memory_limit") . "n"; ?>' >memory-limit.php
~/web$ php memory-limit.php
memory_limit: 512M
~/web$ echo 'memory_limit = 1024M' >.user.ini
~/web$ php -c .user.ini memory-limit.php
memory_limit: 1024M
~/web$
The following example activates allow_url_fopen for the WP CLI tool (specifically allows recovering extensions):
php -d allow_url_fopen=On ~/bin/wp package install trepmal/wp-revisions-cli
Useful resources
- How to create a .htaccess or .user.ini file
- Changing the PHP version of an Internet site
- Activate Gzip compression
- Activate Google's PageSpeed Tools
- Support 301 type redirections
- Increasing the memory and runtime of scripts