Copy php.iniThere are many situations when you may want to copy your hosts main php.ini file to your account or directory. This is especially true if your host has their servers configured in CGI or FastCGI mode.

If php.ini overriding isn’t disabled, then you can copy it to your account so you can change the way PHP functions and performs to suit your needs.

For instance maybe you want to increase the default memory limit. Some shared hosts have the memory limit set so pathetically low that your site may run out of memory. If your host has a 32MB to 64MB or less memory limitation, then you may need to bump it up, or find a new host. You obviously don’t want to use too much or they may end up suspending your account for excessive memory use. I personally don’t think a setting of 128MB to 256MB is too much to ask for these days. Even if you don’t use that much consistently, I think you should be allowed to use that much on an occasional basis at the very least.

That is just one example. There are many other settings that you could change by making changes to a php.ini file.

Some people will tell you to create your own php.ini file with the lines you want to change and upload it to your account, or create one with a file manager. This will generally work, but it’s much better to get a copy of the actual file your host is using and make changes to it so there are no conflicts.

How to copy the main/master php.ini to your home directory

The first thing you need to do is determine the actual location of the file on the server. To do this, you need to create a phpinfo.php file.

Option 1:
Open Windows Notepad and paste in the following line of code:
<? phpinfo(); ?>

Save it as:

Then, upload it to your website/space:

Option 2:
Use your hosts file manager to create a file called phpinfo.php in your account.
For cPanel users that location would be:

Edit the newly created file and add this line of code to it:
<? phpinfo(); ?>

Be sure to save the changes after doing so.

Once you have completed either option 1 or 2, then simply visit the link or location you uploaded it to in your web browser. In this case:

If you created/uploaded the file correctly you should see a purple’ish looking page with your PHP Version at the top.

Look for the line that says:
Loaded Configuration File

php.ini Location

This is the location of the servers main/master php.ini file. In the screen shot above it would be:

Keep this window/tab open because we will need to copy this location later.

In order to copy the file we also need to know the path (location) of our home directory for our account. If your host is using cPanel you can usually find this on the left-hand column towards the top when you first login to cPanel.

It looks like this:

cPanel Main

In the screen shot above our home directory would be:

To recap, what we know at this point is:

The path to php.ini is:

And, our home directory is:

Now we need to create another php file that will do the actual copying to our account. You can create this file with either Windows Notepad and upload it to your account just like the phpinfo file, or you can use your hosts file manager.

Create a php file with the following line of code:


You can call/name it anything you want. Just make sure it is named something unique, and not the same name as a file that already exists in your account. I will call it copy.php for this example.

Once I have created/uploaded my copy.php file with the line of code above to my account I just need to visit the link/page in my web browser one time. So in my web browser I would enter:

If you see a blank white page don’t worry that’s normal.

Now the main/master php.ini file should have been copied to your home directory.

To verify FTP into your account or use your hosts file manager and goto:

You should now find php.ini there.

File Manager

Now you can use the file manager to edit the file and make changes to it.

Remove the files you created in your account:
At this point you can remove/delete the phpinfo.php and copy.php file you created earlier as they are no longer needed.

For suPHP (CGI) configured servers:
If your host has a suPHP configured server (many shared hosts do), then you are supposed to copy the php.ini file to each and every folder/directory in your account.

To overcome this and use just one php.ini file for all your folders/directories you need to add a couple of lines of code to your main .htaccess file.

With cPanel hosting the main .htaccess file would be located:

Open/edit the .htaccess file with the file manager and add the following lines of code near the top:
<IfModule mod_suphp.c>
suPHP_ConfigPath /home/yoursite

Be sure to save the changes, and be careful editing .htaccess files they are very particular.

If you don’t see a .htaccess file make sure that you select “Show Hidden Files (dotfiles)” when the cPanel file manager prompts you to make a selection.

Show Hidden Files

If you still don’t see a .htaccess file you can manually create one with the cPanel File Manager and add the code above to it.

With this particular setup the php.ini file is located in the folder/directory /home/yoursite. Since that is above the public_html directory it will not be accessible in a web browser, and there is no need to prevent/deny access to it because it’s not publicly viewable at this location.

For other CGI configured servers (FastCGI):
Generally you only need to place one php.ini file in the public_html folder/directory. You can ask your host if you are not certain.

You would simply copy the php.ini file from:


If you want to prevent it from being viewed in a web browser then you can edit:

And add the following lines of code:
<Files php.ini>
deny from all

<Files php.ini>
order allow,deny
deny from all

The use of “youraccount” in this tutorial was obviously used for instructional purposes. You need to find and use the name of your real account in its place instead. The same with path to php /usr/local/lib/php.ini. You need to find and use the real path displayed in the “Loaded Configuration File” line.

If you have a decent host that allows you to make changes to a php.ini file you can usually ask them to copy it to your account for you.

I find that it is faster to do it myself in most situations rather than waiting for them to do so. Sometimes they don’t understand what you are asking for, and you end up contacting them 2 or 3 times before they get it right.

About: Jeremy LeSarge - AKA: Ray (233 Posts)

I am the site owner and administrator of I provide help and tips for Boonex Dolphin on the main part of this website where you will also find an assortment of other resources. Here, on the blog I write about a variety of topics surrounding WordPress, technology, social media/networking, SEO, and webmaster resources.