Is your site WordPress loads slowly? It's frustrating to see visitors abandon your website before the first screen finishes rendering. Speed is crucial for user experience and SEO, and although we often blame plugins or images, one of the most common bottlenecks is one level below: the server's PHP configuration. In this guide we are going to speed up WordPress with PHP settings in 3 steps: update the PHP version, adjust key directives (memory_limit, max_execution_time, upload_max_filesize) and activate OPcache. All with real code snippets and an objective way to measure the improvement.
Before touching anything: measure your starting point
To know if a change works, you have to measure before and after, not rely on feeling. Two free tools are enough:
- PageSpeed Insights (pagespeed.web.dev): note the value of TTFB (time to first byte) and of LCP. TTFB is what best reflects PHP's work: it's how long the server takes to generate the page.
- Query Monitor (free plugin): in the admin bar it shows you the page generation time in seconds and the peak memory consumed on each load.
Write down those numbers. At the end of the guide, you will repeat the measurement on the same pages and know exactly how much you have gained.
Step 1: check and update your PHP version
If you could only do one thing to speed up WordPress via PHP, this would be it. Each major PHP version is notably faster than the previous one: the jump from PHP 7.4 to PHP 8.x brought the JIT compiler and real performance improvements in WordPress, plus extra years of security support. A WordPress on PHP 8.2 or 8.3 serves more requests per second than the same site on 7.4, without changing anything else.
First, find out which version you are using. In your WordPress, go to Tools > Site Health > Info > Server: ahí verás “Versión de PHP”. Si estás por debajo de 8.1, toca actualizar.
The update is done from your hosting panel, not from WordPress:
- Make a full backup (files and database). It's a reversible change, but better with a safety net.
- Log in to your hosting panel. In cPanel busca “Select PHP Version” o “MultiPHP Manager”; en Plesk, “Configuración de PHP” dentro del dominio; en IONOS, SiteGround o Webempresa hay un selector equivalente en los ajustes del sitio.
- Select the latest stable version supported by your hosting (ideally PHP 8.2 or 8.3) and save.
- Browse your website and WordPress dashboard for a few minutes. If a fatal error appears, it's almost always an incompatible old plugin or theme: revert to the previous PHP version from the same selector, update or replace the conflicting component, and retry.
What improves: the entire server processing time. It is the adjustment with the greatest impact of the three, and it also closes vulnerabilities in unsupported versions.
Step 2: adjust key PHP directives
PHP works with configurable limits. If they are too low, WordPress drags or directly fails; if they are well-sized, the site breathes. The three directives that matter:
memory_limit: maximum memory per PHP process. With visual themes, WooCommerce, or many plugins, 128M is insufficient; 256M is the recommended value today.max_execution_time: seconds a script can run before being cut off. Affects imports, backups, and large updates. 60-120 seconds is reasonable.upload_max_filesize(and its partnerpost_max_size): maximum upload size. If you can't upload a theme or a video, this is it.
You can set them in three places, depending on the access your hosting gives you. Choose only one, not all three at once.
Option A: php.ini (the preferred method)
Many shared hostings let you edit a php.ini from the panel itself (or the PHP selector brings these options as editable fields). The values would be as follows:
memory_limit = 256M
max_execution_time = 120
upload_max_filesize = 64M
post_max_size = 64M
Option B: wp-config.php (for WordPress memory)
WordPress defines its own memory limits above PHP. Edit wp-config.php via FTP or from the file manager and add these lines just before /* That's all, stop editing! Happy publishing. */:
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
La primera fija la memoria del sitio público; la segunda, la del escritorio de administración, que suele necesitar más. Más abajo dedicamos un apartado completo al límite de memoria, con los errores típicos y sus soluciones.
Option C: .htaccess (Apache with mod_php only)
If your server is Apache and runs PHP as a module, you can add to the end of the .htaccess from the root:
php_value memory_limit 256M
php_value max_execution_time 120
php_value upload_max_filesize 64M
php_value post_max_size 64M
Warning: on servers with PHP-FPM (most modern hostings) these lines cause a 500 error. If your website crashes when saving them, delete them and use option A or B.
What improves: elimina errores de memoria agotada, timeouts en actualizaciones e importaciones, y fallos al subir archivos grandes. No hace la web “más rápida” en cada visita, pero sí más estable bajo carga.
Step 3: activate OPcache, the silent turbo
Every time someone visits your website, PHP would have to read and compile dozens of WordPress files. OPcache saves that already compiled code in memory, so that subsequent requests are served without recompiling anything. It's the cheapest performance improvement available: it's included in PHP and just needs to be activated.
Check if you have it in Tools > Site Health > Info > Server (o pregunta a tu hosting). En la mayoría de paneles se activa con una casilla en el selector de PHP (“opcache”). Si tu hosting te permite ajustar su configuración, estos valores funcionan bien para WordPress:
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=10000
opcache.revalidate_freq=60
What improves: the processing time of each PHP request, across the entire site. Along with the updated PHP version, it's what lowers the TTFB the most.
OPcache speeds up PHP execution, but it doesn't prevent it from running on every visit: page caching does that. They are complementary layers, and we tell you about the second one in our analysis of WP Rocket, the reference cache plugin in WordPress.
Measure again and compare
Now repeat the initial measurements, on the same pages: PageSpeed Insights for TTFB and LCP, and Query Monitor for generation time and memory. Speeding up WordPress with PHP settings is not magic, it's server physics: what's common after these three steps is to see the TTFB drop significantly (often 20-40% just with the PHP version jump and OPcache) and memory and timeout errors disappear. If your website is still slow after this, the problem will be in another layer: heavy plugins, unoptimized images, or an undersized server. In that case, check what hosting you need for WordPress before continuing to accumulate optimization plugins.
A fondo: el límite de memoria PHP y sus errores típicos
De las tres directivas anteriores, memory_limit es la que más problemas da en el día a día, así que merece su propio apartado. WordPress está escrito en PHP, y cada vez que alguien carga una página, el servidor ejecuta un proceso PHP que consume memoria RAM. El límite de memoria define cuánta puede usar como máximo ese proceso: si un script lo supera, PHP lo mata en seco y la página se rompe a mitad de carga o aparece la temida pantalla blanca.
The unmistakable symptom is this message on screen or in the server error log:
Fatal error: Allowed memory size of 134217728 bytes exhausted
(tried to allocate 2348617 bytes) in /home/usuario/public_html/wp-includes/...
Ese número gigante son bytes: 134217728 equivale a 128M, que sería tu límite actual. Otras señales del mismo problema: la pantalla blanca de la muerte (WSOD) sin mensaje alguno, errores 500 intermitentes al guardar entradas o editar con el constructor, imágenes que se suben pero no generan miniaturas, y actualizaciones de plugins que se quedan a medias. WordPress también puede avisarte con un genérico “Ha habido un error crítico en esta web” mientras el detalle real queda en el log del servidor.
Identifica tu límite actual con Salud del sitio
Before changing anything, check your starting point. In your dashboard, go to Tools > Site Health > Info and open two sections:
- WordPress (o “Constantes de WordPress”): ahí aparece el valor de
WP_MEMORY_LIMIT, the limit that WordPress imposes on itself. - Server: ahí verás el “Límite de memoria de PHP” real del servidor (
memory_limit).
Este matiz es importante: hay dos capas. WordPress usa por defecto 40M en el sitio público (64M en multisitio) aunque el servidor permita más, y el servidor a su vez tiene su propio techo. Para que un aumento funcione, el valor de WordPress debe caber dentro del valor del servidor. Los métodos para subir ambos valores son exactamente las opciones A, B y C del paso 2: php.ini para el techo del servidor y wp-config.php para el de WordPress.
When your hosting sets the limit (and what to do)
In shared hosting, the provider sets a memory_limit maximum at the server level that none of your directives can exceed: you can ask for 512M in wp-config.php, but if the plan contracts 256M, you'll stay at 256M. Clues that you are in this situation: the Site Health value does not change after editing the files, or the hosting reverts your php.ini. The real options are three: open a support ticket asking for the increase (many apply it at no cost), upgrade to a higher plan, or migrate to a provider with more generous resources. Before deciding, take a look at our guide on what hosting you need for WordPress.
Ten en cuenta también que más memoria no es un remedio universal: si un plugin tiene una fuga de memoria, subir el límite solo retrasa el error. Trata el límite de memoria como una pieza de la puesta a punto, no como la solución completa.
Frequently Asked Questions
Is it safe to update the PHP version of my WordPress?
Yes, as long as you make a full backup first. The change is reversible from the hosting panel: if something
What happens if my site doesn't work after updating PHP?
Casi siempre es un plugin o tema incompatible. Revierte la versión de PHP desde el selector del hosting para recuperar la web, activa el registro de errores o revisa el “error log” del panel para identificar el archivo que provoca el fallo, y actualiza o reemplaza ese componente. Después vuelve a subir la versión de PHP. Desactivar plugins por bloques (la mitad cada vez) también localiza al culpable rápidamente.
How much speed can I gain by accelerating WordPress with these PHP settings?
It depends on the starting point. Moving from PHP 7.4 to 8.2/8.3 with OPcache active usually reduces page generation time by 20 to 40%, which is especially noticeable in TTFB and the administration dashboard. Memory and execution time settings don't speed up every visit, but they eliminate errors and crashes during peak workloads. To further reduce loading time, the next step is full page caching.
What is a recommended PHP memory limit for WordPress?
For a simple blog or corporate website, 128M is enough. For most sites with a visual builder and a dozen plugins, 256M is the sweet spot. WooCommerce stores with large catalogs, or websites with frequent imports, may need 512M. Going beyond that rarely helps: if you're still running out of memory with 512M, the problem is usually a faulty plugin, not the limit.
What happens if my hosting doesn't allow me to increase the PHP memory limit?
First, contact support: in many hostings, increasing it to 256M is a matter of asking. If your contracted plan has a hard cap, consider upgrading your plan or migrating to a provider with more resources, especially if your website generates income. Meanwhile, reduce consumption: deactivate unused plugins, avoid heavy builders, and keep your theme updated.