Find source of memory issues

The websites on my Linode are more and more regularly not working due to (I believe) Apache memory issues. I can fix the problem by restarting Apache, but I'd obviously prefer to address the underlying problem to prevent this happening in the first place. I followed https://www.linode.com/docs/troubleshoo … eshooting/">https://www.linode.com/docs/troubleshooting/troubleshooting/ and determined that I have an issue with memory, however these steps https://www.linode.com/docs/troubleshoo … ng-issues/">https://www.linode.com/docs/troubleshooting/troubleshooting-memory-and-networking-issues/ don't really help since you can't use those settings permanently and I'm not sure what setting them low temporarily will solve…

I'm therefore looking for a way to work out why Apache is running out of memory. Is it a certain website that is mis-configured, is it simply lots of traffic and I need to upgrade my plan (it'd be nice to know which website too), or something else. Any advice/steps to find the root cause would be much appreciated!

6 Replies

There are several ways to run Apache (prefork, worker, event) and several ways to run PHP (which is one of the likely reasons for your memory problems). You have not given any detail about your particular setup, so we can only guess.

In either case, if you are running Apache >= 2.4, I recommend that you use php-fpm for PHP (Debian/Ubuntu package name "php5-fpm").

> You have not given any detail about your particular setup I'm happy to provide any info you need, just tell me what and how :)

Ok, I found http://serverfault.com/a/663878/293911 and my Apache is setup as 'prefork'. It's also running version 'Apache/2.4.7 (Ubuntu)'

Considering http://serverfault.com/a/383634/293911 should I set it up as 'event' instead?

I can't work out what the PHP setup options are or which I'm running…

> I can't work out what the PHP setup options are or which I'm running…

Create a file called "info.php" in the root of your web server containing this line:

Then visit the address http://example.com/info.php where example.com is your site address.

Your server will probably say "Server API: Apache 2.0 Handler" which means you are using mod-php.

This is the very short recipe to switch to php-fpm on Debian, I think it will work in Ubuntu too:

apt-get install apache2 php5-fpm
a2enmod proxy
a2enmod proxy_fcgi
nano /etc/apache2/sites-available/000-default.conf

Insert this in appropriate place:

  <filesmatch \.php$="">SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost/"</filesmatch> 
  DirectoryIndex index.php index.html index.htm

then restart apache:

service apache2 restart

Yes, I'm using 'Server API: Apache 2.0 Handler'. I'll look into switching to php-fpm, thanks.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct