{"id":457,"date":"2024-07-04T13:26:28","date_gmt":"2024-07-04T13:26:28","guid":{"rendered":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/?p=457"},"modified":"2024-07-04T13:26:28","modified_gmt":"2024-07-04T13:26:28","slug":"custom-php-ini-file-cont","status":"publish","type":"post","link":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/custom-php-ini-file-cont\/","title":{"rendered":"Custom php.ini file-Controlling PHP"},"content":{"rendered":"<p>Custom php.ini file Controlling PHP settings using a custom <code>php.ini<\/code> file can be crucial for tailoring your PHP environment to meet the specific needs of your application. Here\u2019s a step-by-step guide on how to do this:<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_83 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/custom-php-ini-file-cont\/#1_Locate_Your_PHP_Configuration_File\" >1. Locate Your PHP Configuration File<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/custom-php-ini-file-cont\/#2_Create_a_Custom_phpini_File\" >2. Create a Custom php.ini File<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/custom-php-ini-file-cont\/#3_Modify_the_Custom_phpini_File\" >3. Modify the Custom php.ini File<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/custom-php-ini-file-cont\/#4_Configure_the_Web_Server_to_Use_the_Custom_phpini\" >4. Configure the Web Server to Use the Custom php.ini<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/custom-php-ini-file-cont\/#Apache\" >Apache<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/custom-php-ini-file-cont\/#Nginx_with_PHP-FPM\" >Nginx with PHP-FPM<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/custom-php-ini-file-cont\/#5_Verifying_Your_Custom_Settings\" >5. Verifying Your Custom Settings<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/custom-php-ini-file-cont\/#Notes\" >Notes<\/a><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"1_Locate_Your_PHP_Configuration_File\"><\/span>1. Locate Your PHP Configuration File<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Find the current <code>php.ini<\/code> file in use. You can locate it by running:<\/p>\n<p>php &#8211;ini<\/p>\n<p>Or create a PHP file with the following content and access it via your web browser:<\/p>\n<pre>&lt;?php phpinfo(); ?&gt;<\/pre>\n<p>This will display a lot of information about your PHP configuration, including the location of the <code>php.ini<\/code> file.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"2_Create_a_Custom_phpini_File\"><\/span>2. Create a Custom <code>php.ini<\/code> File<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Create a custom <code>php.ini<\/code> file in the directory where your application is located. You can start by copying the default <code>php.ini<\/code> file and then modify it according to your needs.<\/p>\n<pre>cp \/path\/to\/php.ini \/path\/to\/your\/custom\/php.ini<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"3_Modify_the_Custom_phpini_File\"><\/span>3. Modify the Custom <code>php.ini<\/code> File<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Edit your custom <code>php.ini<\/code> file to change the settings you need. Here are some common settings you might want to change:<\/p>\n<ul>\n<li><strong>Memory Limit<\/strong>:<\/li>\n<\/ul>\n<pre>memory_limit = 256M<\/pre>\n<p><strong>Maximum Execution Time<\/strong>:<\/p>\n<pre>max_execution_time = 60<\/pre>\n<p><strong>File Upload Size<\/strong>:<\/p>\n<pre>upload_max_filesize = 50M\r\npost_max_size = 50M<\/pre>\n<p><strong>Error Reporting<\/strong>:<\/p>\n<pre>error_reporting = E_ALL\r\ndisplay_errors = On<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"4_Configure_the_Web_Server_to_Use_the_Custom_phpini\"><\/span>4. Configure the Web Server to Use the Custom <code>php.ini<\/code><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"Apache\"><\/span>Apache<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>If you are using Apache, you can configure it to use your custom <code>php.ini<\/code> by creating a <code>.htaccess<\/code> file in your application directory:<\/p>\n<pre>php_value auto_prepend_file \"\/path\/to\/your\/custom\/php.ini\"<\/pre>\n<h4><span class=\"ez-toc-section\" id=\"Nginx_with_PHP-FPM\"><\/span>Nginx with PHP-FPM<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>For Nginx with PHP-FPM, you can set the <code>php_value<\/code> directives in your <code>server<\/code> block:<\/p>\n<pre>location ~ \\.php$ {\r\nfastcgi_param PHP_VALUE \"auto_prepend_file=\/path\/to\/your\/custom\/php.ini\";\r\nfastcgi_pass unix:\/run\/php\/php7.4-fpm.sock;\r\nfastcgi_index index.php;\r\ninclude fastcgi_params;\r\n}<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"5_Verifying_Your_Custom_Settings\"><\/span>5. Verifying Your Custom Settings<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>After setting up your custom <code>php.ini<\/code> file, create a new PHP file with the following content to verify that your custom settings are applied:<\/p>\n<pre>&lt;?php phpinfo(); ?&gt;<\/pre>\n<p>Access this file via your web browser and check if the settings reflect your custom <code>php.ini<\/code> configuration.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Notes\"><\/span>Notes<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li>Ensure that the custom <code>php.ini<\/code> file has the correct permissions for the web server to read it.<\/li>\n<li>If you are using a shared hosting environment, the ability to customize the <code>php.ini<\/code> file might be restricted.<\/li>\n<li>Always back up the original <code>php.ini<\/code> file before making any changes.<\/li>\n<\/ul>\n<p>By following these steps, you can effectively control and customize PHP settings for your application using a custom <code>php.ini<\/code> file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Custom php.ini file Controlling PHP settings using a custom php.ini file can be crucial for tailoring your PHP environment to meet the specific needs of your application. Here\u2019s a step-by-step guide on how to do this: 1. Locate Your PHP Configuration File Find the current php.ini file in use. You can locate it by running: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-457","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-json\/wp\/v2\/posts\/457","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-json\/wp\/v2\/comments?post=457"}],"version-history":[{"count":6,"href":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-json\/wp\/v2\/posts\/457\/revisions"}],"predecessor-version":[{"id":463,"href":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-json\/wp\/v2\/posts\/457\/revisions\/463"}],"wp:attachment":[{"href":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-json\/wp\/v2\/media?parent=457"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-json\/wp\/v2\/categories?post=457"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hyderabadwebhosting.co.in\/tutorials\/wp-json\/wp\/v2\/tags?post=457"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}