HostingVPS and dedicatedSpanish version

Support article

How to Increase the PHP Memory Limit in DirectAdmin

Learn how to edit memory_limit in php.ini on your VPS or dedicated server with DirectAdmin to fix PHP out-of-memory errors.

Published: 30/06/2026Updated: 07/07/2026

Introduction

Scripts written in PHP are some of the most common code on the web: they don’t need to be compiled and can be developed quickly, which makes them very useful. However, they have one major drawback: a poorly written script can easily consume all the server’s available resources and even cause other parts to malfunction. That’s why PHP has a default limit on how much server memory a single script can use.

While this limit is necessary for most applications, certain cases require increasing it. On a VPS or dedicated server with DirectAdmin, here’s how to do it.

What the PHP memory_limit setting is

Contrary to what many people think, memory_limit applies at the script level: it’s the maximum amount of server memory a single PHP script is allowed to consume. The official PHP documentation explains it this way: it helps prevent poorly written scripts from consuming all the memory available on the server (php.net).

If you haven’t changed the default setting, memory_limit is usually 128M. If one of your scripts needs more memory than that, you’ll see an error like this:

Fatal error: Allowed memory size of x bytes exhausted (tried to allocate x bytes) in /path/to/php/script

or:

PHP Fatal error: Out of memory (allocated x) (tried to allocate x bytes) in /path/to/php/script

How to increase the PHP memory limit in DirectAdmin

These steps apply to VPS or dedicated servers where you have administrator access. On shared hosting, contact support if you need this value reviewed.

First, ask yourself whether the memory usage is actually reasonable: if it isn’t, the wisest fix is to correct the script’s issues rather than raising the limit. If the usage is legitimate, follow these steps:

Step 1: find your php.ini. An easy trick is to ask PHP which one it’s using:

/usr/local/bin/php --ini | grep 'Loaded Configuration File'

If you’re using the default PHP version on the command line (CLI), your php.ini is usually located at:

/usr/local/lib/php.ini

Step 2: edit the memory_limit line. If you can’t find it, add it to the end of the file:

memory_limit = 256M ; adjust the value to your needs

Save the file. You can use the nano text editor from an SSH session.

Step 3: restart Apache to apply the change.

Keep in mind these other limits can also affect your application:

  • Maximum data size sent via POST: post_max_size = 8M
  • Maximum allowed size for uploaded files: upload_max_filesize = 2M

Frequently asked questions

It depends on the site. Many sites run fine on 128M or 256M, but a store or a WordPress site with heavy plugins may need more.

Does raising memory_limit make the site faster?

Not necessarily. It only lets PHP use more memory. If your site is slow, check performance, caching, plugins, and the database instead.

Can I change it from DirectAdmin without SSH?

It depends on the server setup: in some cases it can be done from the panel’s PHP options, in others you need to edit php.ini over SSH.

Conclusion

The PHP memory limit exists for a good reason: without it, a poorly written script could consume all your server’s resources. If you have a VPS or dedicated server and need more memory for your scripts, edit memory_limit in the correct php.ini and restart Apache. If you’re not sure which file to edit, contact support before making changes.