How To Create a php.ini File with Complete Configurations

phpini file Let’s learn how to create a complete php.ini file with full configuration settings. When you want to run scripts which require certain Server Requirements like
increase or decrease
You can make changes using a custom php.ini file in the root.

When we upload a php.ini file with only few settings say for example; memory_limit = 128M,
Other settings custom settings may get change and your site may be broken.

How To Create a php.ini File ?

Step 1:

We should make a copy of our default php.ini file.

Create a php file naming it as myini.php using the snippet:

<?php system("cp /usr/local/lib/php.ini /home/username/php.ini"); ?>

For your convenience, Download myini.php here. Rightclick and save links as..

Change the ‘username’ to your controlpanel username.
Read Step1(b) for the second path in the above snippet.

Step 1(a):
If you are not sure how to create a php file,
Open notepad, paste the above snippet.
Go to File > Save As > File name: myini.php – Save type as: Choose All Files

Step 1(b):
And If you are not sure where your default php.ini file is located on your server,
Create a php file using Step 1(a) and name it as phpinfo.php with the below snippet:

<?php phpinfo(); ?>

Upload it to the root folder.
Visit on the browser.
Scroll down and Look for Loaded Configuration File.
Example: Loaded Configuration File : /home/username/public_html/php.ini

Step 2:
Go to in your browser
Please note, It will be a Blank Screen only.
What happens is that a copy of your default php.ini file will be created in the root specified.

Step 3:
Use a FTP Client like FileZilla, download the default php.ini file.
Edit the php.ini file using a php-editor like Arisesoft Winsyntax. You can Download Winsyntax here.
Make the necessary changes required in the php.ini file.

Step 4:
Upload your new php.ini file to the root folder using the FTP Client.

Step 4(a):
To avoid showing your php.ini file, Add this to your .htaccess file:

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

That’s it.

2 Responses to “How To Create a php.ini File with Complete Configurations”

  1. Edgardo

    Jun 04. 2012

    I am hosted on a shared host so i cant find the original php.ini with your method or maybe I’m doing something wrong where i can find a complete file php.pni file for php5+

    Reply to this comment
    • Babaji M P

      Jul 11. 2012

      You need to have the Root Access, which isn’t given on shared environment.
      But you can create a php5.ini file and upload it to your blog’s root directory.

      Reply to this comment

Leave a Reply