{"id":2974,"date":"2025-12-05T22:20:04","date_gmt":"2025-12-05T19:20:04","guid":{"rendered":"https:\/\/www.dchost.com\/blog\/choosing-the-right-php-memory_limit-max_execution_time-and-upload_max_filesize-for-your-website\/"},"modified":"2025-12-05T22:20:04","modified_gmt":"2025-12-05T19:20:04","slug":"choosing-the-right-php-memory_limit-max_execution_time-and-upload_max_filesize-for-your-website","status":"publish","type":"post","link":"https:\/\/www.dchost.com\/blog\/en\/choosing-the-right-php-memory_limit-max_execution_time-and-upload_max_filesize-for-your-website\/","title":{"rendered":"Choosing the Right PHP memory_limit, max_execution_time and upload_max_filesize for Your Website"},"content":{"rendered":"<div class=\"dchost-blog-content-wrapper\"><p>PHP settings like <strong>memory_limit<\/strong>, <strong>max_execution_time<\/strong> and <strong>upload_max_filesize<\/strong> look like small configuration lines, but they directly decide whether your website quietly works\u2026 or constantly hits white screens, 500 errors and failed uploads. When we review new sites that move to our infrastructure at dchost.com, these three values are among the first things we check. They affect everything from WordPress and WooCommerce to Laravel, custom APIs, LMS platforms and even small corporate sites. The goal is not to push all limits to extreme values, but to set realistic numbers that match your code, traffic, and hosting resources.<\/p>\n<p>In this guide, we will walk through what each of these PHP directives actually does in real life, common mistakes we keep seeing, and safe baseline values for different types of projects. You will see how to change them on shared hosting, cPanel\/DirectAdmin, and <a href=\"https:\/\/www.dchost.com\/vps\">VPS<\/a> or <a href=\"https:\/\/www.dchost.com\/dedicated-server\">dedicated server<\/a>s, and how to debug when you still hit limits. By the end, you will have a practical checklist you can apply immediately on your own hosting or on your servers at dchost.com.<\/p>\n<div id=\"toc_container\" class=\"toc_transparent no_bullets\"><p class=\"toc_title\">\u0130&ccedil;indekiler<\/p><ul class=\"toc_list\"><li><a href=\"#Why_These_PHP_Settings_Matter_More_Than_You_Think\"><span class=\"toc_number toc_depth_1\">1<\/span> Why These PHP Settings Matter More Than You Think<\/a><\/li><li><a href=\"#Understanding_memory_limit_How_Much_PHP_Memory_Do_You_Really_Need\"><span class=\"toc_number toc_depth_1\">2<\/span> Understanding memory_limit: How Much PHP Memory Do You Really Need?<\/a><ul><li><a href=\"#What_memory_limit_Actually_Controls\"><span class=\"toc_number toc_depth_2\">2.1<\/span> What memory_limit Actually Controls<\/a><\/li><li><a href=\"#Typical_Defaults_and_When_They_Fail\"><span class=\"toc_number toc_depth_2\">2.2<\/span> Typical Defaults and When They Fail<\/a><\/li><li><a href=\"#How_to_Estimate_a_Reasonable_memory_limit\"><span class=\"toc_number toc_depth_2\">2.3<\/span> How to Estimate a Reasonable memory_limit<\/a><\/li><li><a href=\"#Practical_Baselines_for_memory_limit\"><span class=\"toc_number toc_depth_2\">2.4<\/span> Practical Baselines for memory_limit<\/a><\/li><li><a href=\"#How_to_Set_memory_limit_phpini_htaccess_and_Per-Site\"><span class=\"toc_number toc_depth_2\">2.5<\/span> How to Set memory_limit (php.ini, .htaccess and Per-Site)<\/a><\/li><\/ul><\/li><li><a href=\"#Understanding_max_execution_time_Keeping_Scripts_Fast_and_Safe\"><span class=\"toc_number toc_depth_1\">3<\/span> Understanding max_execution_time: Keeping Scripts Fast and Safe<\/a><ul><li><a href=\"#What_max_execution_time_Controls\"><span class=\"toc_number toc_depth_2\">3.1<\/span> What max_execution_time Controls<\/a><\/li><li><a href=\"#Where_Low_max_execution_time_Hurts\"><span class=\"toc_number toc_depth_2\">3.2<\/span> Where Low max_execution_time Hurts<\/a><\/li><li><a href=\"#Safe_Ranges_for_max_execution_time\"><span class=\"toc_number toc_depth_2\">3.3<\/span> Safe Ranges for max_execution_time<\/a><\/li><li><a href=\"#Timeouts_Exist_Across_the_Stack\"><span class=\"toc_number toc_depth_2\">3.4<\/span> Timeouts Exist Across the Stack<\/a><\/li><li><a href=\"#How_to_Set_max_execution_time\"><span class=\"toc_number toc_depth_2\">3.5<\/span> How to Set max_execution_time<\/a><\/li><\/ul><\/li><li><a href=\"#upload_max_filesize_and_post_max_size_Getting_File_Uploads_Right\"><span class=\"toc_number toc_depth_1\">4<\/span> upload_max_filesize and post_max_size: Getting File Uploads Right<\/a><ul><li><a href=\"#How_upload_max_filesize_and_post_max_size_Work_Together\"><span class=\"toc_number toc_depth_2\">4.1<\/span> How upload_max_filesize and post_max_size Work Together<\/a><\/li><li><a href=\"#Typical_Values_for_Different_Sites\"><span class=\"toc_number toc_depth_2\">4.2<\/span> Typical Values for Different Sites<\/a><\/li><li><a href=\"#Do_Not_Forget_Web_Server_Limits\"><span class=\"toc_number toc_depth_2\">4.3<\/span> Do Not Forget Web Server Limits<\/a><\/li><li><a href=\"#How_to_Set_upload_max_filesize_and_post_max_size\"><span class=\"toc_number toc_depth_2\">4.4<\/span> How to Set upload_max_filesize and post_max_size<\/a><\/li><\/ul><\/li><li><a href=\"#Changing_PHP_Settings_on_Shared_Hosting_VPS_and_Dedicated_Servers\"><span class=\"toc_number toc_depth_1\">5<\/span> Changing PHP Settings on Shared Hosting, VPS and Dedicated Servers<\/a><ul><li><a href=\"#On_Shared_or_cPanelDirectAdmin_Hosting\"><span class=\"toc_number toc_depth_2\">5.1<\/span> On Shared or cPanel\/DirectAdmin Hosting<\/a><\/li><li><a href=\"#On_VPS_and_Dedicated_Servers\"><span class=\"toc_number toc_depth_2\">5.2<\/span> On VPS and Dedicated Servers<\/a><\/li><\/ul><\/li><li><a href=\"#Recommended_Baselines_and_a_Practical_Tuning_Checklist\"><span class=\"toc_number toc_depth_1\">6<\/span> Recommended Baselines and a Practical Tuning Checklist<\/a><ul><li><a href=\"#Baseline_Settings_for_Common_Use_Cases\"><span class=\"toc_number toc_depth_2\">6.1<\/span> Baseline Settings for Common Use Cases<\/a><\/li><li><a href=\"#A_Step-by-Step_Tuning_Checklist\"><span class=\"toc_number toc_depth_2\">6.2<\/span> A Step-by-Step Tuning Checklist<\/a><\/li><li><a href=\"#Troubleshooting_When_You_Still_Hit_Limits\"><span class=\"toc_number toc_depth_2\">6.3<\/span> Troubleshooting When You Still Hit Limits<\/a><\/li><\/ul><\/li><li><a href=\"#When_PHP_Settings_Are_Not_Enough_Time_to_Rethink_Hosting\"><span class=\"toc_number toc_depth_1\">7<\/span> When PHP Settings Are Not Enough: Time to Rethink Hosting<\/a><\/li><li><a href=\"#Wrapping_Up_Make_PHP_Limits_Work_For_You_Not_Against_You\"><span class=\"toc_number toc_depth_1\">8<\/span> Wrapping Up: Make PHP Limits Work For You, Not Against You<\/a><\/li><\/ul><\/div>\n<h2><span id=\"Why_These_PHP_Settings_Matter_More_Than_You_Think\">Why These PHP Settings Matter More Than You Think<\/span><\/h2>\n<p>From a distance, memory and time limits look like pure backend concerns. In practice, they shape user experience, SEO and even conversion rates. Here is what they really control:<\/p>\n<ul>\n<li><strong>memory_limit<\/strong>: How much RAM a single PHP process can use. Too low and you get fatal errors; too high and a few heavy requests can exhaust server RAM.<\/li>\n<li><strong>max_execution_time<\/strong>: How long PHP is allowed to run a script. Too low and long operations break; too high and you can keep stuck processes hanging around.<\/li>\n<li><strong>upload_max_filesize<\/strong> (and related <strong>post_max_size<\/strong>): The maximum size of files (forms) users can upload. Too low and file uploads silently fail; too high and you risk abuse and wasted resources.<\/li>\n<\/ul>\n<p>These directives interact with your web server (Apache, Nginx, LiteSpeed), database timeouts, and even CDN or WAF settings. They are also one of the root causes behind issues like the WordPress white screen problem. If you have struggled with that, you may want to read our detailed guide on <a href=\"https:\/\/www.dchost.com\/blog\/en\/wordpress-beyaz-ekran-hatasi-cozumu-hosting-ve-php-tarafli-adim-adim-rehber\/\">fixing the WordPress White Screen of Death from the hosting side<\/a> after finishing this article.<\/p>\n<h2><span id=\"Understanding_memory_limit_How_Much_PHP_Memory_Do_You_Really_Need\">Understanding memory_limit: How Much PHP Memory Do You Really Need?<\/span><\/h2>\n<h3><span id=\"What_memory_limit_Actually_Controls\">What memory_limit Actually Controls<\/span><\/h3>\n<p><strong>memory_limit<\/strong> defines the maximum amount of RAM that a single PHP script (a single request) is allowed to allocate. This is not total server RAM, and it is not per user; it is <strong>per PHP process<\/strong>. If a script exceeds this value, PHP stops execution and logs an error similar to:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes)<\/code><\/pre>\n<p>134217728 bytes is 128M; you will often see this in logs when a plugin, theme, or custom script tries to load too much data into memory at once (for example, a huge WooCommerce product export or a poorly written report query).<\/p>\n<h3><span id=\"Typical_Defaults_and_When_They_Fail\">Typical Defaults and When They Fail<\/span><\/h3>\n<p>Common defaults on many hosting environments:<\/p>\n<ul>\n<li>64M or 128M on older shared hosting plans<\/li>\n<li>256M on more modern setups<\/li>\n<li>512M or more on tuned VPS \/ dedicated environments for heavy applications<\/li>\n<\/ul>\n<p>Where these defaults often fail in real projects:<\/p>\n<ul>\n<li><strong>WordPress with many plugins<\/strong>: Page builders, security suites, analytics, WooCommerce, and translation plugins quickly push beyond 128M.<\/li>\n<li><strong>WooCommerce, Magento or other e\u2011commerce<\/strong>: Bulk imports, large product catalogs, and complex cart\/checkout logic can easily hit 256M or more.<\/li>\n<li><strong>LMS platforms (Moodle, custom LMS)<\/strong>: Reporting, grade exports and complex queries often need more RAM during peak processes.<\/li>\n<li><strong>Image-heavy or PDF\u2011heavy workflows<\/strong>: Any script that resizes or manipulates large images or PDFs can spike memory usage.<\/li>\n<\/ul>\n<p>We cover broader performance tuning for LMS workloads in our <a href=\"https:\/\/www.dchost.com\/blog\/en\/moodle-ve-diger-lmsler-icin-hosting-performans-rehberi\/\">Moodle and LMS hosting performance guide<\/a>, where memory_limit is one of the key levers.<\/p>\n<h3><span id=\"How_to_Estimate_a_Reasonable_memory_limit\">How to Estimate a Reasonable memory_limit<\/span><\/h3>\n<p>There is no single magic number, but you can estimate a safe value by thinking about three things:<\/p>\n<ol>\n<li><strong>The heaviest operation on your site<\/strong> (e.g. product import, backup, report)<\/li>\n<li><strong>Concurrent PHP processes<\/strong> (how many requests can run at the same time)<\/li>\n<li><strong>Total RAM available for PHP<\/strong> (after the OS, database, cache, web server, etc.)<\/li>\n<\/ol>\n<p>Assume:<\/p>\n<ul>\n<li>Your heaviest request needs around <strong>256M<\/strong> to complete comfortably.<\/li>\n<li>Your PHP-FPM pool can handle <strong>20 concurrent workers<\/strong>.<\/li>\n<li>You are on a VPS with <strong>4 GB RAM<\/strong>, and you want to reserve about half (2 GB) for PHP.<\/li>\n<\/ul>\n<p>In this scenario, 20 workers \u00d7 256M = 5120M (\u22485 GB) theoretical max usage, which is more than your server RAM. In real life, not all workers hit peak memory at the same time, but this calculation shows that setting memory_limit to 256M with 20 workers may be too optimistic for a 4 GB VPS unless you reduce workers, optimize code, or increase RAM.<\/p>\n<h3><span id=\"Practical_Baselines_for_memory_limit\">Practical Baselines for memory_limit<\/span><\/h3>\n<p>Based on real-world sites we host and tune, a practical starting point is:<\/p>\n<ul>\n<li><strong>Simple blogs or small business sites<\/strong>: 128M\u2013256M<\/li>\n<li><strong>Standard WordPress with several plugins<\/strong>: 256M<\/li>\n<li><strong>WooCommerce or other e\u2011commerce<\/strong>: 256M\u2013512M (sometimes higher for large stores)<\/li>\n<li><strong>LMS, CRM, ERP, SaaS backends<\/strong>: 512M+ for heavy admin operations, with appropriate worker limits<\/li>\n<\/ul>\n<p>These must align with available RAM. On a tiny shared hosting plan, jumping to 1024M memory_limit does not magically give you more RAM; it just makes it easier to overload the server. On a VPS or dedicated server at dchost.com, you can tune PHP-FPM pools and memory_limit together to match the actual RAM you are paying for.<\/p>\n<p>For a more holistic look at server-side tuning for WordPress, including PHP-FPM and OPcache, you may also want to read our article <a href=\"https:\/\/www.dchost.com\/blog\/en\/wordpress-icin-sunucu-tarafi-optimizasyon-php-fpm-opcache-redis-ve-mysql-ile-neyi-ne-zaman-nasil-ayarlamalisin\/\">The Server-Side Secrets That Make WordPress Fly<\/a>.<\/p>\n<h3><span id=\"How_to_Set_memory_limit_phpini_htaccess_and_Per-Site\">How to Set memory_limit (php.ini, .htaccess and Per-Site)<\/span><\/h3>\n<p>You can change memory_limit via several methods, depending on hosting:<\/p>\n<ul>\n<li><strong>php.ini<\/strong> (global or per PHP version)<\/li>\n<li><strong>.user.ini<\/strong> (per directory, often on shared hosting)<\/li>\n<li><strong>.htaccess<\/strong> (for Apache with mod_php or certain handlers)<\/li>\n<li><strong>Control panel UI<\/strong> (cPanel, DirectAdmin, Plesk selectors)<\/li>\n<\/ul>\n<p>Examples:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">; php.ini or .user.ini\nmemory_limit = 256M\n<\/code><\/pre>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\"># .htaccess\nphp_value memory_limit 256M\n<\/code><\/pre>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">\/\/ In a PHP script (temporary change)\nini_set('memory_limit', '256M');\n<\/code><\/pre>\n<p>On cPanel or DirectAdmin, you will often find a &#8220;Select PHP Version&#8221; or &#8220;PHP Options&#8221; screen where you can pick memory_limit without editing files. For more advanced scenarios with multiple applications, see our article on <a href=\"https:\/\/www.dchost.com\/blog\/en\/cpanel-ve-directadminde-coklu-php-surumu-yonetimi-her-site-icin-dogru-php-7-x-8-x-secimi\/\">managing multiple PHP versions per site on cPanel and DirectAdmin<\/a>; there we also touch on per-site PHP settings.<\/p>\n<h2><span id=\"Understanding_max_execution_time_Keeping_Scripts_Fast_and_Safe\">Understanding max_execution_time: Keeping Scripts Fast and Safe<\/span><\/h2>\n<h3><span id=\"What_max_execution_time_Controls\">What max_execution_time Controls<\/span><\/h3>\n<p><strong>max_execution_time<\/strong> sets the maximum <strong>CPU time in seconds<\/strong> that a PHP script is allowed to run. When the limit is reached, PHP terminates the script and may output a fatal error or just close the connection.<\/p>\n<p>Common default values:<\/p>\n<ul>\n<li>30 seconds on many shared hosting setups<\/li>\n<li>60\u2013120 seconds on more generous configurations<\/li>\n<li>Higher values for CLI scripts and background jobs (e.g. 300\u2013600 seconds)<\/li>\n<\/ul>\n<p>Note that for command-line PHP (php-cli), <strong>max_execution_time is often ignored or set to 0 (unlimited)<\/strong>. Long-running tasks like queue workers and cron jobs normally use CLI and separate timeout strategies.<\/p>\n<h3><span id=\"Where_Low_max_execution_time_Hurts\">Where Low max_execution_time Hurts<\/span><\/h3>\n<p>We most commonly see timeouts in:<\/p>\n<ul>\n<li><strong>Large imports\/exports<\/strong> (CSV, XML, product lists, user lists)<\/li>\n<li><strong>Backup or migration plugins<\/strong> that try to run everything in one go<\/li>\n<li><strong>Heavy admin pages<\/strong> (large reports, analytics, or complex filters)<\/li>\n<li><strong>API calls to slow third-party services<\/strong> where your script is waiting for an external response<\/li>\n<\/ul>\n<p>If users report that &#8220;it always stops around 30 seconds&#8221; when doing a certain action, max_execution_time is a prime suspect.<\/p>\n<h3><span id=\"Safe_Ranges_for_max_execution_time\">Safe Ranges for max_execution_time<\/span><\/h3>\n<p>We like to think in tiers:<\/p>\n<ul>\n<li><strong>Regular web requests<\/strong>: 30\u201360 seconds is usually enough if the code is efficient. If a page needs more than 60 seconds, it probably should be broken into smaller chunks or moved to a background job.<\/li>\n<li><strong>Admin-only operations<\/strong>: 60\u2013120 seconds can be acceptable for imports, exports and heavy actions initiated by authenticated admins.<\/li>\n<li><strong>Background or CLI tasks<\/strong>: Use CLI PHP with its own supervision (cron, systemd, queue workers). Set max_execution_time to 0 for CLI and control runtime via process managers instead.<\/li>\n<\/ul>\n<p>Remember: raising max_execution_time does not make slow code fast. It simply allows slow operations to finish instead of being killed. You should still profile and optimize slow queries, caches and external calls.<\/p>\n<h3><span id=\"Timeouts_Exist_Across_the_Stack\">Timeouts Exist Across the Stack<\/span><\/h3>\n<p>One common troubleshooting trap: even if you increase PHP&#8217;s max_execution_time, you might still hit timeouts elsewhere:<\/p>\n<ul>\n<li><strong>Web server<\/strong>: Apache, Nginx, or LiteSpeed have their own request and proxy timeouts.<\/li>\n<li><strong>Load balancer \/ reverse proxy<\/strong>: Upstream timeouts may be shorter than PHP&#8217;s.<\/li>\n<li><strong>Database<\/strong>: MySQL\/MariaDB and PostgreSQL have query and connection timeouts.<\/li>\n<li><strong>CDN or WAF<\/strong>: Some edge providers time out connections after 100 seconds or less.<\/li>\n<\/ul>\n<p>That is why serious performance work always involves checking logs across components. If you want to get comfortable reading web server logs for 4xx and 5xx issues, have a look at our guide on <a href=\"https:\/\/www.dchost.com\/blog\/en\/hosting-sunucu-loglarini-okumayi-ogrenin-apache-ve-nginx-ile-4xx-5xx-hatalarini-teshis-rehberi\/\">diagnosing 4xx\u20135xx errors on Apache and Nginx<\/a>.<\/p>\n<h3><span id=\"How_to_Set_max_execution_time\">How to Set max_execution_time<\/span><\/h3>\n<p>Common ways to set it:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">; php.ini or .user.ini\nmax_execution_time = 60\n<\/code><\/pre>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\"># .htaccess\nphp_value max_execution_time 60\n<\/code><\/pre>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">\/\/ In a PHP script (for that script only)\nini_set('max_execution_time', '60');\n<\/code><\/pre>\n<p>Before you increase it too far, ask yourself: can this operation be restructured? For example, a WooCommerce product import can often be split into smaller batches via the plugin configuration, instead of trying to process 100,000 products in one monstrous request.<\/p>\n<h2><span id=\"upload_max_filesize_and_post_max_size_Getting_File_Uploads_Right\">upload_max_filesize and post_max_size: Getting File Uploads Right<\/span><\/h2>\n<h3><span id=\"How_upload_max_filesize_and_post_max_size_Work_Together\">How upload_max_filesize and post_max_size Work Together<\/span><\/h3>\n<p>PHP uses two directives to control uploads and POST data:<\/p>\n<ul>\n<li><strong>upload_max_filesize<\/strong>: The maximum size of a single uploaded file.<\/li>\n<li><strong>post_max_size<\/strong>: The maximum size of the entire POST request body (including all files and form fields).<\/li>\n<\/ul>\n<p>Some key rules:<\/p>\n<ul>\n<li><strong>post_max_size must be equal to or larger than upload_max_filesize<\/strong>.<\/li>\n<li>If multiple files are uploaded in one form, their total size must be within post_max_size.<\/li>\n<li>Other layers (web server, reverse proxy, WAF, CDN) may have their own body size limits.<\/li>\n<\/ul>\n<p>For example, if you set:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">upload_max_filesize = 32M\npost_max_size = 32M\n<\/code><\/pre>\n<p>then one 32 MB file or several smaller files whose total is up to 32 MB can be uploaded in one request. If you want up to 32 MB per file and multiple files per upload, you might use:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">upload_max_filesize = 32M\npost_max_size = 64M\n<\/code><\/pre>\n<h3><span id=\"Typical_Values_for_Different_Sites\">Typical Values for Different Sites<\/span><\/h3>\n<p>Reasonable starting points:<\/p>\n<ul>\n<li><strong>Standard content sites<\/strong>: 8M\u201316M (for images and small PDFs)<\/li>\n<li><strong>Corporate \/ portfolio \/ blogs<\/strong>: 16M\u201332M (enough for larger images, short videos, PDFs)<\/li>\n<li><strong>E\u2011commerce with product images<\/strong>: 32M\u201364M (raw images, optimized later)<\/li>\n<li><strong>LMS and file sharing features<\/strong>: 64M\u2013256M or more, depending on your policy<\/li>\n<\/ul>\n<p>Always tie this to a clear policy: what is the maximum file size you are comfortable with, given storage, bandwidth and security constraints? Setting everything to 1 GB just &#8220;in case&#8221; usually creates more problems than it solves, especially on smaller VPSs or shared hosting plans.<\/p>\n<h3><span id=\"Do_Not_Forget_Web_Server_Limits\">Do Not Forget Web Server Limits<\/span><\/h3>\n<p>Even if PHP allows 64M uploads, the web server might block them first. Examples:<\/p>\n<ul>\n<li><strong>Nginx<\/strong>: <code>client_max_body_size<\/code><\/li>\n<li><strong>Apache<\/strong>: <code>LimitRequestBody<\/code> or module-specific limits<\/li>\n<li><strong>Reverse proxies \/ CDNs<\/strong>: their own maximum upload S<\/li>\n<\/ul>\n<p>A consistent configuration is important. For instance, on an Nginx + PHP-FPM stack for 64M uploads, you might have:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\"># nginx.conf or vhost\nclient_max_body_size 64M;\n<\/code><\/pre>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">; php.ini\nupload_max_filesize = 64M\npost_max_size = 64M\n<\/code><\/pre>\n<h3><span id=\"How_to_Set_upload_max_filesize_and_post_max_size\">How to Set upload_max_filesize and post_max_size<\/span><\/h3>\n<p>Again, you can use php.ini, .user.ini or .htaccess:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">; php.ini or .user.ini\nupload_max_filesize = 32M\npost_max_size = 64M\n<\/code><\/pre>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\"># .htaccess\nphp_value upload_max_filesize 32M\nphp_value post_max_size 64M\n<\/code><\/pre>\n<p>On many control panels, these values are available under the same PHP settings interface where you changed memory_limit and max_execution_time.<\/p>\n<h2><span id=\"Changing_PHP_Settings_on_Shared_Hosting_VPS_and_Dedicated_Servers\">Changing PHP Settings on Shared Hosting, VPS and Dedicated Servers<\/span><\/h2>\n<h3><span id=\"On_Shared_or_cPanelDirectAdmin_Hosting\">On Shared or cPanel\/DirectAdmin Hosting<\/span><\/h3>\n<p>On shared hosting (including shared plans at dchost.com), your access is usually limited to per-account settings, but that is still enough for most websites. Typical approaches:<\/p>\n<ul>\n<li>Use the panel&#8217;s <strong>PHP Selector \/ MultiPHP Manager \/ PHP Options<\/strong> to change values.<\/li>\n<li>Create or edit <strong>.user.ini<\/strong> or <strong>.htaccess<\/strong> in your document root if supported.<\/li>\n<\/ul>\n<p>Example workflow on cPanel-like environments:<\/p>\n<ol>\n<li>Log in to the control panel.<\/li>\n<li>Open the PHP settings tool (e.g. &#8220;Select PHP Version&#8221; then &#8220;Options&#8221;).<\/li>\n<li>Adjust <strong>memory_limit<\/strong>, <strong>max_execution_time<\/strong>, <strong>upload_max_filesize<\/strong> and <strong>post_max_size<\/strong>.<\/li>\n<li>Save and test by uploading a larger file or repeating the heavy operation.<\/li>\n<\/ol>\n<p>If you are frequently hitting resource ceilings on shared hosting even after tuning PHP settings, it is worth reading our article on <a href=\"https:\/\/www.dchost.com\/blog\/en\/paylasimli-hostingde-resource-limit-reached-hatasini-onlemek\/\">how to avoid the &#8220;Resource Limit Reached&#8221; error on shared hosting<\/a>. It explains CPU, memory and I\/O limits at the account level, which exist above PHP&#8217;s own limits.<\/p>\n<h3><span id=\"On_VPS_and_Dedicated_Servers\">On VPS and Dedicated Servers<\/span><\/h3>\n<p>On a VPS or dedicated server (for example, one you manage at dchost.com), you have full control over:<\/p>\n<ul>\n<li><strong>Global PHP configuration<\/strong> (<code>\/etc\/php\/&lt;version&gt;\/fpm\/php.ini<\/code>, <code>cli\/php.ini<\/code>, etc.)<\/li>\n<li><strong>Per-pool PHP-FPM configs<\/strong> to tune worker counts and memory usage<\/li>\n<li><strong>Web server settings<\/strong> (Nginx\/Apache body size and timeout directives)<\/li>\n<\/ul>\n<p>This opens the door to more serious tuning. For example, on PHP-FPM you might:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">; \/etc\/php\/8.2\/fpm\/php.ini\nmemory_limit = 512M\nmax_execution_time = 60\nupload_max_filesize = 64M\npost_max_size = 64M\n<\/code><\/pre>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">; \/etc\/php\/8.2\/fpm\/pool.d\/www.conf\npm = dynamic\npm.max_children = 20\npm.max_requests = 500\n<\/code><\/pre>\n<p>Here you must think about the <strong>combined effect<\/strong> of memory_limit and max_children. 20 children \u00d7 512M theoretical max is about 10 GB potential PHP usage, so this configuration only makes sense on a machine with enough RAM and with the understanding that not every process will reach the limit at the same time.<\/p>\n<p>If you regularly handle larger loads or mission-critical applications, we strongly recommend pairing PHP tuning with broader performance and capacity planning. Our article on <a href=\"https:\/\/www.dchost.com\/blog\/en\/yeni-web-sitesi-icin-cpu-ram-ve-trafik-nasil-hesaplanir\/\">how much CPU, RAM and bandwidth a new website needs<\/a> is a good starting point before you choose your VPS or dedicated specs at dchost.com.<\/p>\n<h2><span id=\"Recommended_Baselines_and_a_Practical_Tuning_Checklist\">Recommended Baselines and a Practical Tuning Checklist<\/span><\/h2>\n<h3><span id=\"Baseline_Settings_for_Common_Use_Cases\">Baseline Settings for Common Use Cases<\/span><\/h3>\n<p>These are not hard rules, but they work well as starting points on reasonably sized hosting plans (2\u20134 vCPU, 4\u20138 GB RAM) when balanced with correct worker counts:<\/p>\n<table border=\"1\" cellpadding=\"6\" cellspacing=\"0\">\n<thead>\n<tr>\n<th>Use Case<\/th>\n<th>memory_limit<\/th>\n<th>max_execution_time<\/th>\n<th>upload_max_filesize<\/th>\n<th>post_max_size<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Small blog \/ corporate site<\/td>\n<td>128M\u2013256M<\/td>\n<td>30\u201345s<\/td>\n<td>8M\u201316M<\/td>\n<td>16M<\/td>\n<\/tr>\n<tr>\n<td>Standard WordPress with several plugins<\/td>\n<td>256M<\/td>\n<td>45\u201360s<\/td>\n<td>32M<\/td>\n<td>32M\u201364M<\/td>\n<\/tr>\n<tr>\n<td>WooCommerce \/ medium e\u2011commerce<\/td>\n<td>256M\u2013512M<\/td>\n<td>60\u201390s<\/td>\n<td>64M<\/td>\n<td>64M\u2013128M<\/td>\n<\/tr>\n<tr>\n<td>LMS, CRM, internal tools<\/td>\n<td>512M+<\/td>\n<td>60\u2013120s<\/td>\n<td>64M\u2013256M<\/td>\n<td>Same or higher than upload_max_filesize<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Always validate against real usage: check logs, run imports or backups on staging, and watch resource graphs.<\/p>\n<h3><span id=\"A_Step-by-Step_Tuning_Checklist\">A Step-by-Step Tuning Checklist<\/span><\/h3>\n<ol>\n<li><strong>Identify your heaviest operations<\/strong>: imports, exports, backups, large page loads, report generation.<\/li>\n<li><strong>Check current errors<\/strong> in PHP error logs and web server logs for &#8220;Allowed memory size exhausted&#8221; or timeouts.<\/li>\n<li><strong>Increase memory_limit<\/strong> in small steps (128M \u2192 256M \u2192 384M, etc.), testing after each change.<\/li>\n<li><strong>Adjust max_execution_time<\/strong> for operations that genuinely need more time, while keeping regular page loads within 30\u201360 seconds.<\/li>\n<li><strong>Set upload_max_filesize and post_max_size<\/strong> based on a clear policy for maximum upload size.<\/li>\n<li><strong>Align web server settings<\/strong> (client_max_body_size, timeouts) with PHP limits.<\/li>\n<li><strong>Monitor impact<\/strong> on RAM, CPU and disk I\/O. If you are constantly near the ceiling, tune PHP-FPM workers or consider a larger plan at dchost.com.<\/li>\n<\/ol>\n<p>If you are in the process of upgrading to PHP 8.x, make sure you also review our <a href=\"https:\/\/www.dchost.com\/blog\/en\/php-8-x-yukseltme-kontrol-listesi-wordpress-ve-laravelde-geriye-uyumluluk-opcache-preload-ve-fpm-havuz-ayarlari-nasil-tatli-tatli-kurulur\/\">PHP 8.x upgrade checklist<\/a>, where we combine version upgrades, OPcache tuning and PHP-FPM pool settings with these basic directives.<\/p>\n<h3><span id=\"Troubleshooting_When_You_Still_Hit_Limits\">Troubleshooting When You Still Hit Limits<\/span><\/h3>\n<p>If you have increased limits and still face issues:<\/p>\n<ul>\n<li><strong>Look for specific error messages<\/strong> in PHP and web server logs, not just on screen.<\/li>\n<li><strong>Check cPanel or panel resource usage charts<\/strong> to see if CPU\/IO\/EP limits are being hit.<\/li>\n<li><strong>Profile slow pages or operations<\/strong>: sometimes one plugin or query is the entire problem.<\/li>\n<li><strong>Use staging<\/strong> to reproduce and test with different settings before changing production.<\/li>\n<\/ul>\n<p>Our article on <a href=\"https:\/\/www.dchost.com\/blog\/en\/cpanelde-kaynak-limitleri-cpu-io-ep-ram-ve-resource-limit-reached-hatasi\/\">understanding cPanel resource limits<\/a> is a useful companion here, because it explains the outer boundaries that surround your PHP settings on shared hosting.<\/p>\n<h2><span id=\"When_PHP_Settings_Are_Not_Enough_Time_to_Rethink_Hosting\">When PHP Settings Are Not Enough: Time to Rethink Hosting<\/span><\/h2>\n<p>Sometimes the problem is not your config values, but the physical limits of your hosting environment. Signs that it is time to upgrade or re-architect include:<\/p>\n<ul>\n<li>You have already set reasonable PHP limits and optimized code, but still hit memory or CPU bottlenecks.<\/li>\n<li>Simple traffic spikes regularly push your site into 500 errors or timeouts.<\/li>\n<li>You need consistently higher upload limits and background processing than shared hosting comfortably supports.<\/li>\n<li>Your site is growing into a full e\u2011commerce or SaaS platform with predictable high loads.<\/li>\n<\/ul>\n<p>In those cases, moving from entry-level shared hosting to a VPS or dedicated server is often the cleanest next step. At dchost.com, we provide shared hosting, VPS, dedicated and colocation options, so you can match PHP limits with actual hardware resources instead of fighting within tight ceilings.<\/p>\n<p>For a structured way to detect when an upgrade is truly necessary, not just &#8220;nice to have&#8221;, you can check our article on <a href=\"https:\/\/www.dchost.com\/blog\/en\/hosting-paketinizi-yukseltmeniz-gerektigini-gosteren-9-sunucu-tarafli-sinyal\/\">server-side signals that it is time to upgrade your hosting plan<\/a>. Combining those signals with the PHP tuning steps in this article will give you a clear roadmap.<\/p>\n<h2><span id=\"Wrapping_Up_Make_PHP_Limits_Work_For_You_Not_Against_You\">Wrapping Up: Make PHP Limits Work For You, Not Against You<\/span><\/h2>\n<p>PHP settings like memory_limit, max_execution_time and upload_max_filesize are not just random numbers you copy from a tutorial. They are guardrails that protect your server resources while still allowing your applications to do real work. When they are too low, you see white screens, broken uploads and failed imports. When they are too high on undersized infrastructure, a few heavy requests can consume all RAM or CPU and slow down everything else.<\/p>\n<p>The best approach is systematic: understand what each directive does, start from sane baselines for your type of site, and then adjust based on actual usage, logs and monitoring. On shared hosting, use panel tools and per-directory configuration to stay within account limits. On VPS or dedicated servers, combine PHP settings with tuned PHP-FPM pools, web server limits and properly sized hardware.<\/p>\n<p>If you are hosting with dchost.com or considering moving your sites to us, our team can help you align these PHP values with the right hosting plan, whether that is shared hosting for a small corporate site, an NVMe VPS for WordPress and WooCommerce, or a dedicated server or colocation setup for custom PHP applications. Configure your limits thoughtfully once, and you will spend far less time chasing random errors and far more time building the features your visitors actually see.<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>PHP settings like memory_limit, max_execution_time and upload_max_filesize look like small configuration lines, but they directly decide whether your website quietly works\u2026 or constantly hits white screens, 500 errors and failed uploads. When we review new sites that move to our infrastructure at dchost.com, these three values are among the first things we check. They affect [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2975,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-2974","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-teknoloji"],"_links":{"self":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts\/2974","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/comments?post=2974"}],"version-history":[{"count":0,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts\/2974\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/media\/2975"}],"wp:attachment":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/media?parent=2974"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/categories?post=2974"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/tags?post=2974"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}