Skip to content

How to Make php.ini file recursive in cPanel shared hosting

We can certainly make the php.ini file recursive in our cPanel settings. Let's check this with our detailed explanation.

PHP is a widely-used open-source scripting language that is especially suited for web development and it can be embedded into HTML. PHP is highly customizable and can be easily modified by the users themselves.

The PHP settings defined in the php.ini file are not recursive, which means the settings in any subdirectories of the current directory cannot be modified.

Table of Contents

Recursive php.ini detail explanation

By default, the php.ini file is not recursive, but if you make a php.ini file recursive, the changes made to the file not only change the folder in which it is but also the changes are made inside the child folders as well. This can be done in very simple steps. But before, let’s understand the whole situation with a simple example:

Let’s suppose, we have a subfolder name Team inside the public_html folder. If we make changes to the php.ini file in the public_html, those changes will only affect scripts in the public_html folder.  Any scripts in our “Team” subfolder will not be affected by the php.ini file in the public_html folder, it would be only affected by the php.ini file located in its own folder, public_html/Team

Well, this can be helpful if you want to have different PHP configurations for various folders, if you want the same settings for all folders in your account, it could become quite slow and tiresome to copy the php.ini file into all those subfolders. In that case, you can upgrade your .htaccess file to tell the server that the public_html/php.ini file should be implemented not only to public_html but to any folders within that directory (such as public_html/Team or public_html/about-us)

How to make php.ini file recursive?

We can certainly make the php.ini file recursive in our cPanel settings. By adding the following code to our .htaccess file, we can make the php.ini file in our public_html folder recursive so the changes will take effect in all the child folders as well:


FYI:  Make sure you replace “Username” with your actual cPanel Username. 

If you do not have a .htaccess file in your public_html you can simply create it by using your cPanel file manager and add the code.

The changes you have made are immediate and should be updated right away.  You can check the changes by placing a php.ini file in your subfolder to verify the PHP configuration setting in that subfolder.

Picture of netspace


Leave a Comment

Subscribe: Trusted By 1M+ Readers

Get the weekly Tech Update straight to your inbox.

Our customer sales team is here to answer your questions. Ask us anything!
👋 Hi, how can I help?