How To Create a php.ini File with Complete Configurations
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 ?
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.
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
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 www.domain.com/phpinfo.php on the browser.
Scroll down and Look for Loaded Configuration File.
Example: Loaded Configuration File : /home/username/public_html/php.ini
Go to www.domain.com/myini.php 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.
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.
Upload your new php.ini file to the root folder using the FTP Client.
To avoid showing your php.ini file, Add this to your .htaccess file:
1 2 3 4
<Files php.ini> order allow,deny deny from all </Files>