Cover Image for Creation of custom php.ini file in CPanel
169 views

Creation of custom php.ini file in CPanel

Creating a custom php.ini file in cPanel allows you to customize PHP settings for your specific website. Here’s how you can create a custom php.ini file in cPanel:

  1. Log in to cPanel:
    Access your cPanel dashboard using your hosting provider’s login credentials.
  2. File Manager:
    In cPanel, navigate to the “File Manager” option under the “Files” section.
  3. Select the Website Directory:
    Choose the directory corresponding to the website for which you want to create a custom php.ini file. Typically, it is the “public_html” directory for the main website.
  4. Create a New File:
    Click on the “New File” option in the File Manager toolbar. Name the file “php.ini”.
  5. Edit the php.ini File:
    Right-click on the newly created “php.ini” file and select the “Edit” option. Alternatively, you can use the “Code Editor” option in the File Manager toolbar to open and edit the file.
  6. Customize PHP Settings:
    Inside the php.ini file, you can add or modify PHP settings as needed. For example:
memory_limit = 128M
upload_max_filesize = 32M
post_max_size = 64M
max_execution_time = 120

These settings increase the memory limit, file upload size, maximum POST data size, and execution time for PHP scripts.

  1. Save Changes:
    After making the necessary changes to the php.ini file, save the file.
  2. Verify the Changes:
    To check if the custom php.ini file is in effect, you can create a PHP file (e.g., info.php) with the following content:
<?php
phpinfo();
?>

Save the info.php file in the same directory where you created the custom php.ini file. Access the PHP info file in your browser (e.g., http://yourdomain.com/info.php) and search for the settings you modified in the php.ini file. If the changes are reflected in the PHP info page, it means the custom php.ini file is being used.

  1. Remove PHP Info File (optional):
    After verifying that the custom php.ini file is working as intended, it is a good practice to remove the info.php file or move it to a secure location to prevent unauthorized access to your server’s PHP settings.

Please note that not all hosting providers allow users to create custom php.ini files, especially on shared hosting plans. If you encounter any issues or have limitations, consider contacting your hosting provider’s support for assistance or upgrading your hosting plan to gain more control over PHP settings.

YOU MAY ALSO LIKE...

The Tech Thunder

The Tech Thunder

The Tech Thunder


COMMENTS