WHAT IS PHP.INI FILE?
The php.ini file is a default configuration file that runs whenever a php script is executed. With the help of php.ini file several changes in the settings and other customization can be made which directly affects the functionality of php programming language.
Everytime you made changes to the php.ini file, you will need to restart the php server in order to see those changes.
HOW TO CREATE A NEW CUSTOM PHP.INI FILE?
Creating a new php.ini file for public_html folder involves very simple steps. We have shown below two ways to create a custom php.ini file.
(1) Using cPanel Account
⏩ First you will have to log into your cPanel account.
⏩ Open the File Manager.
⏩ Plot a route to ensure that the file is being created in the public_html directory.
⏩ Click on the New File tab.
⏩ Type php.ini in the box provided for New File Name.
⏩ Click on the Create New File tab.
By following the above steps, a new custom php.ini file will be created which can be further edited accordingly(See How to edit php.ini file? section).
(2) Using a Text Editor(We have used Notepad)
⏩ Open the notepad text editor.
⏩ Type variables you want to add like upload_max_filesize, post_max_size, memory_limitetc.
⏩ Now click on File and Save As.
⏩ Type php.ini in the File name box.
⏩ Choose All Files in the Save as type box and then save the file.
⏩ The File is created now.
⏩ Upload the file to a folder i.e, public_html folder.
HOW TO EDIT PHP.INI FILE?
To edit a php.ini file using cPanel, the following steps should be followed.
- Select php.ini file that you have created.
- Click on the Code Editor tab.
- Check whether you are going to edit the correct file and then Click on the Edit tab.
- Add the php.ini directives and change their values as per the need.
- Now, click on the Save Changes tab to finish the editing.
Some of the php.ini directives with the help of which you can edit a php.ini file or change the configuration settings are listed below with their default values in the brackets.
- allow_url_fopen (“1”)
- apc.enabled (“1”)
- allow_url_include (0)
- default_charset (“UTF-8”)
- disable_functions (“”)
- disable_errors (“1”)
- expect.timeout (“10”)
- file_uploads (“1”)
- html_errors (“1”)
- include_path (“.;/path/to/php/pear”)
- magic_quotes_gpc (“1”)
- magic_quotes_runtime (“0”)
- max_execution_time (30 sec)
- memory_limit (128 mb)
- open_basedir (NULL)
- post_max_size (8M)
- register_globals (“0”)
- safe_mode (“0”)
- SMTP ( Localhost)
- upload_max_filesize (2M)
PURPOSE OF PHP.INI FILE?
(1) to increase the size of the upload file (upload_max_filesize).
(2) to alter the maximum execution time (max_execution_time).
(3) to maximize the input time (max_input_time).
(4) to maximize the size of post data (post_max_size).
(5) to make changes in other php.ini directives like memory limit, magic_quotes_gpc, magic_quotes_runtime etc.
We have provided you the best possible information about all the aspects regarding a php.ini file. Hope you liked this article. For further updates and related information, stay connected to our php blogs.