How to modify PHP settings without using php.ini files

When PHP is running as a CGI module,  PHP settings cannot be modified through an .htaccess file.

If you would like to modify a PHP setting, you would have to use php.ini files. Unfortunately, php.ini files work only on a per-folder basis.

In other words, if you would like to apply custom PHP settings to two different folders, you would have to place separate php.ini files in each folder.

And when you need to apply custom PHP settings to many folders, placing a php.ini file in each folder can be bothersome.

Fortunately, there is a workaround which should apply to most applications. Instead of copying php.ini files recursively, you can specify the needed value only once.

Imagine you have a Joomla installation which spreads on many directories. You would like to allow remote file inclusion with the PHP setting allow_url_include. One way is to specify it in many php.ini files across all directories. The other way is to specify it in the main configuration.php file with PHP's function ini_set. The configuration.php file is included in all Joomla scripts and that's why your configuration change will take effect for all Joomla directories.

Thus all you have to do is add a line in the configuration.php file which says:

ini_set('allow_url_include','on');

Now this PHP directive will be valid for all Joomla subdirectories. Similarly, you can do so for almost any other application. Just make sure that you include the PHP directive in the main configuration file.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Does Hostlantern support PHP HTTP Authorization?

Hostlantern supports the PHP HTTP Authorization and in order to enable it you need to add the...

Is PHP Safe Mode turned Off on Hostlantern’s servers

PHP Safe Mode is by default turned off for all PHP versions available on Hostlantern servers....

How to enable zlib compression manually for PHP scripts

PHP Zlib module allows you to transparently read and write gzip compressed files. Thus it is used...

What is SourceGuardian and how to use it?

SourceGuardian is commercial software which allows you to securely encode, compile and encrypt...

How to install Smarty Template Engine

Follow the steps below to install Smarty Template Engine on your hosting account: Download the...